Help

Re: Record id showing instead of Value

2431 7
cancel
Showing results for 
Search instead for 
Did you mean: 
Craig_Robertson
4 - Data Explorer
4 - Data Explorer

Hello all,

I have been messing around with the API and PHP to try and display a list of records.

I have been sort of successful in retrieving records but when it is linked to another table it just shows the Record ID instead of the value from the other table. Anyway around this?

For instance in the code below $model is returned as the Record ID instead of the Model Name.

				if ( array_key_exists ( 'Model', $fields ) ) {
		
					echo '<h2>Model</h2>';
					echo '<ul>';
					foreach ( $fields[ 'Model' ] as $model ) {
						echo '<li>' . $model . '</li>';
					}		
					echo '</ul>';
		
				}	

Thanks.

18 Replies 18
Howie
7 - App Architect
7 - App Architect

Hello Craig, this is the intended behavior of the API right now–if you’d like to retrieve the record from the other table, you would make another request for that record. We may offer an option in the future for the API to “expand” that linked record and return all its cell values inline, rather than simply its record ID.

Thanks for the quick reply. Glad to know it wasn’t anything stupid I was doing at this end.

Is there a way to show the name instead of the Record ID?

To get the name of the linked record instead of just its id, you need to issue a subsequent API request, scoped to the other table:

$ curl  https://api.airtable.com/v0/<YOUR_BASE_ID>/<NAME_OF_OTHER_TABLE>/<RECORD_ID> \
-H "Authorization: Bearer YOUR_API_KEY"

You can find more documentation and example code for this in the “Retrieve a record” section of the API docs for the other table.

We realize this is inconvenient, so in the future, we plan on improving the API by adding support for retrieving all the linked record’s cell values (including its name), instead of just retrieving the id.

Hi Kennedy,

As another approach, you could create a formula that references the link field. The formula value will be returned in the API response and it will be the text version of the link.

Alex

Danny_Alvarez
5 - Automation Enthusiast
5 - Automation Enthusiast

Good to know that you’re expanding on retrieving linked records is in the roadmap.

I’m curious, is it possible to retrieve multiple records in on API call? If so, how would I make that call?

I think that at this time, this is the most elegant solution.
It exposes both the record ID and publicly viewed ‘Name’ of the linked table making it easier to reference in external app.
Very easy to maintain.

Pete

Andrew_Richards
4 - Data Explorer
4 - Data Explorer

+1 for denormalised queries

Having a option which would put all the linked information inline would be very useful. If you have a relatively complicated table, the amount of work you have to do to denormalise it is quite significant which limits its appeal for a quick solution for some applications.

Downloading via CSV is viable but not easily automated. Maybe you could add an API call which retrieves the CSV if the full JSON output is going to take a while

Andy

A kludge I’ve done : insert adjacent column to link column in the table. Define field in this column as a Formula. Set to value of field name of link column. For example:

“teacherActual_link” is name of field which is a link to the Instructors table. “teacherActual” is the name of field defined as Formula, with the “formula” defined as simply “={teacherActual_link}”. Saving this new column (field) will populate the table with the actual values of the link. Do the API query on the non-link field and the value will be returned, not a record ID.

Inelegant but it works for me now.

David_Lano
4 - Data Explorer
4 - Data Explorer

I’d also love to see the API expanded so it could reference and output the actual field name for a linked record. For now, I’ll use the Formula hack, but that does at a lot of extra work. I’m hoping to integrate Airtable extensively with our Klipfolio dashboard, so naturally a richer API would be much appreciated! :grinning_face_with_big_eyes:

Cristina_Grant
4 - Data Explorer
4 - Data Explorer

I saw this was posted back in 2016. Any news of expanding the API so that the linked records return all of its cell values inline? It would be quite useful!

Ben_Orozco
7 - App Architect
7 - App Architect

Something like http://jsonapi.org/ supports the includes parameter exactly to include nested relationships

Also, a GraphQL endpoint would achieve same thing more elegantly IMHO: API Idea: GraphQL endpoint

Hi! Has it been any progress in this? In my case it’s the most expected feature that would save plenty of extra queries

F_K
4 - Data Explorer
4 - Data Explorer

Same here. Any ideas?

F_K
4 - Data Explorer
4 - Data Explorer

I am using GraphQL to query the API, how do I re-query based on record Id?

Ambroise_Dhenai
8 - Airtable Astronomer
8 - Airtable Astronomer

Interested as well, using GraphQL underneath may be a viable solution and would bring lots of possibilities to the API!

return all its cell values inline, rather than simply its record ID
are there any updates on this matter?

its quite ironic to do relational database in airtable to validate records yet when you store them into another warehouse say snowflake. all you get are IDs…

now you have re-join the different tables just to get the desired result and that’s quite the resource just to re-join. that’s like doing twice the effort. :face_vomiting:

Andrew_Truong
4 - Data Explorer
4 - Data Explorer

this never happened, eh? seriously annoying where a CSV export of a view is miles faster than pulling via API.