Welcome to the Airtable Community! If you're new here, check out our Getting Started area to get the most out of your community experience.

Filtering views in the API read

Topic Labels: API
5211 7
Showing results for 
Search instead for 
Did you mean: 

I am trying to understand the way to formulate either an API call that matches a filtered view on a table I have set up – a base that has date serving, name, venue name, address, zip code, time starting, time ending and cache. I have the filter by in the view of the table set to filter by a specific day and zip code to filter for the first three numbers of the zip code and of course this provides exactly the information I want.

My question is, how do I translate this view into an API call so that in a table with multiple entries I receive the information that translates to this more limited scope?

7 Replies 7

The Airtable API provides you with a neat parameter called “filterByFormula”…which you can pass as parameter along with you HTTP call.
You can set this parameter to the formulae you want to to filter your bases by.

Your formulae would look something like

AND(zipcode=“333”, date=“5/5/18”)

The formulae has to be URL encoded.

They also provide you with a parameter called “view” which you can pass along with your HTTP call.
You can set the view parameter to the name of the “filtered view” on your table you are intrested in

To clarify, would the view parameter honor the filtering already present in the Airtable view? IE, any records not showing in the view do not exist as far as the API is concerned?

Andrew, Thanks for replying to my question, I believe I have attempted this before and received this same INVALID_FILTER_BY_FORMULA result, if you look at the relevant part of my url could you advise me what’s wrong? url …Table%201?&filterByFormula=AND(zip+code=“296”,%20date+serving=“2018-04-30”)&

I would greatly appreciate it, needless to say the information to the left and right of the text is base number and api key and the + have been added to the zip code and date serving because of the text space.

You need the quotes, commas and equal sign to also be URL encoded…

It would look something like this.


Andrew I really am not sure what the issue is, to answer your first question, yes it would accept those exact parameters as filters and supplies the results in the view, I have tried both your url encoded filter by formula as well as the formula that I have marked as codepen from the codepen resource that airtable has provided, unfortunately something must be wrong as both times the api response is {
“error”: {
“message”: “The formula for filtering records is invalid: please check your formula text.”

This is your formula:

Codepen formula

I have absolutely no idea what is wrong, I am hitting the api, I am authorizing the query and the table and view and items are filterable by the parameters I am using.

So In case any one is following this thread the field name needs to be wrapped in curly’s, as an example: AND({dateserving}=“04/30/2018”, {zipcode}=“14131”) which will yield this url string filterByFormula=AND(%7Bdateserving%7D%3D%2204%2F30%2F2018%22%2C+%7Bzipcode%7D%3D%2214131%22) Hope anyone else ever struggling with this finds this helpful.