{"id":13607449,"url":"https://github.com/cstrnt/notion-api","last_synced_at":"2025-10-03T20:44:26.356Z","repository":{"id":34288702,"uuid":"174422149","full_name":"cstrnt/notion-api","owner":"cstrnt","description":"Unofficial Notion.so API","archived":false,"fork":false,"pushed_at":"2022-06-24T22:23:21.000Z","size":241,"stargazers_count":278,"open_issues_count":8,"forks_count":28,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-09-23T08:51:47.283Z","etag":null,"topics":["api-client","api-wrapper","nodejs","notion"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/notion-api-js","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cstrnt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-07T21:21:49.000Z","updated_at":"2025-08-27T13:21:34.000Z","dependencies_parsed_at":"2022-07-17T09:30:31.272Z","dependency_job_id":null,"html_url":"https://github.com/cstrnt/notion-api","commit_stats":null,"previous_names":["frexeptabel/notion-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cstrnt/notion-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrnt%2Fnotion-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrnt%2Fnotion-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrnt%2Fnotion-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrnt%2Fnotion-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cstrnt","download_url":"https://codeload.github.com/cstrnt/notion-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cstrnt%2Fnotion-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277025203,"owners_count":25747189,"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","status":"online","status_checked_at":"2025-09-26T02:00:09.010Z","response_time":78,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["api-client","api-wrapper","nodejs","notion"],"created_at":"2024-08-01T19:01:18.710Z","updated_at":"2025-10-03T20:44:26.327Z","avatar_url":"https://github.com/cstrnt.png","language":"TypeScript","readme":"# Unofficial Notion.so API Wrapper (WIP)\n\n![npm](https://img.shields.io/npm/v/notion-api-js.svg)\n![npm bundle size](https://img.shields.io/bundlephobia/min/notion-api-js.svg)\n\nThis repository contains an unofficial port of the [Notion](https://notion.so) API to Node.js. **Important**: It only works in the backend using Node.js and not in a client-side environment.\n\n**IMPORTANT**: You need a token to use the Notion API. You can obtain one by reading your local cookie. You can find instructions for that below.\n\n# Documentation\n\n- [Installation](#Installation)\n- [Dependencies](#Dependencies)\n- [Usage](#Usage)\n- [Obtaining Credentials](#Obtaining-Credentials)\n- [Instance Methods](#Instance-Methods)\n- [Disclaimer](#Disclaimer)\n\n# Installation\n\nYou can either use `npm ` or `yarn ` to install it:\n\n```\nnpm i --save notion-api-js\n```\n\n```\nyarn add notion-api-js\n```\n\n# Usage\n\n## Creating an instance\n\nTo create an instance, simply pass an object with the token you read from the cookie:\n\n```js\n// ES Modules syntax\nimport Notion from \"notion-api-js\";\n\n// require syntax\nconst Notion = require(\"notion-api-js\").default;\n\nconst notion = new Notion({\n  token: \"YOUR_TOKEN_V2\"\n});\n```\n\nYou can also provide options for the HTML parsing:\n\n```js\nconst notion = new Notion({\n  token: \"YOUR_TOKEN_V2\",\n  options: {\n    colors: {\n      orange: 'CSS COLOR HERE'\n    },\n    pageUrl: 'ABSOLUTE PAGE URL (e.g. /posts/'),\n  }\n});\n```\n\n# Obtaining Credentials\n\nRight now there is no official way of accessing the Notion API but there is a little work-around to get your credentials.\n\n## Prerequisites\n\nYou need to have an account on [Notion.so](https://notion.so/) and need to be logged in.\n\n## Getting your credentials\n\nMost of the modern web browsers support inspecting cookies visually using the browser's devtools.\nYou can read how to do it in your browser here:\n\n- [Chrome](https://developers.google.com/web/tools/chrome-devtools/manage-data/cookies)\n- [Firefox](https://developer.mozilla.org/en-US/docs/Tools/Storage_Inspector)\n\nAfter you found the Notion.so cookie, look for an entry called `token_v2`. It is the necessary credential for the `Notion` instance. Simply copy it into your code when you create the instance.\n\n# Instance Options\n\nThe options are optionally passed to the instance as a parameter. Those options contain information on how the HTML will be parsed and returned using the instance methods.\n\n### Colors (Object)\n\nContains definitions for the colors. If this option is omitted the default HTML colors like orange, pink and blue are used. You can change this behavior by passing an object containing color definitions. Example:\n\n```js\noptions: {\n    colors: {\n      red: 'tomato',\n      blue: 'rgb(100, 149, 237)',\n      purple: '#9933cc',\n    }\n}\n```\n\nPossible colors are:\n\n- red\n- brown\n- orange\n- yellow\n- teal\n- blue\n- purple\n- pink\n\n### PageUrl (String)\n\nThe PageUrl is the string passed to the `\u003ca\u003e` tag and is used to build the href of it. The id is inserted after the passed string.\nBy default it looks like this `/page?id=`, which results in `\u003ca href=\"/page?id=SOME_ID\"\u003eHello World\u003c/a\u003e`\n\n# Instance Methods\n\n- [getPages](\u003c#getPages()\u003e)\n- [getPageById](\u003c#getPageById(pageId)\u003e)\n- [getPagesByIndexId](\u003c#getPagesByIndexId(pageId)\u003e)\n- [getAllHTML](\u003c#getAllHTML()\u003e)\n\n## getPages()\n\nGets all pages of the user by the userId passed to the `Notion ` instance. All pages are parsed to HTML.\n\n**Example**\n\n```js\nnotion.getPages().then(pages =\u003e {\n  // Your Code here\n});\n```\n\n## getPageById(pageId)\n\nGets a Notion page by the pageId and returns the parsed HTML.\n\n**Parameters**:\n\n| **Parameter** | **Type** | **Opt/Required** |\n| ------------- | -------- | ---------------- |\n| pageId        | string   | Required         |\n\n**Example**\n\n```js\nnotion.getPageById(\"pageId\").then(page =\u003e {\n  // Your code here\n});\n```\n\n## getPagesByIndexId(pageId)\n\nGets a Notion page by the given pageId and all subpages of that page. Useful if you want to use a homepage.\n\n**Parameters**:\n\n| **Parameter** | **Type** | **Opt/Required** |\n| ------------- | -------- | ---------------- |\n| pageId        | string   | Required         |\n\n**Example**\n\n```js\nnotion.getPagesByIndexId(\"pageId\").then(page =\u003e {\n  // Your code here\n});\n```\n\n## getAllHTML() [WIP]\n\nGets the HTML for all pages.\n\n```js\nnotion.getAllHTML().then(html =\u003e {\n  // Your Ccode here\n});\n```\n\n# Disclaimer\n\nIt's really WIP right now but I would highly appreciate if you would like to contribute to the project. Just fork this repository and create a PR 😄\n","funding_links":[],"categories":["TypeScript","APIs"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcstrnt%2Fnotion-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcstrnt%2Fnotion-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcstrnt%2Fnotion-api/lists"}