Copy of Snippet "Airtable data extracter"

UPDATE: Check out our new lightweight spreadsheet "Data Blaze". You can easily write to and read data from Data Blaze into your existing snippets. We support one-click import of Airtable data into Data Blaze. Check out this guide to get started.


Fetch data from multiple Airtable tables

This snippet fetches specific data from a single record in an Airtable base.
You can build other snippets that, for example, fetch the same column data from multiple records (using a for loop).
Theoretically, it is possible to build on top of any data that you can extract from Airtable; see this page for examples on what data you can extract.

Currently, we ask for base value as form input and use it the API query. If you want to use a fixed base, you can change the url in the urlload command below. Currently, it is importing from https://api.airtable.com/v0/\{=base\}/VWB/\{=recordid\}. In place of \{=base\} you can put in the exact base Id, for example, https://api.airtable.com/v0/appW0YBv9zvXFQcO6/VWB/\{=recordid\}.

Note that this is a connected snippet! (documentation) You will be prompted to give special permissions for this folder, so you may want to keep a single separate folder for all your connected snippets in your Text Blaze Dashboard.

{note}{formtext: name=apikey} {formtext: name=base} {formtext: name=recordid}{endnote}
{if: apikey <> "" and recordid <> "" and base <> ""}{urlload: https://api.airtable.com/v0/{=base}/VWB/{=recordid}; method=GET; done=(res) -> ["response":catch(fromJSON(res), "???")]; headers=Authorization:Bearer {=apikey}}
Data received
All keys in response: {=keys(response)}
All keys in response.fields: {=keys(response.fields)}
Specific data from the given record
{agent=response.fields["Our Agent"][1]}
Our agent: {=agent}
Property Address: {=response.fields["Property Address"]}
TC: {=response.fields["TC"]}
Buyer Full Name: {=response.fields["Buyer Full Name"]}
Resolving Agent data with a second query
Our Agent name is actually a unique pointer into the Agents table. We need to use a second urlload query to grab the actual name.
{urlload: https://api.airtable.com/v0/{=base}/Agents/{=agent}; method=GET; done=(res) -> ["agentresponse":catch(fromJSON(res), "???")]; headers=Authorization:Bearer {=apikey}}
Fields received: {=keys(agentresponse.fields)}
Our agent (corrected): {=agentresponse.fields["Agent Name"]}
{else}
Enter apikey, base and recordid to proceed

To get the apikey, generate it on your Airtable account page (keep it a secret)

If you have the record URL as: Sign in - Airtable, then base=appW0...Qc06, and recordid=rec...VtB.

For an interactive demo of Airtable's API, visit their API page and choose your base. On the left you should choose "VWB Table" and then "Fields", "List records" or "Retrieve a record". On the right you will see various outputs relevant to your base.
{endif}

5 Likes

This is awesome @Gaurang_Tandon! Love the API integration. Never realized we could do this :star_struck:

4 Likes

Holy Wow!

3 Likes

Newer version by Gaurang here: Copy of Snippet "Airtable record lister"

5 Likes