Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

How to use filterByFormula Api using javascript fetch() call

Topic Labels: Formulas
605 1
Showing results for 
Search instead for 
Did you mean: 

Hello Guys! I need some help here, I am using javascript fetch call to get values from airtable, I want Specific field Values using filterByFormula filter…
I want only those fields where field name {TaskDate} = CurrentDate and field name {FK_UserUsageID} = PK_UserUsageID…
I see many topics about filterByFormula but i can’t understand them because of the high level formulas using in them. I try code:

fetch(airtableURL + baseInfo + tblSchedule + apikey+"?filterByFormula=AND({TaskDate} = “+ CurrentDate +”,{FK_UserUsageID} = “+PK_UserUsageID+”)")

  .then(res => res.json())

  .then(res => {



but response is:

Object {
“error”: Object {
“message”: “Authentication required”,

I also use my apikey and all that needed. Please figure out my mistakes and tell me the solution.
Thanks in advance…

1 Reply 1

Hi @Usama_Khalid - in the API documentation for your base you will see an authentication section. From here it notes:

You can authenticate to the API by providing your API key in the HTTP authorization bearer token header. Alternatively, a slightly lower-security approach is to provide your API key with the api_key query parameter.

So you can do it directly in the URL, but it would take the form:

So, note that the api_key param is a query param, i.e. after the ?

It is not clear from your code, but it looks like the api_key is before the query param, so this could be the issue.

The error message is around the authorisation, not the filter by formula.