Movatterモバイル変換


[0]ホーム

URL:


Filter database entries

❗️

Deprecated as of version 2025-09-03

This page describes the API for versions up to and including2022-06-28. In the new2025-09-03 version, the concepts of databases and data sources were split up, as described inUpgrading to 2025-09-03.

Refer to the new page instead:

When youquery a database, you can send afilter object in the body of the request that limits the returned entries based on the specified criteria.

For example, the below query limits the response to entries where the"Task completed"checkbox property value istrue:

curl -X POST 'https://api.notion.com/v1/databases/897e5a76ae524b489fdfe71f5945d1af/query' \  -H 'Authorization: Bearer '"$NOTION_API_KEY"'' \  -H 'Notion-Version: 2022-06-28' \  -H "Content-Type: application/json" \--data '{  "filter": {    "property": "Task completed",    "checkbox": {        "equals": true   }  }}'

Here is the same query using theNotion SDK for JavaScript:

const { Client } = require('@notionhq/client');const notion = new Client({ auth: process.env.NOTION_API_KEY });// replace with your own database IDconst databaseId = 'd9824bdc-8445-4327-be8b-5b47500af6ce';const filteredRows = async () => {const response = await notion.databases.query({  database_id: databaseId,  filter: {    property: "Task completed",    checkbox: {      equals: true    }  },});  return response;}

Filters can be chained with theand andor keys so that multiple filters are applied at the same time. (SeeQuery a database for additional examples.)

{  "and": [    {      "property": "Done",      "checkbox": {        "equals": true      }    },     {      "or": [        {          "property": "Tags",          "contains": "A"        },        {          "property": "Tags",          "contains": "B"        }      ]    }  ]}

If no filter is provided, all the pages in the database will be returned with pagination.

The filter object

Eachfilter object contains the following fields:

FieldTypeDescriptionExample value
propertystringThe name of the property as it appears in the database, or the property ID."Task completed"
checkbox
date
files
formula
multi_select
number
people
phone_number
relation
rich_text
select
status
timestamp
verification
ID
objectThe type-specific filter condition for the query. Only types listed in the Field column of this table are supported.

Refer totype-specific filter conditions for details on corresponding object values.
"checkbox": { "equals": true }
{  "filter": {    "property": "Task completed",    "checkbox": {      "equals": true    }  }}

👍

The filter object mimics the databasefilter option in the Notion UI.

Type-specific filter conditions

Checkbox

FieldTypeDescriptionExample value
equalsbooleanWhether acheckbox property value matches the provided value exactly.

Returns or excludes all database entries with an exact value match.
false
does_not_equalbooleanWhether acheckbox property value differs from the provided value.

Returns or excludes all database entries with a difference in values.
true
{  "filter": {    "property": "Task completed",    "checkbox": {      "does_not_equal": true    }  }}

Date

📘

For theafter,before,equals, on_or_before, andon_or_after fields, if a date string with a time is provided, then the comparison is done with millisecond precision.

If no timezone is provided, then the timezone defaults to UTC.

A date filter condition can be used to limitdate property value types and thetimestamp property typescreated_time andlast_edited_time.

The condition contains the below fields:

FieldTypeDescriptionExample value
afterstring (ISO 8601 date)The value to compare the date property value against.

Returns database entries where the date property value is after the provided date.
"2021-05-10"

"2021-05-10T12:00:00"

"2021-10-15T12:00:00-07:00"
beforestring (ISO 8601 date)The value to compare the date property value against.

Returns database entries where the date property value is before the provided date.
"2021-05-10"

"2021-05-10T12:00:00"

"2021-10-15T12:00:00-07:00"
equalsstring (ISO 8601 date)The value to compare the date property value against.

Returns database entries where the date property value is the provided date.
"2021-05-10"

"2021-05-10T12:00:00"

"2021-10-15T12:00:00-07:00"
is_emptytrueThe value to compare the date property value against.

Returns database entries where the date property value contains no data.
true
is_not_emptytrueThe value to compare the date property value against.

Returns database entries where the date property value is not empty.
true
next_monthobject (empty)A filter that limits the results to database entries where the date property value is within the next month.{}
next_weekobject (empty)A filter that limits the results to database entries where the date property value is within the next week.{}
next_yearobject (empty)A filter that limits the results to database entries where the date property value is within the next year.{}
on_or_afterstring (ISO 8601 date)The value to compare the date property value against.

