跳到主要内容

获取数据表详情

使用该接口可以获取表详情,包括 Meta 信息(数据表字段的格式、名称和视图)和 数据行。

单次读取数据的条数限制为 500 条;如果数据表行数大于 500, 需要根据 lastSegmentRowID 获取增量数据。

如果 lastSegmentRowID 为空(读取 1-500 条数据),则会同时返回 Meta 信息和数据行;否则只返回数据行;

请求

curl -vvv "$API_HOST/open/api/v1/tablenodes/$id/partial/" -H "Content-Type: application/json" -H "Authorization: $access-token" -d '{}'

请求体

名称类型必需描述
viewIDstring视图ID,为空时返回默认视图
lastSegmentRowIDstring前一分片最后一行的ID,为空时请求第一分片

请求体示例

{
lastSegmentRowID: "5349b4ddd2781d08c09890f3",
viewID: "5349b4ddd2781d08c09890f3"
}

Python 示例

def read_table(access_token, table_id, view_id, last_rowid):
url = '%s/open/api/v1/tablenodes/%d/partial/' % (API_HOST, table_id)
data = {}
if view_id:
data['viewID'] = view_id
if last_rowid:
data['lastSegmentRowID'] = last_rowid
headers = {'Authorization': access_token}
req = requests.get(url, json=data, headers=headers)
return req.json()

响应

响应体

名称类型描述
detailobject数据表详情
∟ idint64数据表ID
∟ typestring数据表类型,table 数据表、bigTable 大数据表、group 组
∟ segmentTypestring分片类型,segmentStart 第一分片, segmentFrame 行数据分片
∟ moreboolean是否有更多数据,false代表已获取全部数据
∟ columnsarray列数据, segmentType == segmentStart 时返回
∟ rowsarray行数据
∟ viewsarray视图列表, segmentType == segmentStart 时返回
∟ rowsarray视图行
∟ columnsarray视图列

响应体示例

{
"code": 0,
"msg": "success",
"detail": {
"id": 1,
"type": "table",
"segmentType": "segmentStart",
"rows": [
{
"id": "61ca7730aeb6fdcb5a6cfcd5",
"cells": {
"620a0e9ef5f9e0fbec16049e": "Tanghekou Town",
"620a0e9ef5f9e0fbec16049f": 2
},
"meta": {
"createTime": "0001-01-01T00:00:00Z",
"updateTime": "0001-01-01T00:00:00Z",
"creatorID": 0,
"updaterID": 0
}
},
"columns": [
{
"id": "620a0e9ef5f9e0fbec16049e",
"syncedID": "000000000000000000000000",
"tableNodeID": 0,
"name": "a",
"type": "singleLineText",
"typeOptions": null,
"isPrimary": true,
"mode": "normal",
"meta": {
"createTime": "0001-01-01T00:00:00Z",
"updateTime": "0001-01-01T00:00:00Z",
"creatorID": 0,
"updaterID": 0
}
}
],
"views": [
{
"id": "620a0e9ef5f9e0fbec16049d",
"name": "New view",
"order": 1,
"frozenColumnCount": 1,
"filterCondition": "and",
"filters": [],
"groups": null,
"orders": null,
"rows": [
{
"id": "61ca7730aeb6fdcb5a6cfcd5",
"order": 1
},
{
"id": "61ca7730aeb6fdcb5a6cfcd6",
"order": 2
},
{
"id": "61ca7730aeb6fdcb5a6cfcd7",
"order": 3
}
],
"columns": [
{
"id": "620a0e9ef5f9e0fbec16049e",
"order": 1,
"width": 200,
"isHidden": false
},
{
"id": "620a0e9ef5f9e0fbec16049f",
"order": 2,
"width": 200,
"isHidden": false
}
]
}
]
}
}