notion-database 2.0.dev1__tar.gz → 2.0.0rc1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/PKG-INFO +119 -6
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/README.md +118 -5
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/__init__.py +2 -2
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/api/blocks.py +21 -2
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/api/databases.py +38 -1
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/api/pages.py +101 -6
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/api/search.py +27 -6
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/http/client.py +1 -1
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/models/blocks.py +54 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/models/filters.py +78 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/models/properties.py +85 -8
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database.egg-info/PKG-INFO +119 -6
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/pyproject.toml +1 -1
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/tests/test_models_filters.py +61 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/tests/test_models_properties.py +23 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/LICENSE +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/api/__init__.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/api/comments.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/api/users.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/client.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/const/__init__.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/const/color.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/exceptions.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/http/__init__.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/models/__init__.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/models/icons.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/models/rich_text.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database/models/sorts.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database.egg-info/SOURCES.txt +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database.egg-info/dependency_links.txt +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database.egg-info/requires.txt +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/notion_database.egg-info/top_level.txt +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/setup.cfg +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/tests/test_models_blocks.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/tests/test_models_icons.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/tests/test_models_rich_text.py +0 -0
- {notion_database-2.0.dev1 → notion_database-2.0.0rc1}/tests/test_models_sorts.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: notion-database
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.0rc1
|
|
4
4
|
Summary: Python client for the Notion API
|
|
5
5
|
Author-email: minwook-shin <minwook0106@gmail.com>
|
|
6
6
|
License: LGPLv3
|
|
@@ -32,10 +32,36 @@ Dynamic: license-file
|
|
|
32
32
|
|
|
33
33
|
> Python client for the Notion API — easy to use, 1-to-1 API mapping, AI/MCP friendly
|
|
34
34
|
|
|
35
|
+
**Notion API version supported: `2026-03-11`**
|
|
36
|
+
|
|
37
|
+
## What's new in 2.0
|
|
38
|
+
|
|
39
|
+
| Feature | Description |
|
|
40
|
+
|---|---|
|
|
41
|
+
| `client.pages.retrieve_markdown()` | Retrieve a page as enhanced Markdown (`GET /pages/{id}/markdown`) |
|
|
42
|
+
| `client.pages.update_markdown()` | Replace page content with Markdown (`PATCH /pages/{id}/markdown`) |
|
|
43
|
+
| `client.pages.append_markdown()` | Append Markdown to the bottom of a page (`PATCH /pages/{id}/markdown`) |
|
|
44
|
+
| `client.pages.create(timezone=...)` | IANA timezone for template variables (`@now`, `@today`) |
|
|
45
|
+
| `client.blocks.append_children(position=...)` | Insert blocks at `start`, `end`, or `after_block` |
|
|
46
|
+
| `client.databases.query(in_trash=...)` | Filter trashed / non-trashed rows |
|
|
47
|
+
| `client.databases.update(is_inline=..., in_trash=..., is_locked=...)` | Toggle inline layout, trash, and lock state |
|
|
48
|
+
| `client.databases.create(initial_data_source=...)` | Pre-populate a database from a data source on creation |
|
|
49
|
+
| `PropertySchema.button()` | Automation button column |
|
|
50
|
+
| `PropertySchema.location()` | Geographic location column |
|
|
51
|
+
| `PropertySchema.last_visited_time()` | Last visited time column (read-only) |
|
|
52
|
+
| `PropertySchema.rollup(relation_property_id=..., rollup_property_id=...)` | ID-based rollup lookup params |
|
|
53
|
+
| `PropertySchema.verification()` | Wiki page verification column |
|
|
54
|
+
| `PropertyValue.verification()` | Set wiki page verification state |
|
|
55
|
+
| `BlockContent.tab()` / `tab_group()` | Tab layout blocks |
|
|
56
|
+
| `Filter.created_by()` / `last_edited_by()` | Filter by creator or last editor |
|
|
57
|
+
| `Filter.formula(name, value_type)` | Filter on formula property results |
|
|
58
|
+
| `Filter.rollup(name, aggregate, value_type)` | Filter on rollup aggregates |
|
|
59
|
+
| `Filter.verification()` | Filter on wiki verification state |
|
|
60
|
+
|
|
35
61
|
## Install
|
|
36
62
|
|
|
37
63
|
```bash
|
|
38
|
-
pip install notion-database==2.0.
|
|
64
|
+
pip install notion-database==2.0.0rc1
|
|
39
65
|
```
|
|
40
66
|
|
|
41
67
|
## Quick start
|
|
@@ -97,10 +123,12 @@ results = client.databases.query(
|
|
|
97
123
|
# Auto-paginate (returns all pages at once)
|
|
98
124
|
all_pages = client.databases.query_all("database-id")
|
|
99
125
|
|
|
100
|
-
# Update schema
|
|
126
|
+
# Update schema — rename, lock, and set inline layout
|
|
101
127
|
client.databases.update(
|
|
102
128
|
"database-id",
|
|
103
129
|
title=[RichText.text("Renamed DB")],
|
|
130
|
+
is_inline=False, # full-page, not inline
|
|
131
|
+
is_locked=True, # prevent edits without unlocking
|
|
104
132
|
)
|
|
105
133
|
```
|
|
106
134
|
|
|
@@ -145,7 +173,7 @@ client.pages.archive("page-id", archived=False)
|
|
|
145
173
|
## Blocks
|
|
146
174
|
|
|
147
175
|
```python
|
|
148
|
-
# Append content to a page
|
|
176
|
+
# Append content to a page (inserted at end by default)
|
|
149
177
|
client.blocks.append_children(
|
|
150
178
|
"page-id",
|
|
151
179
|
children=[
|
|
@@ -166,9 +194,23 @@ client.blocks.append_children(
|
|
|
166
194
|
[BlockContent.paragraph("Left column")],
|
|
167
195
|
[BlockContent.paragraph("Right column")],
|
|
168
196
|
]),
|
|
197
|
+
# Tab layout (Notion-Version: 2026-03-11)
|
|
198
|
+
BlockContent.tab_group([
|
|
199
|
+
BlockContent.tab("Overview", [BlockContent.paragraph("Overview content")]),
|
|
200
|
+
BlockContent.tab("Details", [BlockContent.paragraph("Details content")]),
|
|
201
|
+
]),
|
|
169
202
|
],
|
|
170
203
|
)
|
|
171
204
|
|
|
205
|
+
# Insert at a specific position (Notion-Version: 2026-03-11)
|
|
206
|
+
client.blocks.append_children("page-id", children=[
|
|
207
|
+
BlockContent.paragraph("Prepended to top"),
|
|
208
|
+
], position={"type": "start"})
|
|
209
|
+
|
|
210
|
+
client.blocks.append_children("page-id", children=[
|
|
211
|
+
BlockContent.paragraph("After a specific block"),
|
|
212
|
+
], position={"type": "after_block", "after_block": {"id": "block-id"}})
|
|
213
|
+
|
|
172
214
|
# Retrieve children (single page)
|
|
173
215
|
response = client.blocks.retrieve_children("page-id")
|
|
174
216
|
blocks = response["results"]
|
|
@@ -248,10 +290,26 @@ Filter.date("Due").before("2025-01-01")
|
|
|
248
290
|
Filter.date("Due").past_week()
|
|
249
291
|
Filter.date("Due").next_month()
|
|
250
292
|
|
|
251
|
-
#
|
|
293
|
+
# People-type columns
|
|
294
|
+
Filter.people("Assignee").contains("user-id")
|
|
295
|
+
Filter.created_by("Created By").contains("user-id")
|
|
296
|
+
Filter.last_edited_by("Last Edited By").does_not_contain("user-id")
|
|
297
|
+
|
|
298
|
+
# Timestamp columns
|
|
252
299
|
Filter.created_time().after("2024-01-01")
|
|
253
300
|
Filter.last_edited_time().past_week()
|
|
254
301
|
|
|
302
|
+
# Formula (value_type: "string" | "number" | "checkbox" | "date")
|
|
303
|
+
Filter.formula("Computed", "string").equals("ok")
|
|
304
|
+
Filter.formula("Score", "number").greater_than(50)
|
|
305
|
+
|
|
306
|
+
# Rollup (aggregate: "any" | "every" | "none" | "number"; value_type: property type)
|
|
307
|
+
Filter.rollup("Tasks", "any", "number").greater_than(0)
|
|
308
|
+
Filter.rollup("Tags", "every", "rich_text").contains("urgent")
|
|
309
|
+
|
|
310
|
+
# Verification (wiki pages)
|
|
311
|
+
Filter.verification("Verified").equals("verified")
|
|
312
|
+
|
|
255
313
|
# Compound
|
|
256
314
|
Filter.and_([
|
|
257
315
|
Filter.select("Status").equals("Active"),
|
|
@@ -271,7 +329,7 @@ Filter.and_([
|
|
|
271
329
|
]),
|
|
272
330
|
])
|
|
273
331
|
|
|
274
|
-
# Raw (escape hatch
|
|
332
|
+
# Raw (escape hatch)
|
|
275
333
|
Filter.raw({"property": "Formula", "formula": {"string": {"equals": "ok"}}})
|
|
276
334
|
```
|
|
277
335
|
|
|
@@ -305,6 +363,61 @@ RichText.mention_date("2024-01-01", end="2024-01-31")
|
|
|
305
363
|
RichText.equation("E=mc^2")
|
|
306
364
|
```
|
|
307
365
|
|
|
366
|
+
## PropertySchema reference
|
|
367
|
+
|
|
368
|
+
```python
|
|
369
|
+
from notion_database import PropertySchema
|
|
370
|
+
|
|
371
|
+
{
|
|
372
|
+
# Text
|
|
373
|
+
"Name": PropertySchema.title(),
|
|
374
|
+
"Notes": PropertySchema.rich_text(),
|
|
375
|
+
"Website": PropertySchema.url(),
|
|
376
|
+
"Email": PropertySchema.email(),
|
|
377
|
+
"Phone": PropertySchema.phone_number(),
|
|
378
|
+
|
|
379
|
+
# Numeric
|
|
380
|
+
"Score": PropertySchema.number("number"),
|
|
381
|
+
"Price": PropertySchema.number("dollar"),
|
|
382
|
+
|
|
383
|
+
# Selection
|
|
384
|
+
"Category": PropertySchema.select([{"name": "A", "color": "green"}]),
|
|
385
|
+
"Tags": PropertySchema.multi_select(),
|
|
386
|
+
"Status": PropertySchema.status(),
|
|
387
|
+
|
|
388
|
+
# Date / time (read-only system columns)
|
|
389
|
+
"Due": PropertySchema.date(),
|
|
390
|
+
"Created": PropertySchema.created_time(),
|
|
391
|
+
"CreatedBy": PropertySchema.created_by(),
|
|
392
|
+
"LastEdited": PropertySchema.last_edited_time(),
|
|
393
|
+
"LastEditedBy": PropertySchema.last_edited_by(),
|
|
394
|
+
|
|
395
|
+
# Other
|
|
396
|
+
"Done": PropertySchema.checkbox(),
|
|
397
|
+
"Files": PropertySchema.files(),
|
|
398
|
+
"People": PropertySchema.people(),
|
|
399
|
+
|
|
400
|
+
# Special (2026-03-11)
|
|
401
|
+
"Action": PropertySchema.button(), # automation trigger
|
|
402
|
+
"Location": PropertySchema.location(), # geographic location
|
|
403
|
+
"LastVisited": PropertySchema.last_visited_time(), # read-only
|
|
404
|
+
|
|
405
|
+
# Computed
|
|
406
|
+
"Formula": PropertySchema.formula("prop('Score') * 2"),
|
|
407
|
+
"UniqueID": PropertySchema.unique_id(prefix="ITEM"),
|
|
408
|
+
"Related": PropertySchema.relation("other-database-id"),
|
|
409
|
+
"Rollup": PropertySchema.rollup("Related", "Count", "count"),
|
|
410
|
+
# ID-based rollup (stable against column renames)
|
|
411
|
+
"RollupByID": PropertySchema.rollup(
|
|
412
|
+
"Related", "Count", "sum",
|
|
413
|
+
relation_property_id="rel-id",
|
|
414
|
+
rollup_property_id="prop-id",
|
|
415
|
+
),
|
|
416
|
+
# Verification (wiki databases only)
|
|
417
|
+
"Verified": PropertySchema.verification(),
|
|
418
|
+
}
|
|
419
|
+
```
|
|
420
|
+
|
|
308
421
|
## Error handling
|
|
309
422
|
|
|
310
423
|
```python
|
|
@@ -9,10 +9,36 @@
|
|
|
9
9
|
|
|
10
10
|
> Python client for the Notion API — easy to use, 1-to-1 API mapping, AI/MCP friendly
|
|
11
11
|
|
|
12
|
+
**Notion API version supported: `2026-03-11`**
|
|
13
|
+
|
|
14
|
+
## What's new in 2.0
|
|
15
|
+
|
|
16
|
+
| Feature | Description |
|
|
17
|
+
|---|---|
|
|
18
|
+
| `client.pages.retrieve_markdown()` | Retrieve a page as enhanced Markdown (`GET /pages/{id}/markdown`) |
|
|
19
|
+
| `client.pages.update_markdown()` | Replace page content with Markdown (`PATCH /pages/{id}/markdown`) |
|
|
20
|
+
| `client.pages.append_markdown()` | Append Markdown to the bottom of a page (`PATCH /pages/{id}/markdown`) |
|
|
21
|
+
| `client.pages.create(timezone=...)` | IANA timezone for template variables (`@now`, `@today`) |
|
|
22
|
+
| `client.blocks.append_children(position=...)` | Insert blocks at `start`, `end`, or `after_block` |
|
|
23
|
+
| `client.databases.query(in_trash=...)` | Filter trashed / non-trashed rows |
|
|
24
|
+
| `client.databases.update(is_inline=..., in_trash=..., is_locked=...)` | Toggle inline layout, trash, and lock state |
|
|
25
|
+
| `client.databases.create(initial_data_source=...)` | Pre-populate a database from a data source on creation |
|
|
26
|
+
| `PropertySchema.button()` | Automation button column |
|
|
27
|
+
| `PropertySchema.location()` | Geographic location column |
|
|
28
|
+
| `PropertySchema.last_visited_time()` | Last visited time column (read-only) |
|
|
29
|
+
| `PropertySchema.rollup(relation_property_id=..., rollup_property_id=...)` | ID-based rollup lookup params |
|
|
30
|
+
| `PropertySchema.verification()` | Wiki page verification column |
|
|
31
|
+
| `PropertyValue.verification()` | Set wiki page verification state |
|
|
32
|
+
| `BlockContent.tab()` / `tab_group()` | Tab layout blocks |
|
|
33
|
+
| `Filter.created_by()` / `last_edited_by()` | Filter by creator or last editor |
|
|
34
|
+
| `Filter.formula(name, value_type)` | Filter on formula property results |
|
|
35
|
+
| `Filter.rollup(name, aggregate, value_type)` | Filter on rollup aggregates |
|
|
36
|
+
| `Filter.verification()` | Filter on wiki verification state |
|
|
37
|
+
|
|
12
38
|
## Install
|
|
13
39
|
|
|
14
40
|
```bash
|
|
15
|
-
pip install notion-database==2.0.
|
|
41
|
+
pip install notion-database==2.0.0rc1
|
|
16
42
|
```
|
|
17
43
|
|
|
18
44
|
## Quick start
|
|
@@ -74,10 +100,12 @@ results = client.databases.query(
|
|
|
74
100
|
# Auto-paginate (returns all pages at once)
|
|
75
101
|
all_pages = client.databases.query_all("database-id")
|
|
76
102
|
|
|
77
|
-
# Update schema
|
|
103
|
+
# Update schema — rename, lock, and set inline layout
|
|
78
104
|
client.databases.update(
|
|
79
105
|
"database-id",
|
|
80
106
|
title=[RichText.text("Renamed DB")],
|
|
107
|
+
is_inline=False, # full-page, not inline
|
|
108
|
+
is_locked=True, # prevent edits without unlocking
|
|
81
109
|
)
|
|
82
110
|
```
|
|
83
111
|
|
|
@@ -122,7 +150,7 @@ client.pages.archive("page-id", archived=False)
|
|
|
122
150
|
## Blocks
|
|
123
151
|
|
|
124
152
|
```python
|
|
125
|
-
# Append content to a page
|
|
153
|
+
# Append content to a page (inserted at end by default)
|
|
126
154
|
client.blocks.append_children(
|
|
127
155
|
"page-id",
|
|
128
156
|
children=[
|
|
@@ -143,9 +171,23 @@ client.blocks.append_children(
|
|
|
143
171
|
[BlockContent.paragraph("Left column")],
|
|
144
172
|
[BlockContent.paragraph("Right column")],
|
|
145
173
|
]),
|
|
174
|
+
# Tab layout (Notion-Version: 2026-03-11)
|
|
175
|
+
BlockContent.tab_group([
|
|
176
|
+
BlockContent.tab("Overview", [BlockContent.paragraph("Overview content")]),
|
|
177
|
+
BlockContent.tab("Details", [BlockContent.paragraph("Details content")]),
|
|
178
|
+
]),
|
|
146
179
|
],
|
|
147
180
|
)
|
|
148
181
|
|
|
182
|
+
# Insert at a specific position (Notion-Version: 2026-03-11)
|
|
183
|
+
client.blocks.append_children("page-id", children=[
|
|
184
|
+
BlockContent.paragraph("Prepended to top"),
|
|
185
|
+
], position={"type": "start"})
|
|
186
|
+
|
|
187
|
+
client.blocks.append_children("page-id", children=[
|
|
188
|
+
BlockContent.paragraph("After a specific block"),
|
|
189
|
+
], position={"type": "after_block", "after_block": {"id": "block-id"}})
|
|
190
|
+
|
|
149
191
|
# Retrieve children (single page)
|
|
150
192
|
response = client.blocks.retrieve_children("page-id")
|
|
151
193
|
blocks = response["results"]
|
|
@@ -225,10 +267,26 @@ Filter.date("Due").before("2025-01-01")
|
|
|
225
267
|
Filter.date("Due").past_week()
|
|
226
268
|
Filter.date("Due").next_month()
|
|
227
269
|
|
|
228
|
-
#
|
|
270
|
+
# People-type columns
|
|
271
|
+
Filter.people("Assignee").contains("user-id")
|
|
272
|
+
Filter.created_by("Created By").contains("user-id")
|
|
273
|
+
Filter.last_edited_by("Last Edited By").does_not_contain("user-id")
|
|
274
|
+
|
|
275
|
+
# Timestamp columns
|
|
229
276
|
Filter.created_time().after("2024-01-01")
|
|
230
277
|
Filter.last_edited_time().past_week()
|
|
231
278
|
|
|
279
|
+
# Formula (value_type: "string" | "number" | "checkbox" | "date")
|
|
280
|
+
Filter.formula("Computed", "string").equals("ok")
|
|
281
|
+
Filter.formula("Score", "number").greater_than(50)
|
|
282
|
+
|
|
283
|
+
# Rollup (aggregate: "any" | "every" | "none" | "number"; value_type: property type)
|
|
284
|
+
Filter.rollup("Tasks", "any", "number").greater_than(0)
|
|
285
|
+
Filter.rollup("Tags", "every", "rich_text").contains("urgent")
|
|
286
|
+
|
|
287
|
+
# Verification (wiki pages)
|
|
288
|
+
Filter.verification("Verified").equals("verified")
|
|
289
|
+
|
|
232
290
|
# Compound
|
|
233
291
|
Filter.and_([
|
|
234
292
|
Filter.select("Status").equals("Active"),
|
|
@@ -248,7 +306,7 @@ Filter.and_([
|
|
|
248
306
|
]),
|
|
249
307
|
])
|
|
250
308
|
|
|
251
|
-
# Raw (escape hatch
|
|
309
|
+
# Raw (escape hatch)
|
|
252
310
|
Filter.raw({"property": "Formula", "formula": {"string": {"equals": "ok"}}})
|
|
253
311
|
```
|
|
254
312
|
|
|
@@ -282,6 +340,61 @@ RichText.mention_date("2024-01-01", end="2024-01-31")
|
|
|
282
340
|
RichText.equation("E=mc^2")
|
|
283
341
|
```
|
|
284
342
|
|
|
343
|
+
## PropertySchema reference
|
|
344
|
+
|
|
345
|
+
```python
|
|
346
|
+
from notion_database import PropertySchema
|
|
347
|
+
|
|
348
|
+
{
|
|
349
|
+
# Text
|
|
350
|
+
"Name": PropertySchema.title(),
|
|
351
|
+
"Notes": PropertySchema.rich_text(),
|
|
352
|
+
"Website": PropertySchema.url(),
|
|
353
|
+
"Email": PropertySchema.email(),
|
|
354
|
+
"Phone": PropertySchema.phone_number(),
|
|
355
|
+
|
|
356
|
+
# Numeric
|
|
357
|
+
"Score": PropertySchema.number("number"),
|
|
358
|
+
"Price": PropertySchema.number("dollar"),
|
|
359
|
+
|
|
360
|
+
# Selection
|
|
361
|
+
"Category": PropertySchema.select([{"name": "A", "color": "green"}]),
|
|
362
|
+
"Tags": PropertySchema.multi_select(),
|
|
363
|
+
"Status": PropertySchema.status(),
|
|
364
|
+
|
|
365
|
+
# Date / time (read-only system columns)
|
|
366
|
+
"Due": PropertySchema.date(),
|
|
367
|
+
"Created": PropertySchema.created_time(),
|
|
368
|
+
"CreatedBy": PropertySchema.created_by(),
|
|
369
|
+
"LastEdited": PropertySchema.last_edited_time(),
|
|
370
|
+
"LastEditedBy": PropertySchema.last_edited_by(),
|
|
371
|
+
|
|
372
|
+
# Other
|
|
373
|
+
"Done": PropertySchema.checkbox(),
|
|
374
|
+
"Files": PropertySchema.files(),
|
|
375
|
+
"People": PropertySchema.people(),
|
|
376
|
+
|
|
377
|
+
# Special (2026-03-11)
|
|
378
|
+
"Action": PropertySchema.button(), # automation trigger
|
|
379
|
+
"Location": PropertySchema.location(), # geographic location
|
|
380
|
+
"LastVisited": PropertySchema.last_visited_time(), # read-only
|
|
381
|
+
|
|
382
|
+
# Computed
|
|
383
|
+
"Formula": PropertySchema.formula("prop('Score') * 2"),
|
|
384
|
+
"UniqueID": PropertySchema.unique_id(prefix="ITEM"),
|
|
385
|
+
"Related": PropertySchema.relation("other-database-id"),
|
|
386
|
+
"Rollup": PropertySchema.rollup("Related", "Count", "count"),
|
|
387
|
+
# ID-based rollup (stable against column renames)
|
|
388
|
+
"RollupByID": PropertySchema.rollup(
|
|
389
|
+
"Related", "Count", "sum",
|
|
390
|
+
relation_property_id="rel-id",
|
|
391
|
+
rollup_property_id="prop-id",
|
|
392
|
+
),
|
|
393
|
+
# Verification (wiki databases only)
|
|
394
|
+
"Verified": PropertySchema.verification(),
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
285
398
|
## Error handling
|
|
286
399
|
|
|
287
400
|
```python
|
|
@@ -42,8 +42,8 @@ from notion_database.models.properties import PropertySchema, PropertyValue
|
|
|
42
42
|
from notion_database.models.rich_text import RichText
|
|
43
43
|
from notion_database.models.sorts import Sort
|
|
44
44
|
|
|
45
|
-
NOTION_VERSION = "
|
|
46
|
-
__version__ = "2.0.
|
|
45
|
+
NOTION_VERSION = "2026-03-11"
|
|
46
|
+
__version__ = "2.0.0rc1"
|
|
47
47
|
|
|
48
48
|
__all__ = [
|
|
49
49
|
# Client
|
|
@@ -87,20 +87,39 @@ class BlocksAPI:
|
|
|
87
87
|
# PATCH /blocks/{block_id}/children
|
|
88
88
|
# ------------------------------------------------------------------
|
|
89
89
|
|
|
90
|
-
def append_children(
|
|
90
|
+
def append_children(
|
|
91
|
+
self,
|
|
92
|
+
block_id: str,
|
|
93
|
+
children: List[Dict],
|
|
94
|
+
*,
|
|
95
|
+
position: Optional[Dict] = None,
|
|
96
|
+
) -> Dict:
|
|
91
97
|
"""Append new block children to a block or page.
|
|
92
98
|
|
|
93
99
|
Args:
|
|
94
100
|
block_id: The parent block or page ID to append to.
|
|
95
101
|
children: List of block objects to append. Build with
|
|
96
102
|
:class:`~notion_database.models.blocks.BlockContent`.
|
|
103
|
+
position: Optional placement object (requires
|
|
104
|
+
``Notion-Version: 2026-03-11``). Controls where the new
|
|
105
|
+
blocks are inserted relative to existing children.
|
|
106
|
+
Three forms are supported:
|
|
107
|
+
|
|
108
|
+
* ``{"type": "end"}`` – append after the last child
|
|
109
|
+
(default behaviour when omitted).
|
|
110
|
+
* ``{"type": "start"}`` – prepend before the first child.
|
|
111
|
+
* ``{"type": "after_block", "after_block": {"id": "<block_id>"}}``
|
|
112
|
+
– insert immediately after the specified sibling block.
|
|
97
113
|
|
|
98
114
|
Returns:
|
|
99
115
|
Notion list object containing the newly appended block objects.
|
|
100
116
|
|
|
101
117
|
Reference: https://developers.notion.com/reference/patch-block-children
|
|
102
118
|
"""
|
|
103
|
-
|
|
119
|
+
body: Dict[str, Any] = {"children": children}
|
|
120
|
+
if position is not None:
|
|
121
|
+
body["position"] = position
|
|
122
|
+
return self._http.patch(f"/blocks/{block_id}/children", body)
|
|
104
123
|
|
|
105
124
|
# ------------------------------------------------------------------
|
|
106
125
|
# PATCH /blocks/{block_id}
|
|
@@ -48,6 +48,7 @@ class DatabasesAPI:
|
|
|
48
48
|
start_cursor: Optional[str] = None,
|
|
49
49
|
page_size: int = 100,
|
|
50
50
|
filter_properties: Optional[List[str]] = None,
|
|
51
|
+
in_trash: Optional[bool] = None,
|
|
51
52
|
) -> Dict:
|
|
52
53
|
"""Query a database and return a page of results.
|
|
53
54
|
|
|
@@ -61,6 +62,8 @@ class DatabasesAPI:
|
|
|
61
62
|
page_size: Number of results per page (1-100). Defaults to 100.
|
|
62
63
|
filter_properties: List of property names/IDs to include in the
|
|
63
64
|
response page objects. Reduces response payload size.
|
|
65
|
+
in_trash: When ``True``, only return trashed pages. When ``False``,
|
|
66
|
+
only return non-trashed pages. Omit to return all.
|
|
64
67
|
|
|
65
68
|
Returns:
|
|
66
69
|
Notion list object with ``results``, ``has_more``, and
|
|
@@ -77,7 +80,18 @@ class DatabasesAPI:
|
|
|
77
80
|
body["start_cursor"] = start_cursor
|
|
78
81
|
if filter_properties is not None:
|
|
79
82
|
body["filter_properties"] = filter_properties
|
|
80
|
-
|
|
83
|
+
if in_trash is not None:
|
|
84
|
+
body["in_trash"] = in_trash
|
|
85
|
+
# In Notion API 2026-03-11 the data_source object may use a different
|
|
86
|
+
# query path. Try /databases/{id}/query first; if the API rejects the
|
|
87
|
+
# URL fall back to /data_sources/{id}/query.
|
|
88
|
+
from notion_database.exceptions import NotionValidationError
|
|
89
|
+
try:
|
|
90
|
+
return self._http.post(f"/databases/{database_id}/query", body)
|
|
91
|
+
except NotionValidationError as exc:
|
|
92
|
+
if exc.code == "invalid_request_url":
|
|
93
|
+
return self._http.post(f"/data_sources/{database_id}/query", body)
|
|
94
|
+
raise
|
|
81
95
|
|
|
82
96
|
def query_all(
|
|
83
97
|
self,
|
|
@@ -86,6 +100,7 @@ class DatabasesAPI:
|
|
|
86
100
|
filter: Optional[Dict] = None,
|
|
87
101
|
sorts: Optional[List[Dict]] = None,
|
|
88
102
|
filter_properties: Optional[List[str]] = None,
|
|
103
|
+
in_trash: Optional[bool] = None,
|
|
89
104
|
) -> List[Dict]:
|
|
90
105
|
"""Query a database and automatically paginate to return **all** pages.
|
|
91
106
|
|
|
@@ -94,6 +109,7 @@ class DatabasesAPI:
|
|
|
94
109
|
filter: A filter object.
|
|
95
110
|
sorts: A list of sort objects.
|
|
96
111
|
filter_properties: Property names/IDs to include in page objects.
|
|
112
|
+
in_trash: When ``True``, only return trashed pages.
|
|
97
113
|
|
|
98
114
|
Returns:
|
|
99
115
|
A flat list of all matching Notion page objects.
|
|
@@ -107,6 +123,7 @@ class DatabasesAPI:
|
|
|
107
123
|
sorts=sorts,
|
|
108
124
|
start_cursor=cursor,
|
|
109
125
|
filter_properties=filter_properties,
|
|
126
|
+
in_trash=in_trash,
|
|
110
127
|
)
|
|
111
128
|
pages.extend(response.get("results", []))
|
|
112
129
|
if not response.get("has_more"):
|
|
@@ -128,6 +145,7 @@ class DatabasesAPI:
|
|
|
128
145
|
cover: Optional[Dict] = None,
|
|
129
146
|
is_inline: bool = False,
|
|
130
147
|
description: Optional[List[Dict]] = None,
|
|
148
|
+
initial_data_source: Optional[Dict] = None,
|
|
131
149
|
) -> Dict:
|
|
132
150
|
"""Create a new database as a child of a page.
|
|
133
151
|
|
|
@@ -143,6 +161,9 @@ class DatabasesAPI:
|
|
|
143
161
|
cover: Cover object. Use :class:`~notion_database.models.icons.Cover`.
|
|
144
162
|
is_inline: Whether the database appears inline on its parent page.
|
|
145
163
|
description: Rich-text array for the database description.
|
|
164
|
+
initial_data_source: Optional data source configuration for
|
|
165
|
+
pre-populating the database with data on creation
|
|
166
|
+
(Notion-Version: 2026-03-11).
|
|
146
167
|
|
|
147
168
|
Returns:
|
|
148
169
|
Newly created Notion database object.
|
|
@@ -161,6 +182,8 @@ class DatabasesAPI:
|
|
|
161
182
|
body["cover"] = cover
|
|
162
183
|
if description is not None:
|
|
163
184
|
body["description"] = description
|
|
185
|
+
if initial_data_source is not None:
|
|
186
|
+
body["initial_data_source"] = initial_data_source
|
|
164
187
|
return self._http.post("/databases", body)
|
|
165
188
|
|
|
166
189
|
# ------------------------------------------------------------------
|
|
@@ -176,6 +199,9 @@ class DatabasesAPI:
|
|
|
176
199
|
properties: Optional[Dict[str, Any]] = None,
|
|
177
200
|
icon: Optional[Any] = None,
|
|
178
201
|
cover: Optional[Any] = None,
|
|
202
|
+
is_inline: Optional[bool] = None,
|
|
203
|
+
in_trash: Optional[bool] = None,
|
|
204
|
+
is_locked: Optional[bool] = None,
|
|
179
205
|
) -> Dict:
|
|
180
206
|
"""Update an existing database.
|
|
181
207
|
|
|
@@ -189,6 +215,11 @@ class DatabasesAPI:
|
|
|
189
215
|
to remove that property from the schema.
|
|
190
216
|
icon: New icon object, or ``None`` to remove.
|
|
191
217
|
cover: New cover object, or ``None`` to remove.
|
|
218
|
+
is_inline: Whether the database should appear inline on its parent
|
|
219
|
+
page.
|
|
220
|
+
in_trash: Set to ``True`` to move the database to trash.
|
|
221
|
+
is_locked: Set to ``True`` to lock the database (prevents edits
|
|
222
|
+
without unlocking).
|
|
192
223
|
|
|
193
224
|
Returns:
|
|
194
225
|
Updated Notion database object.
|
|
@@ -206,4 +237,10 @@ class DatabasesAPI:
|
|
|
206
237
|
body["icon"] = icon
|
|
207
238
|
if cover is not None:
|
|
208
239
|
body["cover"] = cover
|
|
240
|
+
if is_inline is not None:
|
|
241
|
+
body["is_inline"] = is_inline
|
|
242
|
+
if in_trash is not None:
|
|
243
|
+
body["in_trash"] = in_trash
|
|
244
|
+
if is_locked is not None:
|
|
245
|
+
body["is_locked"] = is_locked
|
|
209
246
|
return self._http.patch(f"/databases/{database_id}", body)
|