Check version for document by REST API

Hello. I want to try downloading by REST API reference - Grist Help Center. when doc is changed. Is it possible to somehow track/compare the version .grist files in Grist-server and on remote server by API? And use downloadDoc endpoint when version is different.

Hmm. There are two undocumented endpoints:

  • /api/docs/DOCID/states
  • /api/docs/DOCID/snapshots

Both will give output that changes as the document changes. If you don’t have snapshots set up, the /snapshots endpoint won’t give a lot of information, but it will give a timestamp. The /states endpoint lists hashes and ids of changes made to the document. Different versions of the document could be compared somewhat with this information. Not sure exactly what you need.

Here are example endpoints for a template document:

Again, /snapshots will look a lot emptier if the feature is not set up, but it will have a lastModified timestamp.

1 Like

Thank you, this is a very interesting opportunity. /states takes into account all changes since the beginning of the document creation? Well, this information can be obtained from the metadata of the saved file .grist?

The length of /states will eventually be truncated for a long lived document or a document with very big changes:

The information shown in /states can indeed be obtained from the .grist file, it is in the _gristsys_ActionHistory table.

1 Like

Here the task is to compare the current version. grist file with the document version, so I think the number of /states is not particularly important. One of the use cases, I think, is the offline operation of a mobile application (I’m just starting to experiment with this).

1 Like