Custom Widget - Get Table Structure

I have been looking through the grist-plugin-api docs, but I haven’t been able to find an answer to my question:

Is it possible to get the structure of a table? I can get the values of each cell of a row easily with onRecord(s), but I am trying to get the type of each column.

For example, instead of {'id': 1, 'name': 'John', 'birthday': '2000-01-01'}, I’d like to get {'id': 'integer', 'name': 'string', 'birthday': 'date'}

Is this possible with the grist-plugin-api?

I guess I could get an accessToken and then call /api/docs/{docId}/tables/{tableId}/columns, right?

Is there any other way to get the type of each column of a table?

The columns endpoint with an access token may be the best approach at this point, since it’s a stable public interface.

You can also get this information without needing an access token by calling fetchTable("_grist_Tables") and fetchTable("_grist_Tables_column") (using fetchTable) – those are the names of the internal tables that contain table and column metadata.

Getting types of columns is a known difficulty. We’ve been thinking how to make that information available more easily, but not sure if there is any specific proposal yet.

1 Like

Hi there!

Is there any update on this or the solution is still the same?

Cheers!