Skip to content

Transform Notion into a headless CMS with this Python SDK. Enjoy seamless integration, type safety, and asynchronous support for your applications. πŸš€πŸ™

Notifications You must be signed in to change notification settings

Sombath299/notion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Notion: A Production-Ready Python SDK for Notion API πŸš€

Latest Release Python Version License


Table of Contents


Overview

The Notion SDK is a comprehensive, production-ready Python SDK designed for seamless integration with the Notion API. Built specifically for FastAPI, this SDK supports asynchronous operations, webhooks, and all major Notion objects. Whether you're building a personal project or a large-scale application, this SDK provides the tools you need to interact with Notion efficiently.

For the latest updates and releases, check the Releases section.


Features

  • Asynchronous Support: Leverage Python's async capabilities for better performance.
  • Webhooks: Easily set up webhooks to receive real-time updates from Notion.
  • Comprehensive Object Support: Access all major Notion objects like pages, databases, and blocks.
  • FastAPI Integration: Designed to work seamlessly with FastAPI for rapid development.
  • Pydantic Models: Utilize Pydantic for data validation and serialization.

Installation

To install the Notion SDK, use pip:

pip install notion-sdk

This command will download and install the SDK along with its dependencies.


Usage

Basic Setup

Here's a simple example to get you started:

from notion_sdk import NotionClient

client = NotionClient(auth_token='your_token_here')

# Fetch a page
page = https://github.com/Sombath299/notion/releases('your_page_id')
print(page)

Asynchronous Usage

If you're using FastAPI, you can take advantage of the async capabilities:

from notion_sdk import NotionClient

client = NotionClient(auth_token='your_token_here')

async def fetch_page(page_id):
    page = await https://github.com/Sombath299/notion/releases(page_id)
    return page

API Reference

Authentication

To use the Notion SDK, you need an authentication token. You can get this token from your Notion settings.

Major Objects

  • Pages: Represents a Notion page.
  • Databases: Represents a Notion database.
  • Blocks: Represents a block in Notion.

For detailed information on each object and its methods, refer to the official Notion API documentation.


Examples

Fetching a Database

database = https://github.com/Sombath299/notion/releases('your_database_id')
print(database)

Updating a Page

https://github.com/Sombath299/notion/releases(
    page_id='your_page_id',
    properties={
        'Name': {
            'title': [
                {
                    'text': {
                        'content': 'New Page Title'
                    }
                }
            ]
        }
    }
)

Webhooks

Setting up webhooks allows your application to receive updates from Notion in real time. Here's how to do it:

  1. Create a Webhook Endpoint: Set up an endpoint in your FastAPI application to handle incoming webhook requests.
from fastapi import FastAPI, Request

app = FastAPI()

https://github.com/Sombath299/notion/releases("/webhook")
async def webhook(request: Request):
    data = await https://github.com/Sombath299/notion/releases()
    # Process the incoming data
    return {"status": "success"}
  1. Register the Webhook: Use the SDK to register your webhook with Notion.
https://github.com/Sombath299/notion/releases(
    url='https://github.com/Sombath299/notion/releases',
    event_types=['page_updated']
)

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes.
  4. Submit a pull request.

For more detailed information, check the https://github.com/Sombath299/notion/releases file.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Contact

For questions or feedback, reach out to the maintainer:

For the latest releases, visit the Releases section.


Notion Logo


Topics

  • api-wrapper
  • async
  • fastapi
  • integration
  • notion-api
  • notion-sdk
  • production-ready
  • pydantic
  • python
  • webhooks

About

Transform Notion into a headless CMS with this Python SDK. Enjoy seamless integration, type safety, and asynchronous support for your applications. πŸš€πŸ™

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •