Type Safe SDK For Notion API
Project description
Type-Safe Notion API SDK
A Python SDK for interacting with the Notion API, featuring complete IntelliSense support. Always up-to-date with the latest Notion API documentation.
Installation
Install the SDK using pip:
pip install pydantic-api-sdk-notion
Quick Start
# Import the NotionClient object from the SDK
from pydantic_api.notion.sdk import NotionClient
# Import all Notion-API related types from pydantic_api.notion.models
from pydantic_api.notion.models import (
TitleDatabaseProperty,
NumberDatabaseProperty,
PeopleDatabaseProperty,
RichTextDatabaseProperty,
# The SDK provides Factory classes for quick instantiation of Notion API objects
SortObjectFactory,
ParentObjectFactory,
RichTextObjectFactory,
)
# Instantiate a Notion client
notion_api_key = '<your-notion-api-key>'
client = NotionClient(auth=notion_api_key)
# List users
list_user_response = client.users.list(page_size=5) # Returns `NotionPaginatedData[UserObject]`
print(type(list_user_response.results[0])) # Prints 'PersonUserObject' or 'BotUserObject'
# Create a new database
new_database = client.databases.create(
parent=ParentObjectFactory.new_page_parent(
page_id="13e6c6f3f38d80269039f0186aaf95bb"
),
title=[
RichTextObjectFactory.new_text(content="🌿 Magical Plant Database"),
],
properties={
"Plant": TitleDatabaseProperty.define(),
"Scientific Name": RichTextDatabaseProperty.define(),
"Price ($)": NumberDatabaseProperty.define(format="dollar"),
"Discovered By": PeopleDatabaseProperty.define(),
},
)
# Query the database
records = client.databases.query(
database_id=new_database.id,
sorts=[
SortObjectFactory.new_property_sort(
property="Price", direction="descending"
)
],
page_size=3,
)
Additional Notes
The types used in this SDK are maintained in a separate GitHub repository:
https://github.com/stevieflyer/pydantic-api-models-notion
This repository ensures type definitions stay in sync with the latest Notion API updates. Developers can directly use these types for their own projects, even without the SDK.
Development
This repository uses devenv. Devenv and enabled direnv will give you the best developer experience.
Releasing
Create a new release here.
Choose a semver-style tag with a v prefix, (i.e. vX.X.X). The release will happen automatically.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydantic_api_sdk_notion-0.0.37.tar.gz.
File metadata
- Download URL: pydantic_api_sdk_notion-0.0.37.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9760625a36fc4e1cacfed6bdabaa11eb0cf34c932086858821f15f939baf62df
|
|
| MD5 |
1e258cbfebb5ebc252494d710c7dd239
|
|
| BLAKE2b-256 |
1e97076f81e30c9c00a6b26f6bde2e0d98166cb10506aa9b08f59d72b5f96325
|
Provenance
The following attestation bundles were made for pydantic_api_sdk_notion-0.0.37.tar.gz:
Publisher:
test.yml on stevieflyer/pydantic-api-sdk-notion
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_api_sdk_notion-0.0.37.tar.gz -
Subject digest:
9760625a36fc4e1cacfed6bdabaa11eb0cf34c932086858821f15f939baf62df - Sigstore transparency entry: 546530406
- Sigstore integration time:
-
Permalink:
stevieflyer/pydantic-api-sdk-notion@eb833bd85025e807f9f7539710c3ef4213fdaac6 -
Branch / Tag:
refs/tags/v0.0.37 - Owner: https://github.com/stevieflyer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@eb833bd85025e807f9f7539710c3ef4213fdaac6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pydantic_api_sdk_notion-0.0.37-py3-none-any.whl.
File metadata
- Download URL: pydantic_api_sdk_notion-0.0.37-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78931653a71d0d529956ff626e9ac8ea8a3fe4b8c182948e3c0dbf5f8cfb722e
|
|
| MD5 |
081f0aac734a5a666d906601ce9bd9a2
|
|
| BLAKE2b-256 |
b0b64ba75eca36045d621c2b24a05c361419fae0a9cacc20e82f6ede7817a246
|
Provenance
The following attestation bundles were made for pydantic_api_sdk_notion-0.0.37-py3-none-any.whl:
Publisher:
test.yml on stevieflyer/pydantic-api-sdk-notion
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydantic_api_sdk_notion-0.0.37-py3-none-any.whl -
Subject digest:
78931653a71d0d529956ff626e9ac8ea8a3fe4b8c182948e3c0dbf5f8cfb722e - Sigstore transparency entry: 546530409
- Sigstore integration time:
-
Permalink:
stevieflyer/pydantic-api-sdk-notion@eb833bd85025e807f9f7539710c3ef4213fdaac6 -
Branch / Tag:
refs/tags/v0.0.37 - Owner: https://github.com/stevieflyer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@eb833bd85025e807f9f7539710c3ef4213fdaac6 -
Trigger Event:
push
-
Statement type: