NotionX, a simple, easy-to-use Notion client, is based on the official SDK modification. 一个简单易用的Notion客户端
MIT License
NotionX
, a simple and easy-to-use Notion client, is based on the official SDK modification.
2022-06-28
version of Notion.httpx
for synchronous HTTP requests, asynchronous request feature is underJust install it using pip.
pip install notionx
Before using NotionX, you need to create an integration token, and share at least one page with that integration.
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
|
See our wikis for details.
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