Skip to content

获取表格元数据

该接口用于根据 spreadsheetToken 获取表格元数据。

请求

项目
HTTP URLhttps://open.feishu.cn/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/metainfo
HTTP MethodGET
接口频率限制100 次/秒
支持的应用类型custom,isv
权限要求 调用该 API 所需的权限。开启其中任意一项权限即可调用 开启任一权限即可drive:drive 查看、评论、编辑和管理云空间中所有文件 drive:drive:readonly 查看、评论和下载云空间中所有文件 sheets:spreadsheet 查看、评论、编辑和管理电子表格 sheets:spreadsheet:readonly 查看、评论和导出电子表格

请求头

名称类型必填描述
Authorizationstringuser_access_tokentenant_access_token 值格式:"Bearer access_token" 示例值:"Bearer u-7f1bcd13fc57d46bac21793a18e560" 了解更多:如何选择与获取 access token
Content-Typestring固定值:"application/json; charset=utf-8"

路径参数

参数类型描述
spreadsheetTokenstringspreadsheet 的 token;获取方式见在线表格开发指南

查询参数

参数类型必须说明
extFieldsstring额外返回的字段,extFields=protectedRange时返回保护行列信息
user_id_typestring返回的用户id类型,可选open_id,union_id

cURL 请求示例

curl --location --request GET 'https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/shtcngNygNfuqhxTBf588jwgWbJ/metainfo?extFields=protectedRange&user_id_type=open_id' \
--header 'Authorization: Bearer t-e346617a4acfc3a11d4ed24dca0d0c0fc8e0067e'

响应

响应体

参数类型说明
spreadsheetTokenstringspreadsheet 的 token
propertiesspreadsheet 的属性
 ∟titlestringspreadsheet 的标题
 ∟ownerUserint64所有者的 id,仅user_id_type为空时返回该值
 ∟ownerUserIDstring所有者的 id,取决于user_id_type的值,仅user_id_type不为空时返回该值
 ∟sheetCountintspreadsheet 下的 sheet 数
 ∟revisionint该 sheet 的版本
sheetsarray<interface>spreadsheet 下的sheet列表
 ∟sheetIdstringsheet 的 id
 ∟titlestringsheet 的标题
 ∟indexintsheet 的位置
 ∟rowCountintsheet 的最大行数
 ∟columnCountintsheet 的最大列数
 ∟frozenRowCountint该 sheet 的冻结行数,小于等于 sheet 的最大行数,0表示未设置冻结
 ∟frozenColCountint该 sheet 的冻结列数,小于等于 sheet 的最大列数,0表示未设置冻结
 ∟mergesarray<interface>该 sheet 中合并单元格的范围
  ∟startRowIndexint合并单元格范围的开始行下标,index 从 0 开始
  ∟startColumnIndexint合并单元格范围的开始列下标,index 从 0 开始
  ∟rowCountint合并单元格范围的行数量
  ∟columnCountint合并单元格范围的列数量
 ∟protectedRangearray<interface>该 sheet 中保护范围
  ∟dimension保护行列的信息,如果为保护工作表,则该字段为空
   ∟startIndexint保护行列的起始位置,位置从1开始
   ∟endIndexint保护行列的结束位置,位置从1开始
   ∟majorDimensionstring若为ROWS,则为保护行;为COLUMNS,则为保护列
   ∟sheetIdstring保护范围所在工作表 ID
  ∟protectIdstring保护范围ID
  ∟lockInfostring保护说明
  ∟sheetIdstring保护工作表 ID
 ∟blockInfo若含有该字段,则此工作表不为表格
  ∟blockTokenstringblock的token
  ∟blockTypestringblock的类型

响应体示例

json
{
    "code": 0,
    "msg": "Success",
    "data": {
        "properties": {
            "title": "",
            "ownerUser": 0,
            "sheetCount": 0,
            "revision": 0
        },
        "sheets": [
            {
                "sheetId": "***",
                "title": "***",
                "index": 0,
                "rowCount": 0,
                "columnCount": 0,
                "frozenColCount": 0,
                "frozenRowCount": 0,
                "merges": [
                    {
                        "columnCount": 0,
                        "rowCount": 0,
                        "startColumnIndex": 0,
                        "startRowIndex": 0
                    }
                ],
                "protectedRange": [
                    {
                        "dimension": {
                            "endIndex": 0,
                            "majorDimension": "ROWS",
                            "sheetId": "***",
                            "startIndex": 0
                        },
                        "protectId": "***",
                        "sheetId": "***",
                        "lockInfo": "***"
                    }
                ]
            },
            {
                "blockInfo": {
                    "blockToken": "***",
                    "blockType": "***"
                },
                "columnCount": 0,
                "frozenColCount": 0,
                "frozenRowCount": 0,
                "index": 0,
                "rowCount": 0,
                "sheetId": "***",
                "title": "*** "
            }
        ],
        "spreadsheetToken": "***"
    }
}

错误码

具体可参考:服务端错误码说明

内容来源:飞书开放平台 · 自动爬取整理