Start building with the Notion API (original) (raw)

Introduction

The reference is your key to a comprehensive understanding of the Notion API.

Integrations use the API to access Notion's pages, databases, and users. Integrations can connect services to Notion and build interactive experiences for users within Notion. Using the navigation on the left, you'll find details for objects and endpoints used in the API.

📘

You need an integration token to interact with the Notion API. You can find an integration token after you create an integration on the integration settings page. If this is your first look at the Notion API, we recommend beginning with the Getting started guide to learn how to create an integration.

If you want to work on a specific integration, but can't access the token, confirm that you are an admin in the associated workspace. You can check inside the Notion UI via Settings & Members in the left sidebar. If you're not an admin in any of your workspaces, you can create a personal workspace for free.

The base URL to send all API requests is https://api.notion.com. HTTPS is required for all API requests.

The Notion API follows RESTful conventions when possible, with most operations performed via GET, POST, PATCH, and DELETE requests on page and database resources. Request and response bodies are encoded as JSON.

Samples requests and responses are shown for each endpoint. Requests are shown using the Notion JavaScript SDK, and cURL. These samples make it easy to copy, paste, and modify as you build your integration.

Notion SDKs are open source projects that you can install to easily start building. You may also choose any other language or library that allows you to make HTTP requests.

Endpoints that return lists of objects support cursor-based pagination requests. By default, Notion returns ten items per API call. If the number of items in a response from a support endpoint exceeds the default, then an integration can use pagination to request a specific set of the results and/or to limit the number of returned items.

If an endpoint supports pagination, then the response object contains the below fields.

Field Type Description
has_more boolean Whether the response includes the end of the list. false if there are no more results. Otherwise, true.
next_cursor string A string that can be used to retrieve the next page of results by passing the value as the start_cursor parameter to the same endpoint.Only available when has_more is true.
object "list" The constant string "list".
results array of objects The list, or partial list, of endpoint-specific results. Refer to a supported endpoint's individual documentation for details.
type "block""comment""database""page""page_or_database""property_item""user" A constant string that represents the type of the objects in results.
{type} paginated list object An object containing type-specific pagination information. For property_items, the value corresponds to the paginated page property type. For all other types, the value is an empty object.

🚧

Parameter location varies by endpoint

GET requests accept parameters in the query string.

POST requests receive parameters in the request body.

Parameter Type Description
page_size number The number of items from the full list to include in the response.Default: 100Maximum: 100The response may contain fewer than the default number of results.
start_cursor string A next_cursor value returned in a previous response. Treat this as an opaque value.Defaults to undefined, which returns results from the beginning of the list.
  1. Send an initial request to the supported endpoint.
  2. Retrieve the next_cursor value from the response (only available when has_more is true).
  3. Send a follow up request to the endpoint that includes the next_cursor param in either the query string (for GET requests) or in the body params (POST requests).
curl --location --request POST 'https://api.notion.com/v1/databases/<database_id>/query' \
--header 'Authorization: Bearer <secret_bot>' \
--header 'Content-Type: application/json' \
--data '{
    "start_cursor": "33e19cb9-751f-4993-b74d-234d67d0d534"
}'