# airtable

A base's tables over Airtable's Web API, from the back end: records listed
page by page, written ten a request, the base's limit kept, and its changes
told by webhooks. The whole of it is [docs/airtable.md](../../docs/airtable.md).

```text
use "pkg:airtable/airtable.mote"     // records
use "pkg:airtable/webhooks.mote"     // a base's changes, told (takes airtable.mote)

let open = airtableAll(base, "Tasks", {formula: airtableEq("Status", "Open")}, 1000, "")?
airtableUpsert(base, "Leads", [{Email: e, Name: n}], ["Email"], true, "")?
fn airtableChanged(c: AirtableChanged): bool       // the program's hook
```

Settings: `AIRTABLE_TOKEN` (a secret); `AIRTABLE_RATE`, `AIRTABLE_WAIT`,
`AIRTABLE_API`.

| File | |
|---|---|
| `airtable.mote` | The calls and shapes, batches of ten, the base's pace and hold, formulas. |
| `webhooks.mote` | Webhooks made and kept, pings checked, payloads read once, refreshed. |
| `tests.mote` | Its tests: `use "pkg:airtable/tests.mote"`, then `mote test` (tests/svc_work/unit.mote). |

**Covered:** records listed (formula, view, sorts, fields, page size, by
field id, cell format) by offset; one got; made, changed, upserted
(`performUpsert`) and deleted ten a request, with typecast; fields read as
text, number, bool, list, files; formulas quoted; five requests a second per
base, a 429's thirty seconds held for every caller; webhooks for a table's
records, the MAC checked, payloads read by cursor and each change told once,
refreshed before they lapse.

**Left out on purpose:** comments, the metadata API (bases, tables, fields),
attachment uploads, `PUT` (replace), OAuth (each call takes a token).

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