Query
query
¶
Provides an interactive query builder for Notion databases.
logger = logging.getLogger(__name__)
module-attribute
¶
CheckboxCondition
¶
CompoundFilter
¶
Represents a compound filter in Notion.
CreatedTimeFilter
¶
DBQuery
¶
Query object in Notion for querying a database
sorts: list[DBSort] | None = None
class-attribute
instance-attribute
¶
DBQueryBuilder(endpoint, db_id: str)
¶
Query builder to query a database.
Notion API: https://developers.notion.com/reference/post-search
DBSort
¶
DateCondition
¶
Represents date criteria in Notion.
after: date | datetime | None = None
class-attribute
instance-attribute
¶
before: date | datetime | None = None
class-attribute
instance-attribute
¶
equals: date | datetime | None = None
class-attribute
instance-attribute
¶
is_empty: bool | None = None
class-attribute
instance-attribute
¶
is_not_empty: bool | None = None
class-attribute
instance-attribute
¶
next_month: Any | None = None
class-attribute
instance-attribute
¶
next_week: Any | None = None
class-attribute
instance-attribute
¶
next_year: Any | None = None
class-attribute
instance-attribute
¶
on_or_after: date | datetime | None = None
class-attribute
instance-attribute
¶
on_or_before: date | datetime | None = None
class-attribute
instance-attribute
¶
past_month: Any | None = None
class-attribute
instance-attribute
¶
past_week: Any | None = None
class-attribute
instance-attribute
¶
past_year: Any | None = None
class-attribute
instance-attribute
¶
FilesCondition
¶
FormulaCondition
¶
Represents formula criteria in Notion.
LastEditedTimeFilter
¶
MultiSelectCondition
¶
Represents a multi_select criteria in Notion.
NumberCondition
¶
Represents number criteria in Notion.
does_not_equal: float | int | None = None
class-attribute
instance-attribute
¶
equals: float | int | None = None
class-attribute
instance-attribute
¶
greater_than: float | int | None = None
class-attribute
instance-attribute
¶
greater_than_or_equal_to: float | int | None = None
class-attribute
instance-attribute
¶
is_empty: bool | None = None
class-attribute
instance-attribute
¶
is_not_empty: bool | None = None
class-attribute
instance-attribute
¶
less_than: float | int | None = None
class-attribute
instance-attribute
¶
less_than_or_equal_to: float | int | None = None
class-attribute
instance-attribute
¶
PeopleCondition
¶
Represents people criteria in Notion.
PropertyFilter
¶
Represents a database property filter in Notion.
checkbox: CheckboxCondition | None = None
class-attribute
instance-attribute
¶
date: DateCondition | None = None
class-attribute
instance-attribute
¶
files: FilesCondition | None = None
class-attribute
instance-attribute
¶
formula: FormulaCondition | None = None
class-attribute
instance-attribute
¶
multi_select: MultiSelectCondition | None = None
class-attribute
instance-attribute
¶
number: NumberCondition | None = None
class-attribute
instance-attribute
¶
people: PeopleCondition | None = None
class-attribute
instance-attribute
¶
phone_number: TextCondition | None = None
class-attribute
instance-attribute
¶
property: str
instance-attribute
¶
relation: RelationCondition | None = None
class-attribute
instance-attribute
¶
rich_text: TextCondition | None = None
class-attribute
instance-attribute
¶
select: SelectCondition | None = None
class-attribute
instance-attribute
¶
Query
¶
Abstract query object in Notion for searching pages/databases and querying databases
filter: SerializeAsAny[QueryFilter] | None = None
class-attribute
instance-attribute
¶
page_size: int = MAX_PAGE_SIZE
class-attribute
instance-attribute
¶
start_cursor: UUID | None = None
class-attribute
instance-attribute
¶
valid_page_size(value: int) -> int
classmethod
¶
Validate that the given page size meets the Notion API requirements
QueryBuilder(endpoint: NCEndpoint, **params: str | None)
¶
General query builder for the Notion search & database query API
endpoint: NCEndpoint = endpoint
instance-attribute
¶
params: dict[str, str] = {param: valuefor (param, value) in params.items() if value is not None}
instance-attribute
¶
query: Query
instance-attribute
¶
execute()
¶
Execute the current query and return an iterator for the results.
first()
¶
Execute the current query and return the first result only.
limit(count: int)
¶
Limit the number of results to the given count.
start_at(cursor_id: UUID)
¶
Set the start cursor to a specific page ID.
QueryFilter
¶
Base class for query filters.
RelationCondition
¶
Represents relation criteria in Notion.
SearchFilter
¶
SearchQuery
¶
Query object in Notion for searching pages & databases
sort: SearchSort | None = None
class-attribute
instance-attribute
¶
SearchQueryBuilder(endpoint, text: str | None = None)
¶
Search query builder to search for pages and databases
By default and not changed by sort
, then the most recently edited results are returned first.
Notion API: https://developers.notion.com/reference/post-search
SearchSort
¶
SelectCondition
¶
Represents select criteria in Notion.
SortDirection
¶
TextCondition
¶
Represents text criteria in Notion.