Returns database entries where the date property value is on or after the provided date.
"2021-05-10"

"2021-05-10T12:00:00"

"2021-10-15T12:00:00-07:00"
on_or_beforestring (ISO 8601 date)The value to compare the date property value against.

Returns database entries where the date property value is on or before the provided date.
"2021-05-10"

"2021-05-10T12:00:00"

"2021-10-15T12:00:00-07:00"
past_monthobject (empty)A filter that limits the results to database entries where thedate property value is within the past month.{}
past_weekobject (empty)A filter that limits the results to database entries where thedate property value is within the past week.{}
past_yearobject (empty)A filter that limits the results to database entries where thedate property value is within the past year.{}
this_weekobject (empty)A filter that limits the results to database entries where thedate property value is this week.{}
{  "filter": {    "property": "Due date",    "date": {      "on_or_after": "2023-02-08"    }  }}

Files

FieldTypeDescriptionExample value
is_emptytrueWhether the files property value does not contain any data.

Returns all database entries with an emptyfiles property value.
true
is_not_emptytrueWhether thefiles property value contains data.

Returns all entries with a populatedfiles property value.
true
{  "filter": {    "property": "Blueprint",    "files": {      "is_not_empty": true    }  }}

Formula

The primary field of theformula filter condition object matches the type of the formula’s result. For example, to filter a formula property that computes acheckbox, use aformula filter condition object with acheckbox field containing a checkbox filter condition as its value.

FieldTypeDescriptionExample value
checkboxobjectAcheckbox filter condition to compare the formula result against.

Returns database entries where the formula result matches the provided condition.
Refer to thecheckbox filter condition.
dateobjectAdate filter condition to compare the formula result against.

Returns database entries where the formula result matches the provided condition.
Refer to thedate filter condition.
numberobjectAnumber filter condition to compare the formula result against.

Returns database entries where the formula result matches the provided condition.
Refer to thenumber filter condition.
stringobjectArich text filter condition to compare the formula result against.

Returns database entries where the formula result matches the provided condition.
Refer to therich text filter condition.
{  "filter": {    "property": "One month deadline",    "formula": {      "date":{          "after": "2021-05-10"      }    }  }}

Multi-select

FieldTypeDescriptionExample value
containsstringThe value to compare the multi-select property value against.

Returns database entries where the multi-select value matches the provided string.
"Marketing"
does_not_containstringThe value to compare the multi-select property value against.

Returns database entries where the multi-select value does not match the provided string.
"Engineering"
is_emptytrueWhether the multi-select property value is empty.

Returns database entries where the multi-select value does not contain any data.
true
is_not_emptytrueWhether the multi-select property value is not empty.

Returns database entries where the multi-select value does contains data.
true
{  "filter": {    "property": "Programming language",    "multi_select": {      "contains": "TypeScript"    }  }}

Number

FieldTypeDescriptionExample value
does_not_equalnumberThenumber to compare the number property value against.

Returns database entries where the number property value differs from the providednumber.
42
equalsnumberThenumber to compare the number property value against.

Returns database entries where the number property value is the same as the provided number.
42
greater_thannumberThenumber to compare the number property value against.

Returns database entries where the number property value exceeds the providednumber.
42
greater_than_or_equal_tonumberThenumber to compare the number property value against.

Returns database entries where the number property value is equal to or exceeds the providednumber.
42
is_emptytrueWhether thenumber property value is empty.

Returns database entries where the number property value does not contain any data.
true
is_not_emptytrueWhether the number property value is not empty.

Returns database entries where the number property value contains data.
true
less_thannumberThenumber to compare the number property value against.

Returns database entries where the number property value is less than the providednumber.
42
less_than_or_equal_tonumberThenumber to compare the number property value against.

Returns database entries where the number property value is equal to or is less than the providednumber.
42
{  "filter": {    "property": "Estimated working days",    "number": {      "less_than_or_equal_to": 5    }  }}

People

You can apply a people filter condition topeople,created_by, andlast_edited_by database property types.

The people filter condition contains the following fields:

FieldTypeDescriptionExample value
containsstring (UUIDv4)The value to compare the people property value against.

Returns database entries where the people property value contains the providedstring.
"6c574cee-ca68-41c8-86e0-1b9e992689fb"
does_not_containstring (UUIDv4)The value to compare the people property value against.

