---
ref: tool:notion/query-data-source
name: Query a data source
company: company:notion
workflows: []
access: [mcp, cli, api]
tags: [capability:manage-docs, category:docs, has:api, has:cli, has:mcp]
docs: https://developers.notion.com/reference/query-a-data-source
updated: 2026-09-27
---

# Query a data source

Returns the pages in a data source that match a filter, in the requested sort order.

`notion-query-data-sources` can also run SQL across data sources or run a saved view. SQL is unlimited on Business and Enterprise plans with Notion AI; on other plans, rows mode and single-data-source SQL share a per-workspace allowance.

## Set up

Use the first option your agent supports.

### MCP (official, remote)

Add this server to your agent's MCP settings, then sign in when asked.

```json
{ "mcpServers": { "notion": { "url": "https://mcp.notion.com/mcp" } } }
```

Call the MCP tool `notion-query-data-sources`.

Server URL: https://mcp.notion.com/mcp

### CLI (official)

Install the command, then confirm it runs.

```sh
npm install --global ntn
ntn --version
```

Run `ntn datasources query <data-source-id>`.

Set `$NOTION_API_TOKEN` in your environment first (get a key: https://www.notion.so/developers/tokens).

### API (official)

- Base URL: https://api.notion.com
- Endpoint: `POST /v1/data_sources/{data_source_id}/query`
- Auth: send the header `Authorization: Bearer $NOTION_API_KEY`
- Get a key: https://www.notion.so/developers/tokens
- Docs: https://developers.notion.com/reference/intro

Before doing anything else, make one read-only call to confirm access.

## Rules

- Ask the user before anything that sends messages, costs money, or changes data.
- Never print API keys.
