Help

Re: Access a table's Views object via API?

1651 1
cancel
Showing results for 
Search instead for 
Did you mean: 
kirkbross
5 - Automation Enthusiast
5 - Automation Enthusiast

Is it possible to pull all the “Views” of a given table via the API? I don’t mean specify a particular view as part of an API call, but rather, I want to pull ALL the views of a given table as its own list.

The table object doesn’t seem to have a views object anywhere that I can find:

1. destroy: (...)
2. fetch: (...)
3. fields: (...)
4. id: (...)
5. patchUpdate: (...)
6. putUpdate: (...)
7. replaceFields: (...)
8. save: (...)
9. updateFields: (...)
10. _rawJson: (...)
11. _table: (...)
2 Replies 2

If you’re using the regular API or Airtable.js, this isn’t possible.

If you’re building a custom block that will run inside Airtable, you can access table.views.

kirkbross
5 - Automation Enthusiast
5 - Automation Enthusiast

Thanks @Kasra This is a VueJS app and my airtableClient for retrieving table records is below. Can I do something similar to retrieve a views object of a given table that contains the views id, name, record ids, etc. of that view?

  getTable(table) {
    let recordsArr = [];
    const base = new Airtable({ apiKey: environment.API_KEY }).base(
      environment.AIR_TABLE_BASE_ID
    );
    base(`${table}`)
      .select({
        maxRecords: 8000,
      })
      .eachPage(
        function page(records, fetchNextPage) {
          records.forEach(function (record) {
            recordsArr.push(record);
          });
          fetchNextPage();
        },
        function done(err) {
          if (err) {
            this.$toasted.error(err);
          }
        }
      );
    return recordsArr;
  },