> ## Documentation Index
> Fetch the complete documentation index at: https://docs.r28.ai/charter/llms.txt
> Use this file to discover all available pages before exploring further.

# data_sources_query

> Get the rows of a data source, optionally filtered and sorted. The filter grammar is one condition per column type, composed with `and` and `or` up to two levels deep. Read the schema first if you do not know the column names — a filter naming a column that is not there is a 400.

<div className="tool-route"><span className="tool-row-method" data-method="POST">POST</span><code>{"https://api.notion.com/v1/data_sources/{dataSourceId}/query"}</code></div>

```python notion_data_sources_query.py theme={null}
from charter.packs import notion

result = await notion.data_sources_query.ainvoke({"dataSourceId": ...})
```

<Note>
  Requires `Read content`. Pages by cursor: `next_cursor` is sent back as `body.start_cursor`.
</Note>

<Warning>
  This tool's JSON schema is 21 KB, because it models the whole resource this endpoint writes.
  That is more context than most tasks. Narrow it at the call site
  with [`Tool.derived`](/charter/charter/reference/tool#tool-derived):

  ```python theme={null}
  narrowed = notion.data_sources_query.derived(
      name="data_sources_query_narrowed",
      drop={"body.filter", "body.sorts"},
  )
  ```

  Those are its heaviest branches by schema size, not a recommendation: which ones you can spare is yours to decide. The tool underneath is unchanged.
  See [Projections](/charter/charter/tools/projections).
</Warning>

## Path parameters

<div className="reference-table">
  | Field                                                                | Type     | Description                |
  | -------------------------------------------------------------------- | -------- | -------------------------- |
  | `dataSourceId` <span className="required" title="required">\*</span> | `string` | The ID of the data source. |
</div>

## Query parameters

<div className="reference-table">
  | Field              | Type        | Description                                                                                                                                                                  |
  | ------------------ | ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
  | `filterProperties` | `string`\[] | Property IDs to return on each row, instead of all of them. The cheapest way to keep a wide table's query readable. <span className="field-constraints">max 100 items</span> |
</div>

## Body

<div className="reference-table">
  | Field  | Type                                                                                  | Description                                        |
  | ------ | ------------------------------------------------------------------------------------- | -------------------------------------------------- |
  | `body` | [DataSourceQueryBody](/charter/charter/packs/notion/data_sources/objects#datasourcequerybody) | The filter, sort and paging options. All optional. |
</div>
