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.
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
File details
Details for the file pydantic_api_sdk_notion-0.0.2.tar.gz
.
File metadata
- Download URL: pydantic_api_sdk_notion-0.0.2.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Darwin/24.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af2afb3c52cf193415a240469d923b768f83e0972f03fe55363a486324a8b3b2 |
|
MD5 | ddc0649461183a45d94cfc0ba5a0e1bc |
|
BLAKE2b-256 | 7730dd436adf96d03646361d3c3b5ae2b9cd2b5acdab85b5cde63ce7642171df |
File details
Details for the file pydantic_api_sdk_notion-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: pydantic_api_sdk_notion-0.0.2-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.7 Darwin/24.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b05b3bd662e48e6d9b320f36255a859d3138a00f1bd9917f1becb810b903a023 |
|
MD5 | 10fc67fcd6755221f034ae5f0e973bf9 |
|
BLAKE2b-256 | b87edf2797465c6aa2964b475513a6d20037655e614c34f9909f51a8665ec797 |