Load Notion data to BigQuery
Build a Notion to BigQuery pipeline with your coding agent. One prompt scaffolds it with the dltHub AI harness, plus the Notion API base URL, auth, endpoints, and incremental loading.
Notion is a workspace content API for reading and managing pages, data sources, blocks, users, and related collaboration data. Everything needed to build a working Notion → BigQuery pipeline is on this page: the API's base URL, authentication, endpoints, pagination and incremental field — plus a prompt that hands the whole job to your coding agent.
Build your Notion to BigQuery pipeline
Paste this prompt into Claude, Codex, or Cursor. The agent does the rest.
uvx dlthub-init@latest to build a pipeline from Notion to BigQuery and run it on dltHubThat scaffolds a dltHub workspace and installs the dltHub AI harness — the project rules, the secrets-management skill, and the dlt MCP server your agent needs to work safely. From there it reads the Notion API, proposes the endpoints to load, then writes, runs and validates the pipeline while you review rather than type. Credentials are inspected through MCP tools, so your agent never reads secrets.toml itself. How the LLM-native workflow works →
Prefer to write it yourself? Every fact the agent uses is below.
Notion API at a glance
| Base URL | https://api.notion.com/v1 |
| Example endpoint | POST data_sources/{data_source_id}/query |
| Records found at | results |
| Authentication | all requests require a Bearer token and Notion-Version header — sent in the Authorization header, prefixed Bearer |
| Also required | Notion-Version |
| Pagination | Cursor-based via start_cursor, next cursor at next_cursor, page size via page_size (default 100, max 100). Notion uses cursor-based pagination for list responses. Send the returned next_cursor as start_cursor on the same endpoint; treat the cursor as opaque. For GET endpoints, start_cursor and page_size are query-string parameters; for POST endpoints, they are JSON body parameters. Continue while has_more is true. List responses contain results, has_more, and next_cursor (next_cursor is available only when has_more is true). The query-a-data-source endpoint additionally caps a single query at 10,000 results, after which pagination stops and the response is marked incomplete. |
| Incremental field | last_edited_time |
| Record id | id |
| API reference | https://developers.notion.com/reference/intro |
These values come from the Notion API reference — the authoritative source if anything here looks out of date.
How do I authenticate with the Notion API?
Send the credential in the Authorization header as Bearer {token} on every request, and include the required Notion-Version header on every REST API request. For requests with a JSON body, use Content-Type: application/json. Notion documents bearer tokens as tokens issued by an internal connection, personal access token, or OAuth flow; examples show token values such as secret_..., but the documentation does not define a universal token-format rule beyond using the bearer scheme.
1. Get your credentials
- Choose the credential type. For a single-workspace pipeline, create an internal connection; for a token acting as your own Notion user, create a personal access token (PAT). Public connections instead use OAuth 2.0. 2. For an internal connection, open the Notion Developer Portal, create or select the connection, then open its Configuration tab and copy the internal connection API token. Grant the connection access to the required pages/databases from the Content access tab or the page’s Add connections menu; new connections have no page access by default. 3. For a PAT, create it from the Notion integrations/developer portal flow and copy the generated token. 4. Store the token in a secret manager or environment variable; do not commit it to source control. 5. Send it on every REST request as Authorization: Bearer , include Notion-Version: 2026-03-11 (the current version shown in the documentation as of 2026-10-12), and use Content-Type: application/json for JSON requests. The REST base URL is https://api.notion.com/v1. 6. Validate credentials with GET https://api.notion.com/v1/users/me (or another permitted endpoint). For public OAuth connections, create the connection in the Developer Portal, obtain the authorization code through the configured redirect URI, then exchange it at POST https://api.notion.com/v1/oauth/token using HTTP Basic authentication with client ID and client secret; the returned access token is used as a bearer token.
2. Add them to .dlt/secrets.toml
[sources.notion_source] api_key = "your_notion_internal_connection_token_or_personal_access_token" notion_version = "2026-03-11"
dlt reads this file automatically at runtime. With the harness, the setup-secrets skill prompts you for the values and never handles the raw credential in chat. For production, see setting up credentials with dlt.
What Notion data can I load into BigQuery?
These are the Notion endpoints dlt can load into BigQuery:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| search | search | POST | results | Search shared pages and data sources; supports cursor pagination and sorting by last_edited_time. |
| users | users | GET | results | List workspace users with cursor pagination. |
| block_children | blocks/{block_id}/children | GET | results | List first-level child blocks of a page or block; cursor-paginated. |
| comments | comments | GET | results | List unresolved comments for a page or block; requires block_id; cursor-paginated. |
| page_property_items | pages/{page_id}/properties/{property_id} | GET | results | Retrieve a paginated page property, including title, rich_text, people, or relation values. |
| view_query_results | views/{view_id}/results | GET | results | Retrieve cached, paginated results from a previously created view query. |
| data_source_templates | data_sources/{data_source_id}/templates | GET | templates | List page templates belonging to a data source; response explicitly uses templates. |
| data_source_pages | data_sources/{data_source_id}/query | POST | results | Query pages/data sources with filters, sorts, and pagination; use a last_edited_time timestamp filter for incremental loading. |
| page | pages/{page_id} | GET | — | Retrieve one page, including its properties and last_edited_time. |
| block | blocks/{block_id} | GET | — | Retrieve one block. |
How do I load only new Notion records?
Notion exposes last_edited_time on data_sources/{data_source_id}/query, so dlt can request only the records that changed since the last run. Set it as the cursor_path and dlt tracks the high-water mark for you between runs.
{"name": "data_source_pages", "endpoint": { "path": "data_sources/{data_source_id}/query", "data_selector": "results", "incremental": {"cursor_path": "last_edited_time", "initial_value": "2024-01-01T00:00:00Z"}, }}
On the first run dlt loads everything from initial_value; on every run after that it requests only what changed and appends with write_disposition="merge" if you set a primary key. See incremental loading.
What does the generated Notion pipeline look like?
A standard dlt REST API pipeline — the same code you would write by hand, loading data_sources/{data_source_id}/query and pages/{page_id} from the Notion API into BigQuery:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def notion_source(api_key=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "https://api.notion.com/v1", "auth": {"type": "bearer", "token": api_key}, }, "resources": [ {"name": "data_source_pages", "endpoint": {"path": "data_sources/{data_source_id}/query", "data_selector": "results", "method": "POST"}}, {"name": "search", "endpoint": {"path": "search", "data_selector": "results", "method": "POST"}} ], } yield from rest_api_resources(config) def load_notion_to_bigquery() -> None: pipeline = dlt.pipeline( pipeline_name="notion_pipeline", destination="bigquery", dataset_name="notion_data", ) load_info = pipeline.run(notion_source()) print(load_info) if __name__ == "__main__": load_notion_to_bigquery()
Run it with uv run python notion_pipeline.py. The agent iterates on this until it loads cleanly — you review and approve, rather than write it from scratch.
How do I query Notion data in BigQuery?
dlt creates one table per resource. Query the loaded data with Python or SQL — or ask your agent to, through the MCP server's execute_sql_query tool.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("notion_pipeline").dataset() df = data.data_source_pages.df() print(df.head())
SQL:
SELECT * FROM notion_data.data_source_pages LIMIT 10;
See querying your data with dataset and exploring it in marimo notebooks.
How do I deploy the Notion to BigQuery pipeline in production?
The pipeline runs locally, which is ideal for prototyping and one-off analysis. When you need it on a schedule, monitored on every load, and shared with your team, deploy the same dlt code on the dltHub platform — no infrastructure to maintain. The prompt above already ends with "run it on dltHub", so your agent can take it there directly.
- Deploy & schedule — run the pipeline as a managed job with automatic retries.
- Monitor — observable job queues, alerting, and load metrics for every run.
- Transform — promote raw Notion loads into governed, documented models.
- Visualize & share — explore data in notebooks and publish live dashboards instead of static screenshots.
What other destinations can I load Notion data to?
dlt loads into any of these — only the destination argument changes:
| Destination | Example value |
|---|---|
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Set dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. On the dltHub platform the same pipeline runs against a managed Iceberg lakehouse. See the full destinations list.
Next steps
Was this page helpful?
Community Hub
Need more dlt context for Notion to BigQuery?
Request dlt skills, commands, AGENT.md files, and AI-native context.