Help

Referencing Field IDs using the API for Code Maintainability

Topic Labels: API
4820 7
cancel
Showing results for 
Search instead for 
Did you mean: 
Mallory_Price
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi all,

I’ve read up in this forum on how to see the Field IDs for the fields in my table. However, I’m struggling with how to to actually use the API to reference those field IDs. Using Python, I’m able to grab the record through the API and convert the data to JSON. I then assign a field in the record to a variable:

json_variable = json_data['fields']['Name']

However, after trying some different variations of this, I can’t seem to figure out how to access the field ‘Name’ just by using its field ID. Can anyone help with this?

The motivation behind this is to avoid hard-coding Field Names so we can change them in Airtable without the program breaking.

Thank you!

7 Replies 7
Per_Carlen
7 - App Architect
7 - App Architect

Hi!

I got this from the Airtable support:

I’ve included an example of a POST request below (using a free app called Postman) where the field id is used instead of the field name.

image.png

However, we don’t make it easy to find out what the field ids are. You would need to go to a grid view that has the fields and toggle the developer window for your browser to view the HTML for the field headings. You will want to look for a value in the pattern of fldxxxxxxxxxxxxxx.

image.png

Could be useful for others to know that this appears to work for any underlying IDs - tables, views, and fields. I had a Zapier automation running JavaScript using the API to delete a record in Airtable, but when I changed the table name my automation broke.

I just replaced it with the table’s ID in the request URL and it worked great no matter what the name was. :+1:t2:

Tane_Martin
5 - Automation Enthusiast
5 - Automation Enthusiast

It looks like the example posted is specifically for writing to a record/field, which I now have working thanks to this post.

Anyone know how we use the field id to read data?

Stephanie_Werha
4 - Data Explorer
4 - Data Explorer

Is there a solution yet to using field IDs to read data?

Mikel_Barton
4 - Data Explorer
4 - Data Explorer

Bumping this thread. Would really like to be able to use field IDs to read data via API. Has Airtable support exposed this functionality yet?

Partyborn
6 - Interface Innovator
6 - Interface Innovator

This feature is available in the API docs. They are autogenrated and contain all ids:

What I do not know yet is how to force the output to only show the ids, not names.
Edit: the boolean returnFieldsByFieldId will do that.

Dmytro_Kovalenk
4 - Data Explorer
4 - Data Explorer

@Partyborn Thanks for the boolean field!

Documentation on this is non-existing!