You’ve posted this question to the API Category, but this doesn’t sound like you’re using the API because the API always returns the IDs (as opposed to the display names). If you are using the API, what programming language are you using?
Regardless, here’s two ways to get the Record IDs of related fields. Assuming we have a Products table and a Vendors table:
Using the Airtable app
In the Vendors table, create a Formula field that simply displays its own RECORD_ID()
In the Products table, create a Linked Record field that links to Vendors.
In the products table, create a Lookup field that references the field created in step 1.
Using the Airtable api
Make a request to fetch a record from the Products table
Using the record IDs from the Vendors field, create a new request for the Vendor table with a filterByFormula that looks something like this OR(RECORD_ID() = 'recXXXXXXXXXXXXXX',RECORD_ID() = 'recXXXXXXXXXXXXXX') or this SEARCH(RECORD_ID(), "recXXXXXXXXXXXXXX,recXXXXXXXXXXXXXX")