Programmatically generate API key and add document

Hi,

I’m adding some tests for GitHub - johncant/gristfdw: PostgreSQL Foreign Data Wrapper for Grist . To do this, I would like to spin up a docker container using gristlabs/grist image.

What’s the easiest way to programmatically generate an API key for a user, say, “You”, then add a predefined document, and get it’s doc_id?

Thanks a lot!

There are a lot of ways. One way that might be handy is to do it all manually one time, and then copy the container’s persist directory. Then you can just present a copy of that persist directory during testing, to start from however you left it. There’s a guide to the files here:

The home.sqlite3 file stores information about users and workspaces, and then the actual docs you make are in docs/*.grist. The grist-sessions.db won’t matter for this use case.

That’s brilliant - thanks!