Skip to content

访问 https://airtable.com/app123456 获取库 ID ,如 app123456 。

查询单库所有表的信息。

const TOKEN = 'pat123456';
const BASE_ID = 'app123456';

const url = 'https://api.airtable.com/v0/meta/bases/' + BASE_ID + '/tables';
const options = {method: 'GET', headers: {Authorization: 'Bearer ' + TOKEN}};

try {
  const response = await fetch(url, options);
  const data = await response.text();
  console.log(data);
} catch (error) {
  console.error(error);
}

查询单库第一张表的结构。

const TOKEN = 'pat123456';
const BASE_ID = 'app123456';

const url = 'https://api.airtable.com/v0/meta/bases/' + BASE_ID + '/tables';
const options = {method: 'GET', headers: {Authorization: 'Bearer ' + TOKEN}};

try {
  const response = await fetch(url, options);
  const data = (await response.json()).tables[0].fields;
  console.log(data);
} catch (error) {
  console.error(error);
}

联系 math@baima.site