Note created with Notion API Feb 25, 2024 This is the code that I used to sync that note. I still want to improve it: const { Client, collectPaginatedAPI } = require("@notionhq/client"); const { NotionToMarkdown } = require("notion-to-md"); const dotenv = require("dotenv"); const fs = require("fs"); const YAML = require("yaml"); dotenv.config(); const notion = new Client({ auth: process.env.NOTION_TOKEN, }); const n2m = new NotionToMarkdown({ notionClient: notion }); const syncNote = async ({ id, title, date }) => { const mdblocks = await n2m.pageToMarkdown(id); const frontMatter = { title, date, layout: "note", }; fs.writeFileSync( `notes/${id}.md`, `---\n${YAML.stringify(frontMatter)}---\n\n${ n2m.toMarkdownString(mdblocks).parent }` ); }; const syncNotes = async () => { const result = await notion.databases.query({ database_id: "[redacted]", filter: { property: "Type", select: { equals: "note", }, }, }); if (result.object === "list") { for (let page of result.results) { await syncNote({ id: page.id, title: page.properties.Name.title[0].text.content, date: page.created_time, }); } } };