Skip to main content

NotionX, a simple, easy-to-use Notion client, is based on the official SDK modification

Project description

NotionX

NotionX, a simple and easy-to-use Notion client, is based on the official SDK modification.

Implemented features

  • Latest Notion API support: The code uses the 2022-06-28 version of Notion.
  • Complete API coverage: all methods of the official Notion API documentation (https://developers.notion.com/reference/) have been wrapped.
  • Simple request validation: locally verifies whether the user's request is legal, currently supports key validation of the outermost parameters (e.g., whether the parameters provided by the user are complete, whether there are parameters not included in the API documentation), while value validation and nested parameter validation are still under development.
  • Synchronous Client request, which uses httpx for synchronous HTTP requests, asynchronous request feature is under development.
  • Complete code examples covering 100% of the client methods and over 90% of the code.
  • Complete tests, covering 98%+ of the client code.

Requirements

  • Python >= 3.7
  • httpx >= 0.23.0

Installation

Just install it using pip.

pip install notionx

Usage

Before using NotionX, you need to create an integration token, and share at least one page with that integration.

Client initialization

To initialize Notion Client by passing in a dictionary (dictionary parameter style) containing auth_token (the token of the above integration, starting with secret_).

from notionx import Client

client = Client({
    "auth_token": "your_integration_token"
})

There is another way to initialize, passed in keyword parameter style.

from notionx import Client

client = Client(
  auth_token="your_integration_token"
)

The dictionary parameter style and the keyword parameter style also apply to the methods of the client, and we will give the invocation of each style later.

💡 Note!!!

To avoid leaks of the integration token, we do not recommend hard-coding the token explicitly in your source code. It is better to write it to the environment variables and then initialize the client by

import os
from notionx import Client

token = os.getenv("NOTION_AUTH_TOKEN")
client = Client(
auth_token=token
)

In addition to auth_token, Client has several optional initialization parameters, whose names and meanings are shown in the following table.

parameter name type default value description
auth_token str no default value Integration Token
notion_version str "2022-06-28" Notion's version
base_url str "https://api.notion.com/v1" The root URL for sending API requests
timeout_ms int 90_000 The number of milliseconds to wait before issuing a RequestTimeoutError

How-tos

See our wikis for details.

Code Examples

We provide code examples that cover all methods of the client and the data is taken from Notion's official documentation.

See also: https://github.com/JezaChen/mumu-notion/tree/master/examples/official_guides

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

NotionX-0.21.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

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

NotionX-0.21-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file NotionX-0.21.tar.gz.

File metadata

  • Download URL: NotionX-0.21.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for NotionX-0.21.tar.gz
Algorithm Hash digest
SHA256 fe0169447673723ffe15023c59a2ba08cdec31efac6f1ecc34da1e036cc933a7
MD5 87d1b90e069b1ea677890348fa9de9ec
BLAKE2b-256 105e89ea1c1be59121ed045ee956da6e92c89b8c9d4056daf82a32169bd5b241

See more details on using hashes here.

File details

Details for the file NotionX-0.21-py3-none-any.whl.

File metadata

  • Download URL: NotionX-0.21-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for NotionX-0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 17fafde6dbd82a522d84c2679e7a5e00dea217d35d9ca83fbd6df522903c3484
MD5 aca9360de36019f5dfec042a878d9bfc
BLAKE2b-256 b70c54949e5b1cd79b581dc2fa9dca040fea23c78acced931a5e0d6c43c9919e

See more details on using hashes here.

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