How to get linked record data using the REST API?

I have a table/sheet that has a field that links to records in another table (parent/child).

When I use the REST API and do a HTTP GET (url, params, headers), and look at the response, the only thing I see in the field with the link is the AT record identifier like:

[ 'recPKTGm6EPiDoS6g' ]

No data from the linked record is present.

I have searched all over the response, and I do not see that there is enough information to use this AT record id to get the data of the record it refers to.

------------------------------------------------------------------------------------------------------------------------

In the UI, if I click on the field in the sheet, I get a popup that shows the full record (all data fields), and clicking on the down arrow next to the key at the top, I can see an option: “Copy Record URL”, and it looks like this:

https://airtable.com/tblPlziY7QNosBG3N/recPKTGm6EPiDoS6g

And so I see there is a uniform URL format for referencing a record with that URL.
https://airtable.com/<at_table_identifier>/<at_record_identifier>

------------------------------------------------------------------------------------------------------------------------

With the REST API, I want to have access to the AT table identifier in the response, and along with the record identifier that I get in the same response, I want to do another HTTP GET, and get that record (data), in JSON format to parse and use.

Even with the table identifier, (If I manually copied it, made a note of it, and put it in my code), I’m not seeing, that along with a record identifier, I can do a GET with the REST API, and get the data.

There is nothing in the Airtable REST API documentation that indicates that linked Record data can be obtained.

------------------------------------------------------------------------------------------------------------------------

Any help, actual working code would be appreciated.

I realize there may be a way to do this with the Node SDK, and I will give this a try next, but I am exploring for the moment how to HTTP GET the data, as we have a specific use case for constructing a URL that links to specific a record, and having that for our use case.

------------------------------------------------------------------------------------------------------------------------

If I copy the URL I get from the record, and paste into another browser tab, the data/pop up is there.

So therefore there must be a way to obtain this through GET, but I do not know what the headers or request would look like to do this, as the URL does not include: https://api.airtable.com, but rather just:

https://airtable.com/<at_table_identifier>/<at_record_identifier>

------------------------------------------------------------------------------------------------------------------------

How, with a first request, do I get the <at_table_identifier> in the first response, and use that to do another GET after constructing this URL?

Hi @Dev_Local - you don’t need the table identifier to get the linked record data. I’ve made a base with People and Departments tables:

The Department field is a linked record. Here’s a Python script that gets the People records and, for each ID in the department field, gets the matching Department record. You can then merge to two objects to get a combined object:

import json
import requests

get_url = 'https://api.airtable.com/v0/YOUR_BASE_ID/People'
get_headers = {
    'Authorization': 'Bearer YOUR_API_KEY'
    }

response = requests.get(get_url, headers=get_headers)
data = response.json()

# for each record in the people table
for i in data['records']:
    # get the department record ID
    dept_id = i['fields']['Department'][0]
    # now get the deprtment record
    dept_url = 'https://api.airtable.com/v0/YOUR_BASE_ID/Departments/' + dept_id
    dept_response = requests.get(dept_url, headers=get_headers).json()
    people = i['fields']
    dept = dept_response['fields']
    # make a department name key as the Name key conflicts with people['Name']
    dept['Department Name'] = dept.pop('Name')
    # merge the two objects
    people.update(dept)
    print(people)

You could implement a similar process in Node or other programming language.

JB