Skip to main content

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


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.5.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

pydantic_api_sdk_notion-0.0.5-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file pydantic_api_sdk_notion-0.0.5.tar.gz.

File metadata

  • Download URL: pydantic_api_sdk_notion-0.0.5.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Darwin/24.1.0

File hashes

Hashes for pydantic_api_sdk_notion-0.0.5.tar.gz
Algorithm Hash digest
SHA256 d131237a01e7110296e3428cdddb55a7e7839b2874ae35f5eb8904f147faad57
MD5 ae208eeee05eafe884163945fe314034
BLAKE2b-256 afc0e6d5bcda6d2e61a1bacb8872ee64574ae7c94a03de5a686797dd639e0ff2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pydantic_api_sdk_notion-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7e496fcdf222a528402535b870b06f3698c7034904111389b691574937029e45
MD5 e749b46dee1a7fdc50bb19f07b214a9b
BLAKE2b-256 1c8ebd24db5d4ae0f54c3cba17b1d475128c3f27a804ade024f6bcce3346a58d

See more details on using hashes here.

Supported by

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