# 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:
```bash
pip install pydantic-api-sdk-notion
```
## Quick Start
```python
# 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](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.
Raw data
{
"_id": null,
"home_page": "https://github.com/stevieflyer/pydantic-api-sdk-notion",
"name": "pydantic-api-sdk-notion",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "notion, pydantic, api, type-safe",
"author": "stevieflyer",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/af/c0/e6d5bcda6d2e61a1bacb8872ee64574ae7c94a03de5a686797dd639e0ff2/pydantic_api_sdk_notion-0.0.5.tar.gz",
"platform": null,
"description": "# Type-Safe Notion API SDK\n\nA Python SDK for interacting with the Notion API, featuring **complete IntelliSense support**. Always **up-to-date** with the latest Notion API documentation.\n\n---\n\n## Installation\n\nInstall the SDK using pip:\n\n```bash\npip install pydantic-api-sdk-notion\n```\n\n## Quick Start\n\n```python\n# Import the NotionClient object from the SDK\nfrom pydantic_api.notion.sdk import NotionClient\n\n# Import all Notion-API related types from pydantic_api.notion.models\nfrom pydantic_api.notion.models import (\n TitleDatabaseProperty,\n NumberDatabaseProperty,\n PeopleDatabaseProperty,\n RichTextDatabaseProperty,\n # The SDK provides Factory classes for quick instantiation of Notion API objects\n SortObjectFactory,\n ParentObjectFactory,\n RichTextObjectFactory,\n)\n\n# Instantiate a Notion client\nnotion_api_key = '<your-notion-api-key>'\nclient = NotionClient(auth=notion_api_key)\n\n# List users\nlist_user_response = client.users.list(page_size=5) # Returns `NotionPaginatedData[UserObject]`\nprint(type(list_user_response.results[0])) # Prints 'PersonUserObject' or 'BotUserObject'\n\n# Create a new database\nnew_database = client.databases.create(\n parent=ParentObjectFactory.new_page_parent(\n page_id=\"13e6c6f3f38d80269039f0186aaf95bb\"\n ),\n title=[\n RichTextObjectFactory.new_text(content=\"\ud83c\udf3f Magical Plant Database\"),\n ],\n properties={\n \"Plant\": TitleDatabaseProperty.define(),\n \"Scientific Name\": RichTextDatabaseProperty.define(),\n \"Price ($)\": NumberDatabaseProperty.define(format=\"dollar\"),\n \"Discovered By\": PeopleDatabaseProperty.define(),\n },\n)\n\n# Query the database\nrecords = client.databases.query(\n database_id=new_database.id,\n sorts=[\n SortObjectFactory.new_property_sort(\n property=\"Price\", direction=\"descending\"\n )\n ],\n page_size=3,\n)\n```\n\n## Additional Notes\n\nThe **types used in this SDK** are maintained in a separate GitHub repository: \n[https://github.com/stevieflyer/pydantic-api-models-notion](https://github.com/stevieflyer/pydantic-api-models-notion)\n\nThis 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.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Type Safe SDK For Notion API",
"version": "0.0.5",
"project_urls": {
"Homepage": "https://github.com/stevieflyer/pydantic-api-sdk-notion",
"Repository": "https://github.com/stevieflyer/pydantic-api-sdk-notion"
},
"split_keywords": [
"notion",
" pydantic",
" api",
" type-safe"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1c8ebd24db5d4ae0f54c3cba17b1d475128c3f27a804ade024f6bcce3346a58d",
"md5": "e749b46dee1a7fdc50bb19f07b214a9b",
"sha256": "7e496fcdf222a528402535b870b06f3698c7034904111389b691574937029e45"
},
"downloads": -1,
"filename": "pydantic_api_sdk_notion-0.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e749b46dee1a7fdc50bb19f07b214a9b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 12243,
"upload_time": "2024-11-21T07:35:21",
"upload_time_iso_8601": "2024-11-21T07:35:21.936107Z",
"url": "https://files.pythonhosted.org/packages/1c/8e/bd24db5d4ae0f54c3cba17b1d475128c3f27a804ade024f6bcce3346a58d/pydantic_api_sdk_notion-0.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "afc0e6d5bcda6d2e61a1bacb8872ee64574ae7c94a03de5a686797dd639e0ff2",
"md5": "ae208eeee05eafe884163945fe314034",
"sha256": "d131237a01e7110296e3428cdddb55a7e7839b2874ae35f5eb8904f147faad57"
},
"downloads": -1,
"filename": "pydantic_api_sdk_notion-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "ae208eeee05eafe884163945fe314034",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 8566,
"upload_time": "2024-11-21T07:35:23",
"upload_time_iso_8601": "2024-11-21T07:35:23.714739Z",
"url": "https://files.pythonhosted.org/packages/af/c0/e6d5bcda6d2e61a1bacb8872ee64574ae7c94a03de5a686797dd639e0ff2/pydantic_api_sdk_notion-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-21 07:35:23",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "stevieflyer",
"github_project": "pydantic-api-sdk-notion",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pydantic-api-sdk-notion"
}