Query table data

Read sampled data from a table. When the number of rows is not explicitly specified, the service returns 100 rows by default.

HTTP
POST $CLOUDSIGMA_API_BASE/catalog/table/data

Before you call

Configure the CloudSigma regional endpoint and authentication before calling. The endpoint, credentials, workspace, and resource IDs must belong to the same region. First query the object in the database to obtain the target table ID, or prepare the table name and database positioning parameters. Prepare the personal access token, target workspace ID, and table location information that can access the target workspace.

Request body

Shell
curl -X POST "$CLOUDSIGMA_API_BASE/catalog/table/data" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "id": '"$TABLE_ID"'
  }'

The positioning method of the table is consistent with query table information: use id, or use name plus database_id/database_name.

Field

Type

Required

Description

id

integer condition required

No

Table ID.

name

string condition is required

No

Table name. Required when id is not provided.

database_id

integer condition required

No

Non-system database ID. Mutually exclusive with database_name.

database_name

string condition is required

No

System database name. Mutually exclusive with database_id.

page

integer

No

Page number, default 1.

page_size

integer

No

Number of lines per page, default 100.

preview_lines

integer

No

Number of preview rows, there is currently no upper limit for additional rows.

include_total

boolean

No

Whether to count the total number of rows. Omitted or null Defaults to true.

Successful response

JSON
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "data": [
      [
        "1",
        "100.00"
      ]
    ],
    "columns": [
      {
        "name": "id",
        "type": "INT"
      },
      {
        "name": "amount",
        "type": "DECIMAL"
      }
    ],
    "total_rows": 120,
    "page": 1,
    "page_size": 100
  }
}

Field

Type

Description

code

string

OK on success.

msg

string

OK on success.

data.data

array

row data. Each inner array is arranged in the order columns.

data.columns

array of object

column information.

data.total_rows

integer

The total number of rows in the table. Returned only when include_total is requested.

data.page

integer

Current page number.

data.page_size

integer

The maximum number of rows in the current page.

data.columns[].name

string

Column name.

data.columns[].type

string

The data type of the column.

Error response

JSON
{
  "code": "ErrParamInvalid",
  "msg": "表定位参数无效"
}

Field

Type

Description

code

string

error code.

msg

string

error message.

Last updated on