# notion

A workspace's databases and pages over Notion's HTTP API, from the back end:
rows queried and read page by page, made and changed, and a page's content
as Markdown both ways. The whole of it is [docs/notion.md](../../docs/notion.md).

```text
use "pkg:notion/notion.mote"     // the API (takes markdown.mote)

let rows = notionAll(source, {filter: notionWhere("Status", "status", "equals", "Doing")}, 500, "")?
let md = notionRead(page, "")?
notionCreate(source, {Name: notionTitle("A task")}, "## Notes\n\n- [ ] ask", "")?
```

Settings: `NOTION_TOKEN` (a secret); `NOTION_VERSION` (2025-09-03 unsaid),
`NOTION_RATE`, `NOTION_API`.

| File | |
|---|---|
| `notion.mote` | The calls, rows and their plain values, properties to write, filters and sorts, limits. |
| `markdown.mote` | Blocks from Markdown (on the syntax battery) and Markdown from blocks. |
| `tests.mote` | Its tests: `use "pkg:notion/tests.mote"`, then `mote test` (tests/svc_work/unit.mote). |

**Covered:** data sources queried with filters and sorts, by cursor; every
property kind read plain (title, rich text, number, select, multi-select,
status, date, checkbox, url, email, phone, people, relation, files, formula,
rollup, unique id, created and edited times and people); pages made in a
data source or a page, changed, trashed; a database's data sources and a
data source's properties; search; a page's content read every level down
as Markdown, written from Markdown a hundred blocks a request with deeper
nesting put in after, appended or replaced; the rate kept and 429s waited
out.

**Left out on purpose:** comments, users, a property's own endpoint (more
than 25 people or relations), a database's schema changed, file uploads,
moving pages, Notion's webhooks, OAuth (each call takes a token).

**Not yet run against Notion**: only against a stand-in
(`tests/all.sh real_svc_work`).
