Async
AsyncNotionAPI
Main class for Notion API wrapper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
access_token
|
str
|
Notion access token |
required |
api_version
|
str
|
Version of the notion API |
'2025-09-03'
|
rate_limit
|
tuple[int, int]
|
(number_of_requests, number of seconds). Default |
(500, 200)
|
Source code in python_notion_api/async_api/api.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 | |
request_headers
property
Gets request headers for making requests.
get_block(block_id)
async
Gets Notion block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block_id
|
str
|
Id of the block to fetch. |
required |
Source code in python_notion_api/async_api/api.py
107 108 109 110 111 112 113 114 115 116 | |
get_data_source(data_source_id)
async
Gets Notion DataSource
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_source_id
|
str
|
Id of the data source to fetch. |
required |
Returns:
| Type | Description |
|---|---|
NotionDataSource
|
A Notion DataSource with the given id. |
Source code in python_notion_api/async_api/api.py
78 79 80 81 82 83 84 85 86 87 88 89 90 | |
get_database(database_id)
async
Gets Notion database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
database_id
|
str
|
Id of the database to fetch. |
required |
Returns:
| Type | Description |
|---|---|
NotionDatabase
|
A Notion database with the given id. |
Source code in python_notion_api/async_api/api.py
64 65 66 67 68 69 70 71 72 73 74 75 76 | |
get_page(page_id, page_cast=NotionPage)
async
Gets Notion Page
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
page_id
|
Id of the page to fetch. |
required | |
page_cast
|
A subclass of a NotionPage. Allows custom property retrieval. |
NotionPage
|
Returns: A Notion page with the given id.
Source code in python_notion_api/async_api/api.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
NotionBlock
Wrapper for a Notion block object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api
|
AsyncNotionAPI
|
Instance of the NotionAPI. |
required |
block_id
|
str
|
Id of the block. |
required |
Source code in python_notion_api/async_api/notion_block.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
block_id
property
Gets the block id.
add_child_block(content, reload_block=False)
async
Adds new blocks as children.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
List[Block]
|
Content of the new block. |
required |
Returns:
| Type | Description |
|---|---|
AsyncBlockIterator
|
An iterator of the newly created blocks. |
Source code in python_notion_api/async_api/notion_block.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
get_child_blocks()
async
Gets all children blocks.
Returns:
| Type | Description |
|---|---|
AsyncBlockIterator
|
An iterator of all children blocks in the block. |
Source code in python_notion_api/async_api/notion_block.py
42 43 44 45 46 47 48 49 50 51 | |
reload()
async
Reloads the block from Notion.
Source code in python_notion_api/async_api/notion_block.py
26 27 28 | |
set(block, reload_block=False)
async
Updates the content of a Block.
The entire content is replaced.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
block
|
Block
|
Block with the new values. |
required |
Returns:
| Type | Description |
|---|---|
Block
|
The updated block. |
Source code in python_notion_api/async_api/notion_block.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
NotionDataSource
Wrapper for a Notion datasource object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api
|
AsyncNotionAPI
|
Instance of the NotionAPI. |
required |
data_source_id
|
str
|
Id of the data source. |
required |
Source code in python_notion_api/async_api/notion_data_source.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
properties
property
Get all property configurations of the data source.
relations
property
Get all property configurations of the data source that are relations.
title
property
Get the title of the data source.
create_page(properties={}, cover_url=None)
async
Creates a new page in the Data Source and updates the new page with the properties.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
properties
|
dict[str, Any]
|
Dictionary of property names and values. Value types |
{}
|
cover_url
|
Optional[str]
|
URL of an image for the page cover. |
None
|
Source code in python_notion_api/async_api/notion_data_source.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
query(filters=None, sorts=None, page_limit=None, cast_cls=NotionPage)
async
A wrapper for 'Query a data source' action.
Retrieves all pages belonging to the data source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
Optional[FilterItem]
|
|
None
|
sorts
|
Optional[list[Sort]]
|
|
None
|
cast_cls
|
A subclass of a NotionPage. Allows custom |
NotionPage
|
Source code in python_notion_api/async_api/notion_data_source.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
NotionDatabase
Wrapper for a Notion database object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api
|
AsyncNotionAPI
|
Instance of the NotionAPI. |
required |
database_id
|
str
|
Id of the database. |
required |
Source code in python_notion_api/async_api/notion_database.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
data_sources
property
Gets all data sources of the database.
database_id
property
Gets the database id.
title
property
Gets title of the database.
NotionPage
Wrapper for a Notion page object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api
|
AsyncNotionAPI
|
Instance of the NotionAPI. |
required |
page_id
|
str
|
Id of the page. |
required |
Source code in python_notion_api/async_api/notion_page.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | |
is_alive
property
Checks if the page is archived.
Returns:
| Type | Description |
|---|---|
bool
|
|
page_id
property
Returns the page id.
add_blocks(blocks)
async
Adds new blocks to the page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
blocks
|
list[Block]
|
List of Blocks to add. |
required |
Returns:
| Type | Description |
|---|---|
AsyncBlockIterator
|
Iterator of new blocks. |
Source code in python_notion_api/async_api/notion_page.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
archive()
async
Archives the page
Source code in python_notion_api/async_api/notion_page.py
83 84 85 | |
get(prop_key, cache=True, safety_off=False, raw=False)
async
Gets a single page property.
First checks if the property is 'special', if so, will call the special function to get that property value. If not, gets the property through the api.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop_key
|
str
|
Name or id of the property to retrieve. |
required |
cache
|
bool
|
If |
True
|
safety_off
|
bool
|
If |
False
|
Source code in python_notion_api/async_api/notion_page.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
get_blocks()
async
Gets all blocks in the page.
Returns:
| Type | Description |
|---|---|
AsyncBlockIterator
|
Iterator of blocks is returned. |
Source code in python_notion_api/async_api/notion_page.py
234 235 236 237 238 239 240 241 242 243 244 | |
get_properties(raw=False)
async
Gets all properties of the page.
Source code in python_notion_api/async_api/notion_page.py
167 168 169 170 171 172 173 174 175 176 | |
reload()
async
Reloads page from Notion.
Source code in python_notion_api/async_api/notion_page.py
55 56 57 58 59 60 61 | |
set(prop_key, value, reload_page=False)
async
Sets a single page property.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prop_key
|
str
|
Name or id of the property to update. |
required |
value
|
Any
|
A new value of the property. |
required |
reload_page
|
bool
|
Whether to reload the page after updating the property. |
False
|
Source code in python_notion_api/async_api/notion_page.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
to_dict(include_rels=True, rels_only=False, properties=None)
async
"Returns all properties of the page as a dict of builtin type values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_rels
|
bool
|
Include relations. |
True
|
rels_only
|
Return relations only. |
False
|
|
properties
|
Optional[dict]
|
List of properties to return. If |
None
|
Source code in python_notion_api/async_api/notion_page.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
unarchive()
async
Unarchives the page
Source code in python_notion_api/async_api/notion_page.py
87 88 89 | |
update(properties, reload_page=False)
async
Updates the page with a dictionary of new values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
properties
|
dict[str, Any]
|
A dictionary mapping property keys to new values. |
required |
reload_page
|
bool
|
Whether to reload the page after updating the properties. |
False
|
Source code in python_notion_api/async_api/notion_page.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |