API Calls Through Grist

I am not too good with APIs so I wanted to throw this question here regarding the rest API system within Grist. I looked at the support page and I tried to follow the command with the curl -H on my cmd but every time it kept saying that I have a bad API key but I retrieved the API key from my Grist settings page. Also I was wondering do we just call API on the cmd only? I tried to do it on vs code using python and this was how I structured it:

I expected json information to pop up but it just returned me an empty list for some reason.

Tazwar Belal

Hi @Tazwar_Belal.

Can you try removing the angle brackets from the API key in the curl command?

You can call the API from any client you’d like (e.g. curl, the requests Python library).

George

Alright so removing the angle bracket from curl worked out! What would I place inside the get() function for the python script to receive the same result?

Thank You!

Tazwar Belal

This should be equivalent:

requests.get("https://docs.getgrist.com/api/orgs", headers={
    'Authorization': 'Bearer GRIST_API_KEY',
})

George

Thank you very much, it worked out!

1 Like