Skip to main content

Overview

In the Notion SDK, databases are containers that hold one or more data sources. To query the contents of a database, you need to query its data sources using notion.dataSources.query().
The databases namespace does not have a query method. Instead, use notion.dataSources.query() to retrieve pages and data from within a database.

Getting Data Source IDs

First, retrieve the database to get its data source IDs:

Querying a Data Source

Once you have a data source ID, query it using notion.dataSources.query():

Filtering Examples

Filter by text property

Filter by select property

Filter by multi-select property

Filter by date property

Filter by checkbox property

Filter by number property

Compound filters with AND

Compound filters with OR

Filter by created time

Sorting Examples

Sort by property ascending

Sort by property descending

Sort by timestamp

Multiple sorts

Pagination

Manual pagination

Using pagination helpers

Complete Example

Additional Options

Filter properties

Limit which properties are returned in the response:

Include/exclude archived pages

Include/exclude trashed pages

Filter by result type

For more details on data source querying, see the Data Sources Query reference.