kkoshin/lark-sheet-plugin

使用飞书表格来作为简单的少量的数据管理

kkoshin opened this issue · 2 comments

在线云文档对于一些少量的数据维护还是很容易使用的,方便产品和开发同步。

常见用于,多语言表、一些应用配置项信息。

需要创建一个应用

需要企业管理员审核,每次调整权限的话,都需要重新发生

token

  1. tenant_access_token/user_access_token

刷新流程:user_access_token 需要用户登录并提供一个回调地址,服务端接人还是比较方便的
直接使用 应用的 app ID/secret 来获取 tenant_access_token

POST https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal
body:
{
"app_id": "cli_a4e6e23e517b100c",
"app_secret": "heiFVL4VHjlH4GmfPqFYyfPfUTkbbV2H"
}

成功返回:
{
"code": 0,
"msg": "success",
"tenant_access_token": "t-caecc734c2e3328a62489fe0648c4b98779515d3",
"expire": 7140
}

表格相关

  1. spreadsheet_token: 从url里可以获取,例如:LS4os3xmMhVwmwt1876cJb4Xn5f
  2. sheet_id

查询工作表信息

GET /open-apis/sheets/v3/spreadsheets/:spreadsheet_token/sheets/query

[{
    sheet_id: "9d44da",
    title: "表格名称"
}]

获取整个列表的筛选状态

可以查询到有效的数据范围

GET /open-apis/sheets/v3/spreadsheets/:spreadsheet_token/sheets/:sheet_id/filter

{
  "code": 0,
  "data": {
    "sheet_filter_info": {
      "filter_infos": [],
      "filtered_out_rows": [],
      "range": "9d44da!A1:F20"
    }
  },
  "msg": "success"
}

获取某个范围内的数据

LS4os3xmMhVwmwt1876cJb4Xn5f 为 spreadsheet_token, t-g1045ngjWQ2MHM5TNJ67LBVRHEW2RAKQS5EM73ZT 为 access_token

curl --location --request GET 'https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/LS4os3xmMhVwmwt1876cJb4Xn5f/values/9d44da!A1:F20?valueRenderOption=ToString&dateTimeRenderOption=FormattedString'
--header 'Authorization: Bearer t-g1045ngjWQ2MHM5TNJ67LBVRHEW2RAKQS5EM73ZT'

更简单的做法是直接使用 飞书提供的sdk,这样省的自己去请求接口