PQ 读取玩具 Airtable 的数据
注册登陆建立空间及生成数据
https://airtable.com/
生成并获取apikey
https://airtable.com/account
apiKey=keyYvOCvO8skt3pnQ
进入api文档界面:https://airtable.com/api
选择一个实例进入该实例初始化api说明文档,里面会有实例的标志,如下面路由https://airtable.com/后面的字符串
https://airtable.com/appsLpjJDjY4tyUND
https://airtable.com/appvPtywXjUDIFJI9
你可以使用头部传参方式或者直接在路由里面加入读取数据权限的key值,套路如下:
Table.FromRecords(Json.Document(Web.Contents("https://api.airtable.com/v0/appvPtywXjUDIFJI9/Sheet1",
[Headers=[Authorization="Bearer keyYvOCvO8skt3pnQ"]]))[records])
或者
Table.FromRecords(Json.Document(Web.Contents("https://api.airtable.com/v0/appvPtywXjUDIFJI9/Sheet1?api_key=keyYvOCvO8skt3pnQ"))[records])
https://api.airtable.com/v0/appvPtywXjUDIFJI9/畅心
Table.FromRecords(Json.Document(Web.Contents("https://api.airtable.com/v0/appvPtywXjUDIFJI9/畅心?api_key=keyYvOCvO8skt3pnQ"))[records])
其他一些路由参数
https://api.airtable.com/v0/appvPtywXjUDIFJI9/Sheet1?maxRecords=3&view=Grid%20view
rest api参数:sort%5B0%5D%5Bfield%5D=%E5%B0%BA%E7%A0%81
sort%5B0%5D%5Bdirection%5D=desc
获取记录
Json.Document(Web.Contents("https://api.airtable.com/v0/appvPtywXjUDIFJI9/Sheet1/recdJUD2VmTXBAj6B?api_key=keyYvOCvO8skt3pnQ"))
POST记录新增
https://api.airtable.com/v0/appvPtywXjUDIFJI9/Sheet1
body
Content-Type: application/json
{
"records": [{"fields": {}},{"fields": {}}]
}
他也可以对数据流进行一些自动化操作,参照微软Power Automate,,,
在apps模块可以引入外部应用工具,如编写脚本提取数据:
output.markdown('# 吹牛逼我们是认真的!');
let name = await input.textAsync('请输入需要查询的表名');
let 表=base.getTable(name);
output.inspect(表);
//循环打印表元数据
for (let table of base.tables) {
output.text(`Table '${table.name}' 的id号为: '${table.id}',
链接地址:${table.url}`);
}
//获取表中字段信息
let table = base.getTable("畅心");
for (let field of table.fields) {
output.inspect(field);
}
//获取指定表元数据
let table2 = base.getTable("畅心");
output.inspect(table2);
//排序
let table3 = base.getTable("畅心");
let queryResult = await table3.selectRecordsAsync({
sorts: [
// sort by "班级" in ascending order
{field: "班级"},
// then by "姓名" in descending order.
{field: "成绩", direction: "desc"},
]
});
let table4 = base.getTable("畅心");
let queryResult2 = await table4.selectRecordsAsync();
let record = queryResult2.records[0];
output.inspect(record.getCellValue("姓名"));
let response = await fetch('https://api.github.com/orgs/Airtable');
console.log(await response.json());
当然你要是技术还凑活可以使用前面客户端构建的官方js文件自己构造相关应用场景交互使用,,,
https://github.com/Airtable/airtable.js
社区构建的客户端参考:
https://github.com/sirupsen/airrecord
https://github.com/ngocnicholas/airtable.net
国内的看维格表,,,
道高一尺 魔高一丈
https://pbihub.cn/users/44
自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)