Here's a project demonstrating the basics of an Airtable API proxy using node.js and Express. Click here to see the source and remix for your own purposes.
Airtable's rate limit is five requests per second per base. Anything more than that and the API will lock down for thirty seconds. By implementing an API proxy, it's possible to cache common results for quick responses and enforce a rate limit for requests.
Click here for example output. Records are returned as a JSON dictionary, keyed with their Airtable record IDs. This facilitates stitching together relationship fields on the client.
Click here to see the source data.
Three files drive the proxy:
An API route,
/api/:table/list/:page, handles requests via
Simple, file-based caching.
Returns cached JSON, if it's not too stale. Use
cacheInterval to adjust this.
This is the meat of the project. It uses the Airtable node.js client to connect to a base and writes the results out as a JSON response.
tableRoutes maps between API paths and the names of tables in your Airtable base.
Base ID and Airtable API key are in 🗝.env.
For more on accessing Airtable via the API, see the interactive Airtable documentation.
Bottleneck handles rate limiting. The Airtable database interactions are handled using Bottleneck's