Failed connection to grist with API and Python

Hi,
I’m trying to connect to grist with Python but I get this message:
‘requests.exceptions.HTTPError: not found: /api/docs/kz********sn/LucaPrimoDoc/p/3/tables/Table1/data’

The code is the following:

from grist_api import GristDocAPI
import os
SERVER = “https://docs.getgrist.com
DOC_ID = "kz***sn/LucaPrimoDoc/p/3"
api = GristDocAPI(DOC_ID, api_key='dda2
4087a’, server=SERVER)
data = api.fetch_table(‘Table1’)
print(data)

The doc ID should just be the kz********sn part.

It works, but I have 3 pages and in this way it reads only the first one (Table1):

[Table1(id=1, manualSort=1, pratica=‘ristrutturazione Cenate Sopra’, referente=‘Bartoli’, note=‘incassati 500 cash 11/05’, saldo=1500), Table1(id=2, manualSort=2, pratica=‘Sollevamento travi CORTEVA’, referente=‘Bedolini’, note=’’, saldo=1200), Table1(id=3, manualSort=3, pratica=‘collaudo az agr Pievetta’, referente=‘Canova’, note=’’, saldo=1000), Table1(id=4, …

That’s normal. fetch_table only fetches the specified table. The only way to get all the data in the document in a single API call is to download it as a SQLite or Excel file.


First of all thanks for you support!
So I can’t acces tables ‘C’ and ‘T’ in the attached image?

You can just fetch each table separately, e.g:

data1 = api.fetch_table(‘Table1’)
data2 = api.fetch_table(‘Table2’)
data3 = api.fetch_table(‘Table3’)

Here I’m guessing that your other two tables have table IDs Table2 and Table3.

Hi, it works perfectly, thanks again for the explanation!