notion-py-client
A type-safe Python client library for the Notion API, built with Pydantic v2.
Features
- Type-Safe: Complete type definitions using Pydantic v2
- Async-First: Built on httpx for async/await support
- API 2026-03-11: Latest Notion API with
position,in_trash, andmeeting_notes - Comprehensive: All blocks, properties, filters, and request types
- Domain Mapping: Built-in mapper for converting to domain models
Installation
pip install notion-py-client
Quick Start
import asyncio
from notion_py_client import NotionAsyncClient
async def main():
client = NotionAsyncClient(auth="your_NOTION_API_TOKEN")
# Query a data source (API 2026-03-11)
response = await client.dataSources.query(
data_source_id="your_data_source_id"
)
for page in response.results:
print(page.id, page.properties)
asyncio.run(main())
Notion API 2026-03-11
This library supports the latest Notion API version 2026-03-11, including:
- Current breaking changes:
position,in_trash, andmeeting_notes - Markdown APIs: create, read, and update page content as markdown
- Comments: create/update comments with rich text or inline markdown, plus delete support
- Meeting notes: query AI meeting notes through
blocks.meetingNotes.query() - Custom emojis:
customEmojis.list()support - Pagination status: exposes
request_statuson list responses - DataSources: Continued support for the 2025-09-03 data model split
DataSources vs Databases
# New DataSources API (recommended)
await client.dataSources.query(data_source_id="...")
# Legacy Databases API (only for older Notion-Version headers)
await client.databases.query(database_id="...")
Both endpoints work identically, but dataSources is the future-proof choice.
Documentation
Full documentation is available at: https://higashi-masafumi.github.io/notion-py/
Core Capabilities
Pages
# Create a page
from notion_py_client.requests import CreatePageParameters, TitlePropertyRequest
await client.pages.create(
params=CreatePageParameters(
parent={"type": "data_source_id", "data_source_id": "your_data_source_id"},
properties={
"Name": TitlePropertyRequest(
title=[{"type": "text", "text": {"content": "New Page"}}]
)
}
)
)
Filters
from notion_py_client import NotionAsyncClient
from notion_py_client.filters import create_and_filter, create_or_filter
client = NotionAsyncClient(auth="your_NOTION_API_TOKEN")
# Simple filter (直接辞書 - IDE補完が効く)
response = await client.dataSources.query(
data_source_id="your_data_source_id",
filter={"property": "Status", "status": {"equals": "Active"}}
)
# AND filter with helper function (型安全 - IDE補完が効く)
filter = create_and_filter(
{"property": "Name", "rich_text": {"contains": "urgent"}},
{"property": "Status", "status": {"equals": "In Progress"}}
)
# OR filter with helper function
filter = create_or_filter(
{"property": "Priority", "select": {"equals": "High"}},
{"property": "Priority", "select": {"equals": "Medium"}}
)
# Nested filters (AND + OR)
filter = create_and_filter(
{"property": "Team", "select": {"equals": "Engineering"}},
create_or_filter(
{"property": "Status", "status": {"equals": "Active"}},
{"property": "Status", "status": {"equals": "Pending"}}
)
)
await client.dataSources.query(
data_source_id="your_data_source_id",
filter=filter
)
Key Benefits:
- IDE Completion: Type hints work correctly with dictionary literals
- Type Safety: TypedDict definitions match official TypeScript SDK
- No
.model_dump(): Use filters directly without conversion - Public API Compatible: Follows official Notion API specification
Domain Mapping
from notion_py_client.helper import NotionMapper, NotionPropertyDescriptor, Field
from notion_py_client.requests.property_requests import (
TitlePropertyRequest,
StatusPropertyRequest,
)
from notion_py_client.responses.property_types import TitleProperty, StatusProperty
from pydantic import BaseModel
class Task(BaseModel):
id: str
name: str
status: str
class TaskMapper(NotionMapper[Task]):
# Define field descriptors with type annotations
name_field: NotionPropertyDescriptor[TitleProperty, TitlePropertyRequest, str] = Field(
notion_name="Name",
parser=lambda p: p.title[0].plain_text if p.title else "",
request_builder=lambda v: TitlePropertyRequest(
title=[{"type": "text", "text": {"content": v}}]
)
)
status_field: NotionPropertyDescriptor[StatusProperty, StatusPropertyRequest, str] = Field(
notion_name="Status",
parser=lambda p: p.status.name if p.status else "",
request_builder=lambda v: StatusPropertyRequest(
status={"name": v}
)
)
def to_domain(self, notion_page):
"""Convert Notion page to domain model."""
props = notion_page.properties
return Task(
id=notion_page.id,
name=self.name_field.parse(props["Name"]),
status=self.status_field.parse(props["Status"]),
)
# Use the mapper
mapper = TaskMapper()
tasks = [mapper.to_domain(page) for page in response.results]
Requirements
- Python >= 3.10
- Pydantic >= 2.11.10
License
MIT License - see LICENSE for details.
Metadata
Release files for notion-py-client 0.1.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| notion_py_client-0.1.21.tar.gz | 178.2 kB | With provenance | Details for notion_py_client-0.1.21.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| notion_py_client-0.1.21-py3-none-any.whl | Python 3 | none | any | Details for notion_py_client-0.1.21-py3-none-any.whl |
Total release size: 293.9 kB
Release files / notion_py_client-0.1.21.tar.gz
| Download URL | notion_py_client-0.1.21.tar.gz |
|---|---|
| Size | 178.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97df073b70ed71a5dd26f78fc7604f94486a76236e79125a15c1d347dfb53b6b
|
|
BLAKE2b-256 checksum How to use checksums |
7a2bbd03de4a90fce85cacb1c02982360bdd0e68fa1ec821c5260ef5cf17027e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logRelease files / notion_py_client-0.1.21-py3-none-any.whl
| Download URL | notion_py_client-0.1.21-py3-none-any.whl |
|---|---|
| Size | 115.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8665aef4be80e56d181cc79f6212e5c076059f5f654c3ac84ad06d318a800946
|
|
BLAKE2b-256 checksum How to use checksums |
b556aa1724d32fd76b023bed92acbf7a6c825620bcfafb89b5acf7091f352514
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logSecurity for notion-py-client 0.1.21
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for notion_py_client-0.1.21.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.