ntn api to call the Notion API from your terminal. It adds the Authorization and Notion-Version headers. Log in with the CLI or set NOTION_API_TOKEN to the token you want to use.
Make a request
SetPAGE_ID to the ID of a page you can read. Pass its API path to ntn api. The leading slash is optional.
ntn api sends a GET request.
To create a child page, set PARENT_PAGE_ID to the ID of a page you can add content to. Pass the parent and title as body fields.
ntn api sends a POST request unless you override the method.
Use -X to choose the method. This request restores a page from the trash.
Build request data inline
Inline inputs after the path can set body fields, query parameters, and request headers.
Use
= when the value should be a string:
:= to send a number. This page must have a number property named Priority.
null:
Choose body syntax
For nested objects, use brackets or dots. Quote the whole argument when it contains brackets or spaces so your shell passes it as one field.[] to append repeated values in input order:
Build version, put the name in brackets.
Inline request syntax is inspired by HTTPie
and implemented in httpcliparser.
Send JSON from a file or stdin
Use inline inputs for small bodies. Use stdin or--data when the body is easier to write as JSON.
Send a JSON file:
--data, or inline body fields. You can still combine headers and query parameters with any one body source.
Add query parameters and headers
Use== for query parameters. This request lists up to 10 users.
Header:Value for request headers:
ntn api already sets Authorization and Notion-Version. You usually do
not need to pass those headers manually.Override the API version
By default,ntn api fetches the latest supported Notion-Version.
Use --notion-version for one request:
NOTION_API_VERSION for a shell session or script:
Inspect endpoints before calling them
List the public API surface:-X so ntn api knows which operation to inspect.
Debug a request
Run with--verbose to print request and response metadata to stderr:
Authorization request header is redacted by default.
Troubleshooting
Next steps
File uploads
Upload local files or import external files into Notion.
API reference
Browse Notion API endpoints and schemas.