AirTable: Useful Tool for Managing App Content Remotely

Just throwing this out there as a public service announcement, as this has made my life a lot easier lately…

AirTable is a web-hosted “kinda-sorta” database with a really easy-to-use interface, a pretty decent REST API, and a free tier (with pretty reasonable upgrade pricing if you need it). I like to think of it as sort of a cross between a proper relational database and something like Google Sheets. If you’re the kind of person who doesn’t like to feel overwhelmed by tech-y nonsense, it’s a useful tool for organizing data.

I have a client who likes to manage his app’s content without requiring an app update. Previously, I allowed him to do this by using a farily large JSON file containing all the app’s content in a series of subtables that he can update at will. On launch, the app phones home to a server, checks that it’s running the latest content, and if not, downloads the new version (as well as any new audio/visual assets referenced).

This worked pretty well, but managing that JSON file got unwieldy, particularly for the non-tech-types who were helping manage his content. So I created a “curriculum builder” desktop app in Corona that put a visual front-end on things to make it easier for them to edit their content. That also worked, but schema changes during development required me to spend time revising the builder app, which became something of a pain. It also meant dealing with some of Corona’s less-friendly native input gotchas.

On a new project with that same client, I decided to try using AirTable.com as a replacement for that desktop app, so that my client can use AirTable’s GUI to make updates to the app’s content, including the adding of audio/visual assets, which are hosted by AirTable. At the time I wasn’t sure if it was going to work out, but…

I have to say I’m loving it. It’s a quick way for me to hand over content creation to my client without needing to manage too much overhead myself, and their API makes it real easy to grab those changes and put them into the app. The only gotcha I’ve dealt with so far is that their API caps you at 5 requests per second, and they limit responses to 100 records per request, so I recommend setting up a worker to convert the data into JSON on a schedule, and then host that JSON yourself so your app can just pull the pre-compiled JSON with no limits/restrictions - but other than that, it’s working like a dream for me. For example, it assigns unique identifiers to every record that I can use to keep things properly organized, but the client never needs to see those IDs or even know they exist - he can think visually, and I can trust that everything is properly mapped in tables.

I also thought I’d share a quick module that will allow you to pull down all the data from an AirTable ‘base’ and convert it into a lua table, with subtables for each table in the base. Note that this is very bare-bones: I’m using a heavily-modified version of it for my own implementation to allow more custom handling of the data, but if you’re interested, it’s a handy shortcut to getting started. You just need to plug in your base ID and your API key at the top of the module, and update the tables values to the names of the tables in your base (unfortunately there’s no way to pull a list of table names via the API). It also makes sure to space out the requests so you don’t run afoul of their rate limits. It’s 90% of what you’d need to build that middleman worker to generate JSON you can host yourself.

You can nab the module here as a gist: https://gist.github.com/schroederapps/87dd50b2f99f8e915723a16ce33ffba9

Usage of the module would look like this:

local airtable = require('airtable') local function my\_listener(data) -- do something with the returned Lua table end airtable.pull(my\_listener)

Anyways, that’s it. I just think that this is a tool that is going to save me tons of headaches, so I thought I’d share. If anybody else is using AirTable and has any cool tips, please keep the conversation going!

-Jason

This is awesome! I have a client already using Airtable, I’ll be replacing some of my current data flow with this module. Thanks!

Hi - Great module. Thanks for this. I am printing the data fine, but can’t seem figure out how to use the data. Usually I do something like:

for i = 1, #data do

 print(data[i].dataField

end

But nothing… 

Any advice?

David,

You’re going to have to dig into the module and your airtable spreadsheet(s) setup.  There is a lot to learn here and no generic how-to step-by-step process that fits all needs.

Thanks for the response. I’m received the data from the tables, but each sub table has a unique Id. I can’t seem to get around the Id to print the data (or a specific key pair from the data). I can if I know the id, but otherwise can’t.

So corona has decoded the Json, I’m just having trouble with printing say for example, all the first names from all the data records

all good - figured it out

Congrats.  That often happens to me after I post a question.  :) 

This is awesome! I have a client already using Airtable, I’ll be replacing some of my current data flow with this module. Thanks!

Hi - Great module. Thanks for this. I am printing the data fine, but can’t seem figure out how to use the data. Usually I do something like:

for i = 1, #data do

 print(data[i].dataField

end

But nothing… 

Any advice?

David,

You’re going to have to dig into the module and your airtable spreadsheet(s) setup.  There is a lot to learn here and no generic how-to step-by-step process that fits all needs.

Thanks for the response. I’m received the data from the tables, but each sub table has a unique Id. I can’t seem to get around the Id to print the data (or a specific key pair from the data). I can if I know the id, but otherwise can’t.

So corona has decoded the Json, I’m just having trouble with printing say for example, all the first names from all the data records

all good - figured it out

Congrats.  That often happens to me after I post a question.  :)