Returns database entries where the people property value does not contain the providedstring.
"6c574cee-ca68-41c8-86e0-1b9e992689fb"
is_emptytrueWhether the people property value does not contain any data.

Returns database entries where the people property value does not contain any data.
true
is_not_emptytrueWhether the people property value contains data.

Returns database entries where the people property value is not empty.
true
{  "filter": {    "property": "Last edited by",    "people": {      "contains": "c2f20311-9e54-4d11-8c79-7398424ae41e"    }  }}

Relation

FieldTypeDescriptionExample value
containsstring (UUIDv4)The value to compare the relation property value against.

Returns database entries where the relation property value contains the providedstring.
"6c574cee-ca68-41c8-86e0-1b9e992689fb"
does_not_containstring (UUIDv4)The value to compare the relation property value against.

Returns entries where the relation property value does not contain the providedstring.
"6c574cee-ca68-41c8-86e0-1b9e992689fb"
is_emptytrueWhether the relation property value does not contain data.

Returns database entries where the relation property value does not contain any data.
true
is_not_emptytrueWhether the relation property value contains data.

Returns database entries where the property value is not empty.
true
{  "filter": {    "property": "✔️ Task List",    "relation": {      "contains": "0c1f7cb280904f18924ed92965055e32"    }  }}

Rich text

FieldTypeDescriptionExample value
containsstringThestring to compare the text property value against.

Returns database entries with a text property value that includes the providedstring.
"Moved to Q2"
does_not_containstringThestring to compare the text property value against.

Returns database entries with a text property value that does not include the providedstring.
"Moved to Q2"
does_not_equalstringThestring to compare the text property value against.

Returns database entries with a text property value that does not match the providedstring.
"Moved to Q2"
ends_withstringThestring to compare the text property value against.

Returns database entries with a text property value that ends with the providedstring.
"Q2"
equalsstringThestring to compare the text property value against.

Returns database entries with a text property value that matches the providedstring.
"Moved to Q2"
is_emptytrueWhether the text property value does not contain any data.

Returns database entries with a text property value that is empty.
true
is_not_emptytrueWhether the text property value contains any data.

Returns database entries with a text property value that contains data.
true
starts_withstringThestring to compare the text property value against.

Returns database entries with a text property value that starts with the providedstring.
"Moved"
{  "filter": {    "property": "Description",    "rich_text": {      "contains": "cross-team"    }  }}

Rollup

A rollup database property can evaluate to an array, date, or number value. The filter condition for the rollup property contains arollup key and a corresponding object value that depends on the computed value type.

Filter conditions forarray rollup values

FieldTypeDescriptionExample value
anyobjectThe value to compare each rollup property value against. Can be afilter condition for any other type.

Returns database entries where the rollup property value matches the provided criteria.
"rich_text": { "contains": "Take Fig on a walk" }
everyobjectThe value to compare each rollup property value against. Can be afilter condition for any other type.

Returns database entries where every rollup property value matches the provided criteria.
"rich_text": { "contains": "Take Fig on a walk" }
noneobjectThe value to compare each rollup property value against. Can be afilter condition for any other type.

Returns database entries where no rollup property value matches the provided criteria.
"rich_text": { "contains": "Take Fig on a walk" }
{  "filter": {    "property": "Related tasks",    "rollup": {      "any": {        "rich_text": {          "contains": "Migrate database"        }      }    }  }}

Filter conditions fordate rollup values

A rollup value is stored as adate only if the "Earliest date", "Latest date", or "Date range" computation is selected for the property in the Notion UI.

FieldTypeDescriptionExample value
dateobjectAdate filter condition to compare the rollup value against.

Returns database entries where the rollup value matches the provided condition.
Refer to thedate filter condition.
{  "filter": {    "property": "Parent project due date",    "rollup": {      "date": {        "on_or_before": "2023-02-08"      }    }  }}

Filter conditions fornumber rollup values

FieldTypeDescriptionExample value
numberobjectAnumber filter condition to compare the rollup value against.

Returns database entries where the rollup value matches the provided condition.
Refer to thenumber filter condition.
{  "filter": {    "property": "Total estimated working days",    "rollup": {      "number": {        "does_not_equal": 42      }    }  }}

Select

FieldTypeDescriptionExample value
equalsstringThestring to compare the select property value against.

Returns database entries where the select property value matches the provided string.
"This week"
does_not_equalstringThestring to compare the select property value against.

