{"id":15020999,"url":"https://github.com/neogeek/notion-to-json","last_synced_at":"2026-01-18T01:35:54.611Z","repository":{"id":41841141,"uuid":"441379223","full_name":"neogeek/notion-to-json","owner":"neogeek","description":"Fetch Notion Pages as JSON","archived":false,"fork":false,"pushed_at":"2022-04-27T04:47:50.000Z","size":148,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T07:18:49.188Z","etag":null,"topics":["json","notion"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neogeek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-24T05:54:09.000Z","updated_at":"2023-10-16T19:37:42.000Z","dependencies_parsed_at":"2022-08-11T19:01:34.163Z","dependency_job_id":null,"html_url":"https://github.com/neogeek/notion-to-json","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neogeek%2Fnotion-to-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neogeek%2Fnotion-to-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neogeek%2Fnotion-to-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neogeek%2Fnotion-to-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neogeek","download_url":"https://codeload.github.com/neogeek/notion-to-json/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280176,"owners_count":20912965,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","notion"],"created_at":"2024-09-24T19:55:59.768Z","updated_at":"2026-01-18T01:35:54.553Z","avatar_url":"https://github.com/neogeek.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](cover.png)\n\n\u003e Fetch Notion Pages as JSON\n\n[![NPM Version](http://img.shields.io/npm/v/notion-to-json.svg?style=flat)](https://www.npmjs.org/package/notion-to-json)\n[![Tests](https://github.com/neogeek/notion-to-json/actions/workflows/test.workflow.yml/badge.svg)](https://github.com/neogeek/notion-to-json/actions/workflows/test.workflow.yml)\n\n## Install\n\n```bash\n$ npm install notion-to-json --save\n```\n\n## Setup\n\nCreate integration at \u003chttps://www.notion.so/my-integrations/\u003e and use the **Internal Integration Token** when requesting pages.\n\n## Usage\n\n```typescript\nimport { getPageSimple } from 'notion-to-json';\n\n(async () =\u003e {\n  const page = await getPageSimple('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', {\n    api_key: 'secret_xxxxxxxxxxxx'\n  });\n\n  console.log(page.title);\n  console.log(page.blocks);\n})();\n```\n\n### Next.js\n\n```typescript\nimport type { NextPage } from 'next';\nimport Head from 'next/head';\n\nimport sanitizeHtml from 'sanitize-html';\n\nimport { getPageSimple } from 'notion-to-json';\nimport { SupportedBlockTypes } from 'notion-to-json/dist/types';\n\nexport async function getStaticProps() {\n  const page = await getPageSimple('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', {\n    api_key: 'secret_xxxxxxxxxxxx'\n  });\n\n  return {\n    props: {\n      page\n    }\n  };\n}\n\nconst Block = ({\n  block\n}: {\n  block: { type: string; contents: string | string[] };\n}) =\u003e {\n  const SimpleBlockTags = Object.freeze({\n    [SupportedBlockTypes.paragraph]: 'p',\n    [SupportedBlockTypes.heading_1]: 'h1',\n    [SupportedBlockTypes.heading_2]: 'h2',\n    [SupportedBlockTypes.heading_3]: 'h3',\n    [SupportedBlockTypes.quote]: 'blockquote',\n    [SupportedBlockTypes.callout]: 'div'\n  });\n\n  if (SimpleBlockTags[block.type]) {\n    const BlockTag = `${\n      SimpleBlockTags[block.type]\n    }` as keyof JSX.IntrinsicElements;\n\n    return (\n      \u003cBlockTag\n        dangerouslySetInnerHTML={{\n          __html: sanitizeHtml(\n            Array.isArray(block.contents)\n              ? block.contents.join('\\n')\n              : block.contents\n          )\n        }}\n      /\u003e\n    );\n  } else if (\n    block.type === SupportedBlockTypes.bulleted_list_item ||\n    block.type === SupportedBlockTypes.numbered_list_item\n  ) {\n    const BlockTag = `${\n      block.type === SupportedBlockTypes.numbered_list_item ? 'ol' : 'ul'\n    }` as keyof JSX.IntrinsicElements;\n\n    return (\n      \u003cBlockTag\u003e\n        {Array.isArray(block.contents) \u0026\u0026\n          block.contents.map((item, index) =\u003e (\n            \u003cli\n              key={index}\n              dangerouslySetInnerHTML={{\n                __html: sanitizeHtml(item)\n              }}\n            /\u003e\n          ))}\n      \u003c/BlockTag\u003e\n    );\n  } else if (block.type === SupportedBlockTypes.image) {\n    return \u003cimg src={block.contents as string} /\u003e;\n  }\n\n  return null;\n};\n\nconst NotionPage: NextPage\u003c{\n  page: {\n    title: string;\n    blocks: {\n      type: string;\n      contents: string | string[];\n    }[];\n  };\n}\u003e = ({ page }) =\u003e {\n  return (\n    \u003cdiv\u003e\n      \u003cHead\u003e\n        \u003ctitle\u003e{page.title}\u003c/title\u003e\n      \u003c/Head\u003e\n\n      \u003ch1\u003e{page.title}\u003c/h1\u003e\n\n      \u003c\u003e\n        {page.blocks.map((block, index) =\u003e {\n          return \u003cBlock block={block} key={index} /\u003e;\n        })}\n      \u003c/\u003e\n    \u003c/div\u003e\n  );\n};\n\nexport default NotionPage;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneogeek%2Fnotion-to-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneogeek%2Fnotion-to-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneogeek%2Fnotion-to-json/lists"}