Skip to main content

Type Safe SDK For Notion API

Project description

Type-Safe Notion API SDK

PyPI version

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_api_sdk_notion-0.0.37.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydantic_api_sdk_notion-0.0.37-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

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

Hashes for pydantic_api_sdk_notion-0.0.37.tar.gz
Algorithm Hash digest
SHA256 9760625a36fc4e1cacfed6bdabaa11eb0cf34c932086858821f15f939baf62df
MD5 1e258cbfebb5ebc252494d710c7dd239
BLAKE2b-256 1e97076f81e30c9c00a6b26f6bde2e0d98166cb10506aa9b08f59d72b5f96325

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydantic_api_sdk_notion-0.0.37-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_api_sdk_notion-0.0.37-py3-none-any.whl
Algorithm Hash digest
SHA256 78931653a71d0d529956ff626e9ac8ea8a3fe4b8c182948e3c0dbf5f8cfb722e
MD5 081f0aac734a5a666d906601ce9bd9a2
BLAKE2b-256 b0b64ba75eca36045d621c2b24a05c361419fae0a9cacc20e82f6ede7817a246

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page