Getting value of lookup field from API


#1

Hello! I’m relatively new to Airtable. I have a view that has columns that are lookups from other tables. When I pull the table data into a web app that I’m building, I get what looks to be random string references anywhere a lookup or linked value is. If anyone has thoughts on how I can grab the value of that field instead of the reference, I’d be super appreciative.

Here is an example of my code:
When I have the results returned to me, and I get a field value for a non linked or lookup column like this:

response.data.records[i].fields.Date

I get the date, as expected. But if I reference a linked or lookup column, like this (the Project column is linked to the projects table…):

response.data.records[i].fields.Project

I get something like this returned:

recNmHYjQBITjdJdb

rather than the string of the project’s name.

Any help or advice is super appreciated!


#2

You will need to make another request to retrieve the actual data.
In your case “recNmHYjQBITjdJdb” is the “id” of the record in the “Project” table

You will need to make a GET request to

https://api.airtable.com/v0/xxxxxxx/Project/recNmHYjQBITjdJdb

(where xxxxxxx is your base) to get the actual data (i.e. the project’s name)

If you check out the API Docs there will be a section called “Retrieve a record”
You will want to go over that


#3

Another approach would be to include a lookup field in your table that pulls in the ‘Name’ field of project. You’ll have 2 fields that show the project name now, but via the api the new field will be the actual project name and not the record id. You can just hide it in your table since its not needed other than for the api calls. This will save you an api call.