服务端 API/云文档/电子表格/表格/获取表格元数据
# 获取表格元数据

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

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.larksuite.com/open-apis/sheets/v2/spreadsheets/:spreadsheetToken/metainfo
HTTP Method | GET
支持的应用类型 | Custom App、Store App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用**<br>开启任一权限即可 | 查看、评论、编辑和管理云空间中所有文件(drive:drive)<br>查看、评论和下载云空间中所有文件(drive:drive:readonly)<br>查看、评论、编辑和管理电子表格(sheets:spreadsheet)<br>查看、评论和导出电子表格(sheets:spreadsheet:readonly)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `user_access_token` 或 `tenant_access_token` <br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer u-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：获取与使用access_token](https://open.larksuite.com/document/ukTMukTMukTM/uMTNz4yM1MjLzUzM)
Content-Type | string | 是 | **固定值**："application/json; charset=utf-8"

### 路径参数

参数 | 类型 | 描述
---|---|---
spreadsheetToken | string | spreadsheet 的 token；获取方式见[在线表格开发指南](https://open.larksuite.com/document/ukTMukTMukTM/uATMzUjLwEzM14CMxMTN/overview)

### 查询参数

**注意事项**：user_id_type目前默认值为lark_id，2022年1月26日后将会调整默认值为open_id，且不再支持lark_id，请尽快适配！

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

### cURL 请求示例

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

## 响应

### 响应体

**注意事项**：ownerUser字段已废弃，2022年1月26日后将不再返回ownerUser字段，请使用ownerUserID作为替代。ownerUserID为文档所有者的id，id类型由user_id_type决定。

| 参数                              | 类型             | 说明                                                         |
| --------------------------------- | ---------------- | ------------------------------------------------------------ |
| spreadsheetToken                  | string           | spreadsheet 的 token                                         |
| properties                        |                  | spreadsheet 的属性                                           |
| &emsp;∟title                      | string           | spreadsheet 的标题                                           |
| &emsp;∟ownerUser                  | int64              | 所有者的 id                                                  |
| &emsp;∟ownerUserID                  | string              | 所有者的 id，取决于user_id_type的值，仅user_id_type不为空是返回该值                                                  |
| &emsp;∟sheetCount                 | int              | spreadsheet 下的 sheet 数                                    |
| &emsp;∟revision                   | int              | 该 sheet 的版本                                              |
| sheets                            | array<interface> | spreadsheet 下的sheet列表                                    |
| &emsp;∟sheetId                    | string           | sheet 的 id                                                  |
| &emsp;∟title                      | string           | sheet 的标题                                                 |
| &emsp;∟index                      | int              | sheet 的位置                                                 |
| &emsp;∟rowCount                   | int              | sheet 的最大行数                                             |
| &emsp;∟columnCount                | int              | sheet 的最大列数                                             |
| &emsp;∟frozenRowCount             | int              | 该 sheet 的冻结行数，小于等于 sheet 的最大行数，0表示未设置冻结 |
| &emsp;∟frozenColCount             | int              | 该 sheet 的冻结列数，小于等于 sheet 的最大列数，0表示未设置冻结 |
| &emsp;∟merges                     | array<interface> | 该 sheet 中合并单元格的范围                                  |
| &emsp;&emsp;∟startRowIndex        | int              | 合并单元格范围的开始行下标，index 从 0 开始                  |
| &emsp;&emsp;∟startColumnIndex     | int              | 合并单元格范围的开始列下标，index 从 0 开始                  |
| &emsp;&emsp;∟rowCount             | int              | 合并单元格范围的行数量                                       |
| &emsp;&emsp;∟columnCount          | int              | 合并单元格范围的列数量                                       |
| &emsp;∟protectedRange             | array<interface> | 该 sheet 中保护范围                                          |
| &emsp;&emsp;∟dimension            |                  | 保护行列的信息，如果为保护工作表，则该字段为空               |
| &emsp;&emsp;&emsp;∟startIndex     | int              | 保护行列的起始位置，位置从1开始                              |
| &emsp;&emsp;&emsp;∟endIndex       | int              | 保护行列的结束位置，位置从1开始                              |
| &emsp;&emsp;&emsp;∟majorDimension | string           | 若为ROWS，则为保护行；为COLUMNS，则为保护列                  |
| &emsp;&emsp;&emsp;∟sheetId        | string           | 保护范围所在工作表 ID                                        |
| &emsp;&emsp;∟protectId            | string           | 保护范围ID                                                   |
| &emsp;&emsp;∟lockInfo             | string           | 保护说明                                                     |
| &emsp;&emsp;∟sheetId              | string           | 保护工作表 ID                                                |
| &emsp;∟blockInfo                  |                  | 若含有该字段，则此工作表不为表格                             |
| &emsp;&emsp;∟blockToken           | string           | block的token                                                 |
| &emsp;&emsp;∟blockType            | string           | block的类型                                                  |

### 响应体示例

```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": "***"
    }
}
```

### 错误码

具体可参考：[服务端错误码说明](https://open.larksuite.com/document/ukTMukTMukTM/ugjM14COyUjL4ITN)