# Cache Airtable API Responses to Stay Under 5 Requests Per Second

> Airtable rate limits hit fast from Frontend / Web. Cache 300s on GET calls where the query string scopes the response.

- Canonical page: https://realcomposer.com/recipes/cache-airtable-avoid-rate-limits
- Client platform: Frontend / Web
- Upstream services: Airtable
- Category: Edge Caching & Rate Limits
- JSON version: https://realcomposer.com/recipes/cache-airtable-avoid-rate-limits.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=cache-airtable-avoid-rate-limits&via=agent

## Problem: Airtable rate limits from Frontend / Web traffic

Without edge caching, identical Airtable reads during a session still round-trip to the origin.

- HTTP 429 responses during launch traffic
- Surprise SaaS overages from duplicate reads
- Slower repeat views than necessary

## Solution steps

1. **Add vault secrets for this pipeline**: Create AIRTABLE_PAT vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

2. **Target the real upstream URL**: Use GET against https://api.airtable.com/v0/{{query.baseId}}/{{query.tableName}}?maxRecords=5. Allowed origins on the client token should match set cache ttl to 300s so repeat gets with the same query string hit caches.default.

3. **Call from Frontend / Web**: Allowed origins on the token should list every Frontend / Web host that calls this URL.

```
const res = await fetch('https://realcomposer.com/v1/workspace/cache-airtable-avoid-rate-limits', {
  headers: { Authorization: 'Bearer rc_live_your_token' }
});
```

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "Cache Airtable API Responses to Stay Under 5 Requests Per Second",
  "method": "GET",
  "cacheTtlSeconds": 300,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "airtable",
      "upstreamUrlTemplate": "https://api.airtable.com/v0/{{query.baseId}}/{{query.tableName}}?maxRecords=5",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.AIRTABLE_PAT}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "recordId",
        "sourcePath": "records.0.id",
        "type": "string",
        "sourceStep": "airtable"
      },
      {
        "targetPath": "fields",
        "sourcePath": "records.0.fields",
        "type": "object",
        "sourceStep": "airtable"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/cache-airtable-avoid-rate-limits" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_cache-ai",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "cache-airtable-avoid-rate-limits"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "recordId": "sample",
  "fields": "sample"
}
```

## FAQ

### What should Frontend / Web store instead of Airtable secrets?

Yes for cache-airtable-avoid-rate-limits. Ship only an rc_live_ client token in Frontend / Web; RealComposer injects AIRTABLE_PAT on https://api.airtable.com/v0/{{query.baseId}}/{{query.tableName}}?maxRecords=5.

### Will Anthropic or Linear prompt bodies be rewritten?

cache-airtable-avoid-rate-limits forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates.

### Can I restrict which domains call this pipeline?

Rotate vault secrets for cache-airtable-avoid-rate-limits anytime; clients keep the same rc_live_ token.
