11 different ways to GET and filter data from Airtable

Airtable is a handy resource to build a small database. It can work with many applications, and different types of data. In here we have listed 11 ways to retrieve data from your Airtable database, via API with the Webhook block.

Bear in mind that it's a freemium service, and has it's limitations: It cannot retrieve more than a 100 results. So is better to filter the data that you are most interested in using.

As we will see in the different methods, Airtable offers us a method called "filterbyformula" that allows us to create formulas that are conditions. Conditions that when are met, when are True, it returns us the items (rows) that match those conditions.

The API will return an array with every row, as a JSON object, like below:

How to save an Array of results from the Airtable API response to use in a Dynamic Data block

As you can see, we can store the main array with all the results like in the picture below:

Here is how you would TEST and Set up the Save response section to be able to select the key "records" (that contains the array of results) and save it in the variable @records:

1. Set the URL, method (GET), the parameters section (with the variable) and the Header with the Authentication

2. In the Test section, add a sample value for the variable you want to use

3. Press TEST

4. Select the Key "records"

5. Select a variable (in this example @records) where it will store the content of the Key "records"

And now we will have the array with all the results based on the filter stored in the @records variable. Later we can use this variable for example in a Dynamic Data block:

Below there is a list of 11 ways to build the URL and/or the "Send params" section to get data filtered from your Airtable.

1. Request data (no filter)

In case we want to pull all the first 100 "items", without any filter

https://api.airtable.com/v0/<app_id>/<nameofthebase>

2. One fixed filter

This is best used when we want to get content from one column (field) that matches completely (case sensitive and the whole string is equal).

In the example below the column (field) is "Type" and the string to match is "Chairs", in the base Furniture:

filterByFormula=SEARCH("Chairs",{Type})

https://api.airtable.com/v0/<app_id>/<nameofthebase>?filterByFormula=SEARCH("Chairs",{Type})

3. One user input filter

You should use this option if what you want is to filter based on the input or selection from the user that will be stored in a variable.

In the example below the column (field) is "Type" and the string to match is the landbot variable @type, in the base "Furniture":

filterByFormula=SEARCH("@type",{Type})

https://api.airtable.com/v0/<app_id>/<nameofthebase>?filterByFormula=SEARCH("@type",{Type})

4. More than one filter

We use AND if we need to match 2 (or more) conditions with specific values.

In this example we check for items that match the landbot variable @color with the column (field) in Airtable "Color" and the landbot variable @type with the column (field) "Type":

Bear in mind that if we use "White" in the color and "Chairs" for type, it WILL NOT match the example above, because is has to be a full match, and color is "White, Brown, Black" in that object.

In case you want a case for "contains", where you are checking if "White" is one of the texts in the cell, please check the next filter:

filterByFormula=AND({Color}='@color',{Type}='@type')

https://api.airtable.com/v0/<app_id>/<nameofthebase>?filterByFormula=AND({Color}='@color',{Type}='@type')

5. Search filter "contains" value in cell/column

If the cell for example has more than one value or contains more text, we want to check if a string (text) is contained for that field like in the example below:

Here we use FIND to check if the string "Brass" is in any of the items of the column (field) "Materials".

It will match both items in the picture above.

filterByFormula=FIND("Brass",{Materials})>0

https://api.airtable.com/v0/<app_id>/<nameofthebase>?filterByFormula=FIND("Brass",{Materials})>0

6. Search filter numeric value bigger than X

This is very handy if we need to check for specific values that are greater (>) or smaller (<) than a specified value.

In this example we check in the column (field) "sold" for items with a value greater than 30:

filterByFormula={sold}>"30"

https://api.airtable.com/v0/<app_id>/<nameofthebase>?filterByFormula={sold}>"30"

7. Search for 2 conditions (bigger and text)

This case is an example that checks numeric values at the same time that checks for a specific string in a column field.

Here the filter is looking for items sold less than 2 times and that their color could be red:

filterByFormula=AND({sold}<"2",FIND("Red",{Color})>0))

https://api.airtable.com/v0/<app_id>/<nameofthebase>?filterByFormula=AND({sold}<"2",FIND("Red",{Color})>0)

8. Search filter by more than X days from Today

This is a specific case that we might use to check for the difference of days comparing with Today. The best case scenario would be if you want to make sure there is a difference of days between today and the date contained in a cell.

In the example below we check in the column (field) "Fulfill" for items fulfilled more than 60 days ago:

filterByFormula=DATETIME_DIFF({Fulfill},TODAY(),'days')>-60

https://api.airtable.com/v0/<app_id>/<nameofthebase>?filterByFormula=DATETIME_DIFF({Fulfill},TODAY(),'days')>-60

9. Filter by dates

Just like with numbers, we can check for dates (greater or smaller) with filters. Bear in mind that the date has to be set with the YYYY-MM-DD format.

In the example we check for orders fulfilled after the 2019-10-17:

filterByFormula={Fulfill}>"2019-10-17"

https://api.airtable.com/v0/<app_id>/<nameofthebase>?filterByFormula={Fulfill}>"2019-10-17"

10. Search checked (box)

Checkboxes are handy for boolean values, we can verify if they are either checked (1) or not (0).

In the example we filter for items that in the column (field) were not checked (0):

filterByFormula={In stock}=0

https://api.airtable.com/v0/<app_id>/<nameofthebase>?filterByFormula={In stock}=0

11. Search this OR that

It is similar to AND, but in this case, only one of the conditions is met. Let's say we want to search either by name or email, then we will need to use OR.

In the formula below we are checking either if a product is not in stock or if theirs gross sales is greater than 0:

filterByFormula=OR({In Stock}=0,{Gross sales}>0)

https://api.airtable.com/v0/<app_id>/<nameofthebase>?filterByFormula=OR({In Stock}=0,{Gross sales}>0)

How to get URL (Airtable's App ID) and the Authorization (API Key)

First we need to go to the API documentation option in the Help section:

Then, once in the API documentation, click on the Authentication option:

How to get the App ID in Airtable to build the Webhook's URL

https://api.airtable.com/v0/<app_id>/<nameofthebase>

In the examples above we have been using the following url:

https://api.airtable.com/v0/appzYrKqRzqbYCGi9/Furniture

It consists of 2 parts:

  • The Base we are using is called Furniture, so the end of our url is : Furniture

  • The Base App Id is appzYrKqRzqbYCGi9

How to get the API Key to set up Webhook's Header (Authorization)

To get an Airtable API Key, repeat the same process to get to the API Documentation, but this time click on this option:

Then, under the line where you located the APP ID, you will see the API KEY just after "Authorization":

Copy from "Bearer" until the end of the text:

Make sure you copy the whole code, but not the quotation marks.


How did we do?


Powered by HelpDocs

Powered by HelpDocs