# Airtable
<!--
ref: @integrations/airtable
tags: [Airtable, API, data access, authentication, scraping]
triggers: [need to access Airtable data, working with shared views, retrieving data without authentication]
trigger_prompt: When you need to access Airtable data in different contexts, whether through a personal token for full access or via public links for shared views and bases.
category: integration
last_reviewed: 2026-05-18
complements: [@integrations/curly, @integrations/luma, @integrations/apify]
audience: [claude-code-user, agent-author, terminal-only]
version: 15
updated_at: 2026-10-24T21:18:28.562Z
-->
Access and manipulate Airtable data through various authentication modes and API endpoints.
> **Three access modes — pick the one that matches what you have:**
> 1. **PAT (Personal Access Token)** — you own or are a collaborator on the base. Full read/write via `api.airtable.com/v0`.
> 2. **Public shared view** — someone published an embed link (`airtable.com/{appId}/{viewId}/{shrId}`). Reads via the undocumented `airtable.com/v0.3/view/{shr}/readSharedViewData` endpoint, no auth.
> 3. **Public shared base** — someone published a whole-base link (`airtable.com/{appId}/{shrId}`, no view id). Reads via the undocumented `airtable.com/v0.3/application/{appId}/read` endpoint with the page's `accessPolicy` — full schema + every row of the included tables in one shot. No auth. See Pattern 5.
## Auth
### Mode 1: PAT — `curly init airtable`
```bash
curly init airtable # hidden prompt for the token → ~/.curly.yaml
```
`airtable` is a built-in service — host and bearer auth are preconfigured, so the token is all you supply. Setup flow and troubleshooting: [`@integrations/curly`](/@integrations/curly).
Create the PAT (`pat…`) at https://airtable.com/create/tokens. **Required scopes:**
| Scope | When you need it |
|---|---|
| `data.records:read` | Always |
| `data.records:write` | Creating/updating/deleting records |
| `schema.bases:read` | Reading field types, view ids, table ids |
| `schema.bases:write` | Renaming tables / adding fields (rare) |
| `webhook:manage` | Subscribing to record changes |
Tokens are also scoped to **specific bases** — pick them in the token-creation UI. A scope-perfect token still 404s on a base you didn't pick.
### Mode 2: Public shared view — no auth
The page at `airtable.com/{appId}/{viewId}/{shrId}` ships a signed `accessPolicy` token in its HTML (expires every ~14 days; the page rolls a fresh one on each load). Pull the HTML, extract `accessPolicy`, hit `v0.3/view/{shrId}/readSharedViewData` with it. See Pattern 3.
### Mode 3: Logged-in browser cookies (last-resort)
Almost all public shared bases work with Pattern 5 (no auth, just the accessPolicy). Only fall through to cookies when the share is genuinely private / org-locked. Symptom: the share URL itself returns `403`/`404` in incognito mode. Two options:
- **Playwright/Puppeteer locally** — extract Airtable cookies from Chrome the same way as `@integrations/luma`, open the share URL, wait for `[data-rowid]` (5-15s), scrape the DOM.
- **Ask the base owner for a PAT/collaborator slot** — official REST API is always cleanest when offered.
Apify's `apify/airtable-scraper` actor is **paid** ($5/mo free credit), and Pattern 5 supersedes it for public bases. Don't reach for Apify unless cookies are needed.
## Cheat Sheet
### Official REST API — `https://api.airtable.com/v0`
| Op | Call | Notes |
|----|------|-------|
| List records | `curly airtable /v0/{baseId}/{tableId}` | Paginated; up to 100 per page. |
| List with filter | `curly airtable "/v0/{baseId}/{tableId}?filterByFormula=…&maxRecords=100"` | URL-encode the formula. |
| Get one | `curly airtable /v0/{baseId}/{tableId}/{recordId}` | |
| Create | `curly airtable /v0/{baseId}/{tableId} -X POST -d '{"records":[{"fields":{…}}]}'` | Up to 10 records per call. |
| Update (partial) | `curly airtable /v0/{baseId}/{tableId} -X PATCH -d '{"records":[{"id":"rec…","fields":{…}}]}'` | Only listed fields change. |
| Replace (full) | `curly airtable /v0/{baseId}/{tableId} -X PUT -d '{"records":[…]}'` | Fields not listed are cleared. |
| Delete | `curly airtable /v0/{baseId}/{tableId}/{recordId} -X DELETE` | |
| Base schema | `curly airtable /v0/meta/bases/{baseId}/tables` | Table + field metadata. |
| List bases | `curly airtable /v0/meta/bases` | All bases the PAT can see. |
### Shared-view JSON (undocumented, no auth)
| Op | Call | Notes |
|----|------|-------|
| Read view | `GET https://airtable.com/v0.3/view/{shrId}/readSharedViewData?accessPolicy=…&stringifiedObjectParams=…&requestId=…` | Returns all rows + schema for one view. See Pattern 3. Use when the share URL has a view id (`airtable.com/{app}/{view}/{shr}`). |
| Read whole base | `GET https://airtable.com/v0.3/application/{appId}/read?accessPolicy=…` | Returns schema + every row of all included tables in one shot. See Pattern 5. Use when the share URL is base-level (`airtable.com/{app}/{shr}`). |
| Embed page | `https://airtable.com/embed/{shrId}` | Same data, prerendered HTML; sometimes parses easier. |
### IDs at a glance
| Prefix | Type | Example |
|---|---|---|
| `app…` | Base | `appXXXXXXXXXXXXXX` |
| `tbl…` | Table | `tblXXXXXXXXXXXXXX` |
| `viw…` | View | `viwXXXXXXXXXXXXXX` |
| `fld…` | Field | `fldXxXxXxXxXxXxXx` |
| `rec…` | Record | `recXxXxXxXxXxXxXx` |
| `shr…` | Share link | `shrXXXXXXXXXXXXXX` |
## Patterns
### 1. List all records from a table (with pagination)
```bash
BASE=appXXXXXXXXXXXXXX
TABLE=tblYYYYYYYYYYYYYY
OUT=records.json
offset=""; > "$OUT.tmp"
while :; do
body=$(curly airtable "/v0/$BASE/$TABLE?pageSize=100${offset:+&offset=$offset}")
jq -c '.records[]' <<<"$body" >> "$OUT.tmp"
offset=$(jq -r '.offset // empty' <<<"$body")
[ -z "$offset" ] && break
sleep 0.25 # rate limit: 5 req/s per base
done
jq -s '.' "$OUT.tmp" > "$OUT" && rm "$OUT.tmp"
echo "Saved $(jq length "$OUT") records"
```
### 2. Create + update with upsert-style merge
```bash
# Upsert by external key (e.g. "luma_url") — needs `performUpsert`:
curly airtable "/v0/$BASE/$TABLE" -X PATCH -d '{
"performUpsert": { "fieldsToMergeOn": ["luma_url"] },
"records": [
{ "fields": { "luma_url": "https://luma.com/abcd1234", "name": "Example Launch Night" } }
]
}'
```
`performUpsert` keys must be string-typed fields with unique values. If two existing records match, the call 422s.
### 3. Scrape a public shared *view*
```python
#!/usr/bin/env python3
"""Pull rows from a public Airtable share view (mode 2)."""
import json, re, sys, urllib.parse, urllib.request, uuid
SHARE_URL = sys.argv[1] # e.g. https://airtable.com/appXXX/viwYYY/shrZZZ
m = re.search(r'airtable\.com/(app[^/]+)/[^/]*/(shr[^/?#]+)', SHARE_URL)
if not m:
sys.exit(f"Not an Airtable share URL: {SHARE_URL}")
app_id, share_id = m.group(1), m.group(2)
# Step 1 — load the share page to (a) get a session cookie, (b) extract accessPolicy.
ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 Chrome/124.0 Safari/537.36'
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor())
opener.addheaders = [('User-Agent', ua)]
html = opener.open(SHARE_URL).read().decode()
idx = html.find('"accessPolicy":"')
assert idx >= 0, "no accessPolicy — is this really a public share?"
start = idx + len('"accessPolicy":"')
i, depth = start, 0
while i < len(html):
c = html[i]
if c == '\\': i += 2; continue
if c == '"' and depth == 0: break
if c == '{': depth += 1
elif c == '}': depth -= 1
i += 1
access_policy = html[start:i].replace('\\"', '"').replace('\\\\', '\\')
page_load_id = re.search(r'pageLoadId["\']\s*[:=]\s*["\']([^"\']+)', html).group(1)
hashed = re.search(r'"hashedShareId":"([^"]+)"', html).group(1)
# Step 2 — call readSharedViewData.
url = (f"https://airtable.com/v0.3/view/{share_id}/readSharedViewData"
f"?stringifiedObjectParams={urllib.parse.quote(json.dumps({'shouldUseUrlForFirstRecordLink': True}))}"
f"&requestId=req{uuid.uuid4().hex[:16]}"
f"&accessPolicy={urllib.parse.quote(access_policy)}")
req = urllib.request.Request(url, headers={
'User-Agent': ua,
'X-Airtable-Application-Id': app_id,
'X-Time-Zone': 'America/Los_Angeles',
'X-User-Locale': 'en',
'X-Airtable-Page-Load-Id': page_load_id,
'X-Airtable-Inter-Service-Client': 'webClient',
'X-Requested-With': 'XMLHttpRequest',
'Referer': SHARE_URL,
})
data = json.loads(opener.open(req).read())
json.dump(data, sys.stdout, indent=2)
```
Run: `python3 scrape-airtable-share.py 'https://airtable.com/appXXX/viwYYY/shrZZZ'`.
The response shape is `{data: {table: {columns: [...], rows: [...]}}}` — column ids in rows match the column ids in the schema (no friendly names; cross-reference).
### 5. Scrape a public shared *base* (no PAT, no view id)
This is the path for Kyosuke-style "here's my whole base" links — `airtable.com/{appId}/{shrId}`. The `v0.3/view/...` endpoint refuses, but `v0.3/application/{appId}/read` returns the full schema + every row of all included tables in one ~360 KB JSON.
**Updated 2026-10-03.** The old recipe (fetch the share HTML, extract the signed `accessPolicy`, call `v0.3/application/{appId}/read` with plain `fetch`) broke on 2026-10-03: the share page HTML no longer carries `accessPolicy`, and the `read` endpoint now answers in msgpack, so the old script gets HTTP 401. Do not use it.
**Working method: let a headless browser make the page's own `read` request, capture it, and replay it with msgpack turned off.** The page builds a valid signed request itself; you copy its URL and headers, set `allowMsgpackOfResult:false` inside `stringifiedObjectParams`, and re-issue it from inside the page context (so cookies and origin match). Needs Playwright (run under node or bun with a Chromium available; pass its path via `CHROMIUM_PATH` if not using Playwright's bundled one).
```js
// capture-read.mjs — node capture-read.mjs <share-url> [<share-url> ...] → raw.json
import { chromium } from "playwright";
import fs from "fs";
const urls = process.argv.slice(2); // https://airtable.com/{appId}/{shrId}
const browser = await chromium.launch({
headless: true,
executablePath: process.env.CHROMIUM_PATH || undefined,
});
const out = [];
for (const u of urls) {
const page = await browser.newPage();
let cap = null;
// 1) Capture the page's own whole-base read request (URL + headers).
page.on("request", (r) => {
if (!cap && /application\/app\w+\/read\?/.test(r.url()))
cap = { url: r.url(), headers: r.headers() };
});
await page.goto(u, { waitUntil: "domcontentloaded" });
for (let i = 0; i < 30 && !cap; i++) await page.waitForTimeout(500); // up to ~15s
if (!cap) { console.error("no read request captured:", u); await page.close(); continue; }
// 2) Replay it with msgpack disabled so the response is plain JSON.
const U = new URL(cap.url);
const sp = JSON.parse(U.searchParams.get("stringifiedObjectParams"));
sp.allowMsgpackOfResult = false;
U.searchParams.set("stringifiedObjectParams", JSON.stringify(sp));
const h = { ...cap.headers };
delete h["x-airtable-accept-msgpack"];
delete h["x-early-prefetch"];
const res = await page.evaluate(async ([url, headers]) => {
const r = await fetch(url, { headers, credentials: "include" });
return { status: r.status, text: await r.text() };
}, [U.toString(), h]);
console.error(u, res.status, res.text.length);
try { out.push({ url: u, data: JSON.parse(res.text).data }); } catch {}
await page.close();
}
fs.writeFileSync("raw.json", JSON.stringify(out));
await browser.close();
```
Then flatten `raw.json` (same response shape as before: `data.tableSchemas` + `data.tableDatas`):
```ts
// flatten.ts — bun flatten.ts (reads raw.json, prints JSONL grouped by table)
const raw = JSON.parse(await Bun.file("raw.json").text());
for (const { url, data } of raw) {
for (let i = 0; i < data.tableSchemas.length; i++) {
const ts = data.tableSchemas[i];
const td = data.tableDatas[i];
const cols = Object.fromEntries(ts.columns.map((c: any) => [c.id, c.name]));
const choices: Record<string, string> = {};
for (const c of ts.columns)
for (const [sel, ch] of Object.entries((c.typeOptions?.choices ?? {}) as any))
choices[sel] = (ch as any).name;
console.log(`## ${ts.name} (${(td?.rows ?? []).length} rows) <- ${url}`);
for (const r of td?.rows ?? []) {
const row: Record<string, any> = { _id: r.id };
for (const [cid, v] of Object.entries(r.cellValuesByColumnId ?? {}))
row[cols[cid] ?? cid] = Array.isArray(v) ? v.map((x) => choices[x as string] ?? x).join("; ") : v;
console.log(JSON.stringify(row));
}
}
}
```
Output is JSONL grouped by table. The shape gotchas below still apply, and the `accessPolicy` / `INVALID_MODEL_ID` notes elsewhere on this page describe the old HTML-extraction method (Pattern 3 view shares may still use it; re-verify before relying on it).
**Important shape gotchas** (will burn you if you skip them):
- The initial response always has `rowsById: {}` — the actual data is in `td.rows` (a list). The client builds `rowsById` from `rows` after load. Iterate `rows`, not `rowsById`.
- `tableDatas` only contains entries for tables included in the share — not every table in `tableSchemas`. A schema entry without a corresponding tableData means "schema-visible, data-private".
- Cell values for `multiSelect` and `singleSelect` columns are `selXXXX` choice ids, not display names. Map them via `typeOptions.choices` on the column.
#### When the share URL rotates each week (Substack-discovered bases)
Some publishers — e.g. **Kyosuke Togami's SF Bay events Substack** — ship a *new* `appXXX/shrYYY` URL in each weekly post. The base is throwaway; only the Substack post is stable. Caching the share URL means scraping last-week's stale base forever.
**Resolve the current week's base at scrape time** rather than hardcoding it:
```ts
// /tmp/resolve-substack-base.ts — find the latest base URL in a publisher's archive.
const SUBSTACK = Bun.argv[2]; // e.g. https://kyosuketogami.substack.com
// 1) latest post via the Substack archive JSON (clean, no HTML parsing)
const archive = await fetch(`${SUBSTACK}/api/v1/archive?sort=new&limit=1`,
{ headers: { "User-Agent": "Mozilla/5.0" } }).then(r => r.json());
const postUrl = archive[0].canonical_url;
// 2) all Airtable URLs in the post body
const html = await fetch(postUrl, { headers: { "User-Agent": "Mozilla/5.0" } }).then(r => r.text());
const urls = [...new Set(html.match(/https:\/\/airtable\.com\/app[A-Za-z0-9]+\/shr[A-Za-z0-9]+/g) ?? [])];
// 3) For multi-base publishers (e.g. SF + NY): scrape both, pick by location signal
// after the data lands. Locations are in the rows themselves — don't try to
// pick by URL pattern, the app/shr ids carry no regional info.
console.log(JSON.stringify({ postUrl, urls }, null, 2));
```
Then loop the scrape recipe over each returned URL; classify after the fact by counting `Location` strings that match your region (`/san francisco|sf|berkeley|palo alto|.../i` for SF; `/new york|brooklyn|nyc|manhattan/i` for NY).
**Gotcha:** the `appvOUAe9q2YYGCuV/shrr5Qb1YpMIc0ZUN` URL appears in *every* Kyosuke post — it's the publisher's standing index, not the week's events. Filter it out by static-list match, or just ignore base shares that have <30 rows.
### 6. Mirror a base into a local SQLite (for cheap querying)
```bash
# Pull schema + all rows; write to SQLite with one table per Airtable table.
# (Pseudocode — a sketch, not a tested script.)
python3 - <<'PY'
import sqlite3, requests, os
TOKEN = os.environ["AIRTABLE_TOKEN"]; BASE = "appXXX"
schema = requests.get(f"https://api.airtable.com/v0/meta/bases/{BASE}/tables",
headers={"Authorization": f"Bearer {TOKEN}"}).json()
con = sqlite3.connect(f"{BASE}.sqlite")
for t in schema["tables"]:
cols = ", ".join(f'"{f["name"]}" TEXT' for f in t["fields"])
con.execute(f'CREATE TABLE IF NOT EXISTS "{t["name"]}" (id TEXT PRIMARY KEY, {cols})')
# ...then paginate /v0/{BASE}/{t["id"]} and INSERT OR REPLACE
PY
```
## Gotchas
### ⚠️ `INVALID_MODEL_ID` from `v0.3/view/...` means it's a base share, not a view share
The view-data endpoint only accepts **view** share ids. A "shared base" link (`airtable.com/{appId}/{shrId}` — no view id in the path) returns:
```json
{"error":{"type":"INVALID_MODEL_ID","message":"Invalid modelId supplied"}}
```
Use Pattern 5 instead: hit `v0.3/application/{appId}/read` with the same accessPolicy. The whole-base data lives behind that endpoint.
### ⚠️ Empty `rowsById` is a trap — the actual rows live in the `rows` array
Both shared-base and shared-view responses contain `tableData` objects with **both**:
```json
{ "rows": [ {id, createdTime, cellValuesByColumnId}, … ],
"rowsById": {} }
```
`rowsById` is **always empty in the initial fetch** — it's filled in client-side from `rows`. If you key off `rowsById`, you'll think the table has zero rows. Always iterate `tableDatas[i].rows`. Same applies to `viewDatas[i].rowsById` vs `viewDatas[i].rowOrder` (use the latter for the visible-row order in a specific view).
### ⚠️ `accessPolicy` expires — refetch the page every run
The signed token's `expires` field is typically 1-14 days from the page-load. If your scraper caches it and re-uses it later, you'll get `401 ACCESS_POLICY_EXPIRED`. Always reload the share HTML at the start of each scrape; don't cache the policy.
### ⚠️ Rate limit: 5 requests/second per base, no header
Official API enforces **5 req/s per base** (not per token), returns `429 RATE_LIMIT_EXCEEDED` with a 30s lockout. No `X-RateLimit-*` headers. Sleep `0.25s` between calls — that's the safe rule. For larger backfills, `0.5s` and one base at a time.
### ⚠️ The `id`/`createdTime` shape lives outside `fields`
```json
{ "id": "recXXX", "createdTime": "2026-05-01T…", "fields": { "Name": "Jane", … } }
```
`id` and `createdTime` are top-level, *not* in `fields`. Easy bug: filtering on `fields.id` returns nothing.
### ⚠️ `filterByFormula` is finicky
Field names with spaces need braces: `{First Name}`. Strings use **double** quotes inside the formula. URL-encode the whole formula. Empty result on a "correct-looking" formula is almost always a missing brace.
```bash
# correct
curly airtable "/v0/$BASE/$TABLE?filterByFormula=$(python3 -c 'import urllib.parse; print(urllib.parse.quote("AND({Status} = \"Active\", {ARR} > 100000)"))')"
```
### ⚠️ View-filtered queries: pass `view=`, not `filterByFormula`
If you only want records that are visible in a specific Airtable view (with its built-in filters/sorts), pass `?view=viwXXX` — much faster than reproducing the filter as a formula, and respects the view's hidden-fields setting.
### ⚠️ Multiple-record-link fields return *arrays of record ids*, not names
```json
"Speakers": ["recAAA", "recBBB"]
```
To get names, fetch the linked records separately (or hit `/meta/bases/{baseId}/tables` to get the primary-field column and join client-side). There is no `expand` parameter.
### ⚠️ "Shared base" pages take 5-15s to settle in a real browser
If you fall back to Playwright on a base share, the initial DOM is empty — Airtable hydrates async after the bundle loads. Wait for a row selector (`[data-rowid]` or `.dataRow`) before scraping. 5s `waitForSelector` is a safe default.
---
*Related: `@integrations/linkedin` · `@protocol/protocol-api` · `@content/youtube/starter-story/platform-marketplace-app-ideas` · `@integrations/notion` · `@content/youtube/langchain/managed-deep-agents-deploying-mission-critical-agents-to-production`*
---
*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*
*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*