How to get the row ID of a related row via API?

First I fetch a row from a table “grid-fotuW_1o6g” and get this response:

{
  "items": [
    {
      "id": "i-X7l9pHbAzj",
      "type": "row",
      "href": "...",
      "name": "2024-123",
      "index": 0,
      "createdAt": "2024-09-13T10:53:12.815Z",
      "updatedAt": "2024-09-13T11:40:20.037Z",
      "browserLink": "...",
      "values": {
        "c-GaQbI-DmMO": "2024-123",
        "c-xU7xx-ReR7": "company name",
        "c-jZmqD_VCQF": "2024-09-13T00:00:00.000+02:00",
        "c-nLwvTE8qaA": "finalized",
      }
    }
  ],
}

It’s column “c-xU7xx-ReR7” is a relation to another table row:

{
...
    {
      "id": "i-DFQ-LEo-tZ",
      "type": "row",
      "href": "...",
      "name": " company name",
      "index": 4,
      "createdAt": "2024-09-13T08:16:56.339Z",
      "updatedAt": "2024-09-13T08:16:56.339Z",
      "browserLink": "...",
      "values": {
        "c-V5CvRv4yJ4": "company name",
        "c-tCb7aR-AcN": "Matthias",
        "c-AvXKJXPPY6": "Client"
      }
    },
...
}

From the response of the first query to table I don’t see a reference to the related table row. Just the name “company name”, but I don’t want to query for that, because it may not be distinct. So how do I get the related row in a fail-safe way?

Hi @maflobra , the API should allow you to get that info.

You’ll need to include the query parameter valueFormat=rich when making the API call.

It will return cells in this format for lookups

// Lookup
  {
    "@context": "http://schema.org",
    "@type": "StructuredValue",
    "additionalType": "row",
    "name": "Row Name",
    "rowId": "i-123456789",
    "tableId": "grid-123456789",
    "tableUrl": "https://coda.io/d/_d123456789/grid-123456789",
    "url": "https://coda.io/d/_d123456789/grid-123456789#_r42",
  }

More details here: Coda API (v1) Reference Documentation

2 Likes

That’s it, thanks a lot!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.