Skip to main content

Access a table's Views object via API?


Forum|alt.badge.img+4

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

Forum|alt.badge.img+4
  • Inspiring
  • 192 replies
  • June 9, 2020

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.


Forum|alt.badge.img+4
  • Author
  • Participating Frequently
  • 5 replies
  • June 10, 2020
Kasra wrote:

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.


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;
  },

Reply