Skip to main content
A data source is a table of pages under a Notion database. For background on how databases and data sources fit together, see Working with databases. All examples below assume you’ve already authenticated with ntn login. To work with data sources, you use a combo of ntn datasources and ntn api commands.

Find a data source ID

Data sources live under a database. Retrieve the parent database to list its data sources. See Working with databases for how to find a database ID from a Notion URL:
Each item in the response’s data_sources array contains an id. To get the ID from the Notion app: open the database’s settings menu, choose Manage data sources, click the data source’s ••• menu, and click Copy data source ID.

Retrieve a data source

Fetch the schema (properties, title, parent) for a single data source. See Retrieve a data source for the response shape:

Create a data source

Add a new data source to an existing database. parent[type]=database_id is the type discriminator; parent[database_id] is the database’s unique ID. properties is a map of column name to property schema. See Create a data source for every supported field:
A default “table” view is created alongside the data source. See Working with views to learn about managing views.

Query a data source

Use ntn datasources query to list pages in a data source:
Pass --filter with the same shape documented in Filter data source entries:
Paginate with --start-cursor using the next_cursor from the previous response. Add --json for machine-readable output. For sorts, filter_properties, or other options, drop down to ntn api. See Query a data source for the full request and response:
To speed up large queries, restrict the columns returned with the filter_properties query param (it accepts property IDs or names):
Paginate by passing start_cursor from the previous response’s next_cursor until has_more is false. Query results cap at 10,000 pages. For larger data sources, narrow with filters or subscribe to webhooks.

Update a data source

PATCH updates the title, description, parent, or schema. To add a column, pass it under properties keyed by name:
To rename or remove a property, key it by its existing name and pass either a new name or null:
See Update a data source for the full list of editable fields and properties that can’t be changed via the API.

List page templates

List the page templates that show up in a data source’s New dropdown. See List data source templates for the response shape:
Templates are regular Notion pages. Fetch full content with Retrieve a page:

Discover the endpoints

To see the request schema or jump to the docs for any of these commands: