Retrieving Table IDs through Coda API

I see that I can list all the tables in a doc through the API, but it returns table NAMES and I want table IDs. Is there a way to get the table IDs through the API?

Without seeing what code you are implementing to return the tables, I can’t really ascertain what the problem is.

if you use the endpoint{your doc id}/tables

you should receive a json object with an output like:

  items: [
      "id": "{TABLE ID}",
      "type": "table",
      "href": "{DOC ID}/tables/{TABLE ID}",
      "browserLink": "{DOC ID}#_tu{TABLE ID}",
      "name": "{TABLE NAME}",
      "parent": {
        "id": "canvas-{CANVAS ID}",
        "type": "section",
        "href": "{DOC ID}/sections/canvas-{CANVAS ID}",
        "browserLink": "{DOC ID}/_su...",
        "name": "{TABLE NAME}"

you should then be able to access it with a lookup of

Let me know if that helps you out


Hi, @Joshua_Upton, thank you for your reply. It solved my problem. My goal was to print a dataframe that lists the items in my doc, including the item type, name and ID. Below is the code in case others find it helpful.

import pandas as pd
import requests
import json

headers = {'Authorization': 'Bearer '+coda_api_key}

list_uri = f''+doc_id+'/tables/'
list_res = requests.get(list_uri, headers=headers).json()
list_item = list_res['items']

# extract_values
def extract_values(obj, key):
    """Pull all values of specified key from nested JSON. This came from this guy: """
    arr = []

    def extract(obj, arr, key):
        """Recursively search for values of key in JSON tree."""
        if isinstance(obj, dict):
            for k, v in obj.items():
                if isinstance(v, (dict, list)):
                    extract(v, arr, key)
                elif k == key:
        elif isinstance(obj, list):
            for item in obj:
                extract(item, arr, key)
        return arr

    results = extract(obj, arr, key)
    return results

def list_doc_items(item):
    table_types = extract_values(item,'type')
    table_names = extract_values(item,'name')
    table_ids = extract_values(item,'id')
    doc_items = pd.DataFrame({
            'type': table_types,
            'name': table_names,
            'id': table_ids
    return doc_items

doc_items = list_doc_items(list_item)