This project is a TypeScript-based tool that extracts journal entries from a Notion database for the past 7 days and saves them into a structured XML file.
- Connects to Notion using the official API.
- Queries entries created in the last 7 days.
- Extracts text content from paragraph blocks.
- Formats output as XML with date-based IDs.
- Node.js installed on your machine.
- A Notion Integration Token (API Key).
- The ID of the Notion database you want to extract from.
-
Install dependencies:
npm install
-
Configure Environment Variables:
Create a
.envfile in the root directory with the following variables:NOTION_API_KEY=your_notion_integration_token NOTION_PAGE_ID=your_notion_database_id OUTPUT_PATH=./journal_entries.xml
Note: Ensure your Notion Integration has access to the target database.
Run the extraction script using tsx:
npx tsx extract.tsThe script generates an XML file (specified by OUTPUT_PATH) with the following structure:
<entry id="2023-10-27">
Content of the journal entry...
</entry>
<entry id="2023-10-28">
Another entry content...
</entry>