{"_id":"@billq/notion-client","name":"@billq/notion-client","dist-tags":{"latest":"6.16.1"},"versions":{"6.16.1":{"name":"@billq/notion-client","version":"6.16.1","type":"module","description":"Robust TypeScript client for the unofficial Notion API.","repository":{"type":"git","url":"git+https://github.com/NotionX/react-notion-x.git"},"author":{"name":"Travis Fischer","email":"travis@transitivebullsh.it"},"license":"MIT","main":"./build/index.js","module":"./build/index.js","types":"./build/index.d.ts","sideEffects":false,"engines":{"node":">=12"},"scripts":{"build":"tsup","watch":"tsup --watch --silent --onSuccess 'echo build successful'","test":"ava"},"dependencies":{"got":"^11.8.1","notion-types":"^6.16.0","notion-utils":"^6.16.0","p-map":"^5.3.0"},"ava":{"snapshotDir":".snapshots","extensions":{"ts":"module"},"nodeArguments":["--loader=ts-node/esm","--no-warnings","--experimental-specifier-resolution=node"]},"gitHead":"c428b0fb8210b44c99a6081e385f9c54a6b556f3","bugs":{"url":"https://github.com/NotionX/react-notion-x/issues"},"homepage":"https://github.com/NotionX/react-notion-x#readme","_id":"@billq/notion-client@6.16.1","_nodeVersion":"18.14.2","_npmVersion":"9.5.0","dist":{"integrity":"sha512-hbNb77QQC+vqJIUIkxbE3cG4D+qOyxkqbkvFcuvWe5l7aF53h6XkURlCnwb3UNa//JFz3Zm0dYuOGTtbKuHOUw==","shasum":"8a72491ac5d59f41c89e1a0289843eaeaca401c0","tarball":"https://registry.npmjs.org/@billq/notion-client/-/notion-client-6.16.1.tgz","fileCount":13,"unpackedSize":83847,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID1vQb/8MT4rdPlg3tgQfPNV6X+rPemEEiRMo75opMDoAiAoyepKaRrXlmmeHtfrFiUyQXV8tqu9XdsPdU0rV0KfqA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkGGZWACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpuCQ/+NpcGPz8tzoiwy/K8eN+vRZAH+c5J6nMw3IsRmMAfXQnmac1U\r\nbllI8DHnO/YOhOWSMOCecb9GKbQDKifDTnZupy4mo7ktQC4YuBSpzssvQrNR\r\nZRrkPw6ovqGilI5h1tW642HaaBq9SRFNdUfW02Om5hJDXH7xqDrxMEF5qKSV\r\n+l1VLUwgqYWMPnULrBDbwaEhaAty3Z15hghAofMQxoQzf+QMF+nveA/W471r\r\nb+bOhoRffYE1UoJgwsxme1HOes8ORZ+9+EfMfExjLtLm9WaOE/QhyI2tis9m\r\nE7oRXhErKFHVzLu4IvMzvTrZdvVRJ8TUx87S0c4L1FFepOVlbyAeuPBoNxsZ\r\nIHsneCJUKmhY+W3UejhWKEXBt406jIhVGlWwkX0ggvpcnGv9j1Kbrxyl0HYR\r\nu5E+Efye6AYscBGriwCUAKRHCRqMUzOpnyBbZvBI2pzoe40UEGHLC1N2X8Tk\r\nBL3IEfahF0+ZXuTT25fyxPNgDV0f+S3z3VjQATnbsWzbN/ZwtK9Kh28kk8T9\r\nuTxBxlqnqAXpUonWLQqamj3G8EGkbwGqRhgj7uUdo9HcI+lyp8cpNxUTXg7Y\r\nMtfhbqLljmsmuM4TLRyBfRQSusRKC/XMEy9q4O59MVBRNIg2YHhpIaurq7Le\r\nvkvtn8IsohhlYTQ9o+n5gm82tAlMfKiOuIs=\r\n=5IdC\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"bill_q","email":"fanglaiq@gmail.com"},"directories":{},"maintainers":[{"name":"bill_q","email":"fanglaiq@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/notion-client_6.16.1_1679320662513_0.6713320906702869"},"_hasShrinkwrap":false}},"time":{"created":"2023-03-20T13:57:42.454Z","6.16.1":"2023-03-20T13:57:42.689Z","modified":"2023-03-20T13:57:42.982Z"},"maintainers":[{"name":"bill_q","email":"fanglaiq@gmail.com"}],"description":"Robust TypeScript client for the unofficial Notion API.","homepage":"https://github.com/NotionX/react-notion-x#readme","repository":{"type":"git","url":"git+https://github.com/NotionX/react-notion-x.git"},"author":{"name":"Travis Fischer","email":"travis@transitivebullsh.it"},"bugs":{"url":"https://github.com/NotionX/react-notion-x/issues"},"license":"MIT","readme":"<p align=\"center\">\n  <img alt=\"React Notion X\" src=\"https://raw.githubusercontent.com/NotionX/react-notion-x/master/media/notion-ts.png\" width=\"689\">\n</p>\n\n# notion-client\n\n> Robust TypeScript client for the unofficial Notion API.\n\n[![NPM](https://img.shields.io/npm/v/notion-client.svg)](https://www.npmjs.com/package/notion-client) [![Build Status](https://github.com/NotionX/react-notion-x/actions/workflows/test.yml/badge.svg)](https://github.com/NotionX/react-notion-x/actions/workflows/test.yml) [![Prettier Code Formatting](https://img.shields.io/badge/code_style-prettier-brightgreen.svg)](https://prettier.io)\n\n## Install\n\n```bash\nnpm install notion-client\n```\n\nThis package is compatible with server-side V8 contexts such as Node.js, Deno, and Cloudflare Workers.\n\n## Usage\n\n```ts\nimport { NotionAPI } from 'notion-client'\n\n// you can optionally pass an authToken to access private notion resources\nconst api = new NotionAPI()\n\n// fetch a page's content, including all async blocks, collection queries, and signed urls\nconst page = await api.getPage('067dd719-a912-471e-a9a3-ac10710e7fdf')\n\n// fetch the data for a specific collection instance\nconst collectionId = '2d8aec23-8281-4a94-9090-caaf823dd21a'\nconst collectionViewId = 'ab639a5a-853e-45e1-9ef7-133b486c0acf'\nconst collectionData = await api.getCollectionData(\n  collectionId,\n  collectionViewId\n)\n```\n\n### Fetch a database's content\n\nYou can pass a database ID to the `getPage` method. The response is an object which contains several important properties:\n\n- `block`\n- `collection`\n- `collection_view`\n\nThe value of the `block` property maps the id of each block object present in the database to its corresponding properties like type, parent id, created time, last edited by, and more. \n\n```\n{\n  block: {\n    'cc368b47-772a-4a1a-a36e-1f52c507d20d': { role: 'reader', value: [Object] },\n    '97dbe6d5-aea3-4e03-b571-91810cf975d4': { role: 'reader', value: [Object] },\n    '08d5ba1e-03d2-4d4a-add7-a414f297ff8a': { role: 'reader', value: [Object] },\n    '7aad4627-c4af-4314-960e-1465e76cc6bd': { role: 'reader', value: [Object] },\n    '7be73360-19b9-4b77-a518-70acd610d492': { role: 'reader', value: [Object] },\n    'af961803-cd0c-470e-bd27-1d025baa2f95': { role: 'reader', value: [Object] },\n    // ...\n  }\n}\n```\n\nThe map of blocks is arranged as followed:\n\n- The first id is of the collection view\n- The second is of the parent page that contains the database in question\n- The next ids are of all the children pages inside the database\n- After that comes all the children blocks of each page.\n\n\nPlease note that a block object can take many types: header, text, list, media, and almost any block supported by Notion. It can also be *a page* or a *collection view*.\n\nExample of a block object of type `text`:\n\n```\n{\n  role: 'reader',\n  value: {\n    id: '0377e1a4-dc3d-4daf-99dd-f54f986d932e',\n    version: 1,\n    type: 'text',\n    properties: { title: [Array] },\n    format: { copied_from_pointer: [Object] },\n    created_time: 1655961814278,\n    last_edited_time: 1655961814278,\n    parent_id: '08d5ba1e-03d2-4d4a-add7-a414f297ff8a',\n    parent_table: 'block',\n    alive: true,\n    copied_from: '526d2008-0d0b-46f8-9de1-7411a85bff7b',\n    created_by_table: 'notion_user',\n    created_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',\n    last_edited_by_table: 'notion_user',\n    last_edited_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',\n    space_id: '6b70425f-211e-4318-80c6-5d093df8f7eb'\n  }\n}\n```\n\nExample of a block object of type `page`:\n\n```\n{\n  role: 'reader',\n  value: {\n    id: 'af961803-cd0c-470e-bd27-1d025baa2f95',\n    version: 31,\n    type: 'page',\n    properties: { '==~K': [Array], 'BN]P': [Array], title: [Array] },\n    content: [\n      '8cbf7053-da37-4d69-8cde-89343baf3623',\n      '0fc1712e-852c-4307-b72b-094dadaa86ba'\n    ],\n    created_time: 1655962200000,\n    last_edited_time: 1655979420000,\n    parent_id: '175482e5-870d-4da8-980c-ead469427316',\n    parent_table: 'collection',\n    alive: true,\n    created_by_table: 'notion_user',\n    created_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',\n    last_edited_by_table: 'notion_user',\n    last_edited_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',\n    space_id: '6b70425f-211e-4318-80c6-5d093df8f7eb'\n  }\n}\n```\n\nExample of a block object of type `collection_view`:\n```\n{\n  role: 'reader',\n  value: {\n    id: 'cc368b47-772a-4a1a-a36e-1f52c507d20d',\n    version: 5,\n    type: 'collection_view',\n    view_ids: [\n      '028f6968-2a6c-46da-bf43-cb44e6d91765',\n      '77f32047-52dd-422e-93fa-813438087e57'\n    ],\n    collection_id: '175482e5-870d-4da8-980c-ead469427316',\n    format: { collection_pointer: [Object], copied_from_pointer: [Object] },\n    created_time: 1655961814276,\n    last_edited_time: 1656075900000,\n    parent_id: '97dbe6d5-aea3-4e03-b571-91810cf975d4',\n    parent_table: 'block',\n    alive: true,\n    copied_from: '3e3073e9-7aee-481c-b831-765e112ec7b5',\n    created_by_table: 'notion_user',\n    created_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',\n    last_edited_by_table: 'notion_user',\n    last_edited_by_id: '55b29a2b-a8fe-4a11-9f9d-ada341bd922b',\n    space_id: '6b70425f-211e-4318-80c6-5d093df8f7eb'\n  }\n}\n```\n\n## Docs\n\nSee the [full docs](https://github.com/NotionX/react-notion-x).\n\n## License\n\nMIT © [Travis Fischer](https://transitivebullsh.it)\n\nSupport my OSS work by <a href=\"https://twitter.com/transitive_bs\">following me on twitter <img src=\"https://storage.googleapis.com/saasify-assets/twitter-logo.svg\" alt=\"twitter\" height=\"24px\" align=\"center\"></a>\n","readmeFilename":"readme.md"}