Helpers
Utility functions for notion-sdk-py.
async_collect_paginated_api(function, **kwargs)
async
Collect asynchronously all the results of paginating an API into a list.
Source code in notion_client/helpers.py
85 86 87 88 89 |
|
async_iterate_paginated_api(function, **kwargs)
async
Return an async iterator over the results of any paginated Notion API.
Source code in notion_client/helpers.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
collect_paginated_api(function, **kwargs)
Collect all the results of paginating an API into a list.
Source code in notion_client/helpers.py
64 65 66 |
|
extract_block_id(url_or_id)
Extract a block ID from a Notion URL fragment or validate if it's already a valid ID.
Specifically looks for block IDs in URL fragments (after #).
If no fragment is present, falls back to extract_notion_id
behavior.
Returns the extracted UUID in standard format (with hyphens) or None if invalid.
Source code in notion_client/helpers.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
|
extract_database_id(database_url)
Extract a database ID from a Notion URL or validate if it's already a valid ID.
This is an alias for extract_notion_id
for clarity when working with databases.
Returns the extracted UUID in standard format (with hyphens) or None if invalid.
Source code in notion_client/helpers.py
207 208 209 210 211 212 213 214 |
|
extract_notion_id(url_or_id)
Extract a Notion ID from a Notion URL or return the input if it's already a valid ID.
Prioritizes path IDs over query parameters to avoid extracting view IDs instead of database IDs.
Returns the extracted UUID in standard format (with hyphens) or None if invalid.
# Database URL with view ID - extracts database ID, not view ID
extract_notion_id('https://notion.so/workspace/DB-abc123def456789012345678901234ab?v=viewid123')
# Returns: 'abc123de-f456-7890-1234-5678901234ab' # database ID
# Already formatted UUID
extract_notion_id('12345678-1234-1234-1234-123456789abc')
# Returns: '12345678-1234-1234-1234-123456789abc'
Source code in notion_client/helpers.py
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 |
|
extract_page_id(page_url)
Extract a page ID from a Notion URL or validate if it's already a valid ID.
This is an alias for extract_notion_id
for clarity when working with pages.
Returns the extracted UUID in standard format (with hyphens) or None if invalid.
Source code in notion_client/helpers.py
217 218 219 220 221 222 223 224 |
|
get_id(url)
Return the id of the object behind the given URL.
Source code in notion_client/helpers.py
36 37 38 39 40 41 42 43 44 45 |
|
get_url(object_id)
Return the URL for the object with the given id.
Source code in notion_client/helpers.py
31 32 33 |
|
is_equation_rich_text_item_response(rich_text)
Return True
if rich_text
is an equation.
Source code in notion_client/helpers.py
129 130 131 |
|
is_full_block(response)
Return True
if response is a full block.
Source code in notion_client/helpers.py
92 93 94 |
|
is_full_comment(response)
Return True
if response is a full comment.
Source code in notion_client/helpers.py
119 120 121 |
|
is_full_database(response)
Return True
if response is a full database.
Source code in notion_client/helpers.py
102 103 104 |
|
is_full_page(response)
Return True
if response is a full page.
Source code in notion_client/helpers.py
97 98 99 |
|
is_full_page_or_database(response)
Return True
if response
is a full database or a full page.
Source code in notion_client/helpers.py
107 108 109 110 111 |
|
is_full_user(response)
Return True
if response is a full user.
Source code in notion_client/helpers.py
114 115 116 |
|
is_mention_rich_text_item_response(rich_text)
Return True
if rich_text
is a mention.
Source code in notion_client/helpers.py
134 135 136 |
|
is_text_rich_text_item_response(rich_text)
Return True
if rich_text
is a text.
Source code in notion_client/helpers.py
124 125 126 |
|
iterate_paginated_api(function, **kwargs)
Return an iterator over the results of any paginated Notion API.
Source code in notion_client/helpers.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
pick(base, *keys)
Return a dict composed of key value pairs for keys passed as args.
Source code in notion_client/helpers.py
18 19 20 21 22 23 24 25 26 27 28 |
|