Skip to main content

Notion

Load data from Notion

Configure via UI

Slack

Configure via API / Client

from llama_cloud.types import CloudNotionPageDataSource

ds = {
'name': '<your-name>',
'source_type': 'NOTION_PAGE',
'component': CloudNotionPageDataSource(
integration_token: '<integration_token>',
# Either 'database_ids' or 'page_ids' must be provided, one of them is required
database_ids: '<database_ids>',
page_ids: '<page_ids>',
)
}
data_source = client.data_sources.create_data_source(request=ds)


How to find Notion Database ID and Page ID?

Database ID:

  1. Extract database_id from Notion URLs.

  2. Open the Database: Navigate to the database in Notion.

  3. Example URL:

    https://www.notion.so/ba0824d2ef6947fea017a157d29ee999?v=d502a3bcd83e40ac91c2ceb522dc3dc6&p=41c6c8c1d99f482a879f6a86b9898213&pm=s
  4. Extract the Database ID: ba0824d2ef6947fea017a157d29ee999 can be found before the query string ?.

Page ID:

  1. Open the Page: Navigate to the specific page in Notion.

  2. Extract page_id from Notion URLs.

  3. Example URL:

    https://www.notion.so/ba0824d2ef6947fea017a157d29ee999?v=d502a3bcd83e40ac91c2ceb522dc3dc6&p=41c6c8c1d99f482a879f6a86b9898213&pm=s
  4. Extract the Page ID: 41c6c8c1d99f482a879f6a86b9898213 can be found after p=.

Retrieve Database ID

How to get Notion Integration Token?

To generate a Notion integration token, also known as a Notion API key or secret, you can follow these steps.

Prerequisites:

  1. A Notion account.
  2. To be a Workspace Owner in the workspace you’re using. You can create a new workspace for testing purposes otherwise.

Getting started

  1. Create your integration in Notion.

    1. Click + New integration.
    2. Enter the integration name and select the associated workspace for the new integration.
    3. Hit Save.
    4. Get your API secret (API requests require an API secret to be successfully authenticated.)
    5. Visit the Configuration tab to get your integration’s API secret (or “Internal Integration Secret”).

    Example Notion Integration Token:

    secret_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  2. Store the Integration Token Securely

    1. It’s crucial to store your token securely since it provides access to your Notion workspace. You can use environment variables, secret management services, or encrypted storage solutions.

Note: For your integration to interact with the page, it needs explicit permission to read/write to that specific Notion page.

  1. Give your integration page permissions

    1. Pick (or create) a Notion page.
    2. Click on the ... More menu in the top-right corner of the page.
    3. Scroll down to + Add Connections.
    4. Search for your integration and select it.
    5. Confirm the integration can access the page and all of its child pages.

This guide should help anyone generate and manage their Notion integration token for use with the Notion API.