Returns database entries where the select property value does not match the providedstring.
"Backlog"
is_emptytrueWhether the select property value does not contain data.

Returns database entries where the select property value is empty.
true
is_not_emptytrueWhether the select property value contains data.

Returns database entries where the select property value is not empty.
true
{  "filter": {    "property": "Frontend framework",    "select": {      "equals": "React"    }  }}

Status

FieldTypeDescriptionExample value
equalsstringThe string to compare the status property value against.

Returns database entries where the status property value matches the provided string.
"This week"
does_not_equalstringThe string to compare the status property value against.

Returns database entries where the status property value does not match the provided string.
"Backlog"
is_emptytrueWhether the status property value does not contain data.

Returns database entries where the status property value is empty.
true
is_not_emptytrueWhether the status property value contains data.

Returns database entries where the status property value is not empty.
true
{  "filter": {    "property": "Project status",    "status": {      "equals": "Not started"    }  }}

Timestamp

Use a timestamp filter condition to filter results based oncreated_time orlast_edited_time values.

FieldTypeDescriptionExample value
timestampcreated_time last_edited_timeA constant string representing the type of timestamp to use as a filter."created_time"
created_time
last_edited_time
objectA date filter condition used to filter the specified timestamp.Refer to thedate filter condition.
{  "filter": {    "timestamp": "created_time",    "created_time": {      "on_or_before": "2022-10-13"    }  }}

🚧

Thetimestamp filter condition does not require a property name. The API throws an error if you provide one.

Verification

FieldTypeDescriptionExample value
statusstringThe verification status being queried. Valid options are:verified,expired,none

Returns database entries where the current verification status matches the queried status.
"verified"
{  "filter": {    "property": "verification",    "verification": {      "status": "verified"    }  }}

ID

Use a timestamp filter condition to filter results based on theunique_id value.

FieldTypeDescriptionExample value
does_not_equalnumberThe value to compare the unique_id property value against.

Returns database entries where the unique_id property value differs from the provided value.
42
equalsnumberThe value to compare the unique_id property value against.

Returns database entries where the unique_id property value is the same as the provided value.
42
greater_thannumberThe value to compare the unique_id property value against.

Returns database entries where the unique_id property value exceeds the provided value.
42
greater_than_or_equal_tonumberThe value to compare the unique_id property value against.

Returns database entries where the unique_id property value is equal to or exceeds the provided value.
42
less_thannumberThe value to compare the unique_id property value against.

Returns database entries where the unique_id property value is less than the provided value.
42
less_than_or_equal_tonumberThe value to compare the unique_id property value against.

Returns database entries where the unique_id property value is equal to or is less than the provided value.
42
{  "filter": {    "and": [      {        "property": "ID",        "unique_id": {          "greater_than": 1        }      },      {        "property": "ID",        "unique_id": {          "less_than": 3        }      }    ]  }}

Compound filter conditions

You can use a compound filter condition to limit the results of a database query based on multiple conditions. This mimics filter chaining in the Notion UI.

1340

An example filter chain in the Notion UI

The above filters in the Notion UI are equivalent to the following compound filter condition via the API:

{  "and": [    {      "property": "Done",      "checkbox": {        "equals": true      }    },     {      "or": [        {          "property": "Tags",          "contains": "A"        },        {          "property": "Tags",          "contains": "B"        }      ]    }  ]}

A compound filter condition contains anand oror key with a value that is an array of filter objects or nested compound filter objects. Nesting is supported up to two levels deep.

FieldTypeDescriptionExample value
andarrayAn array offilter objects or compound filter conditions.

Returns database entries that matchall of the provided filter conditions.
Refer to the examples below.
orarrayAn array offilter objects or compound filter conditions.

Returns database entries that matchany of the provided filter conditions
Refer to the examples below.

Example compound filter conditions

{  "filter": {    "and": [      {        "property": "Complete",        "checkbox": {          "equals": true        }      },      {        "property": "Working days",        "number": {          "greater_than": 10        }      }    ]  }}
{  "filter": {    "or": [      {        "property": "Description",        "rich_text": {          "contains": "2023"        }      },      {        "and": [          {            "property": "Department",            "select": {              "equals": "Engineering"            }          },          {            "property": "Priority goal",            "checkbox": {              "equals": true            }          }        ]      }    ]  }}

[8]ページ先頭

©2009-2025 Movatter.jp