docs/en/developers/code-style-guides/restful-api-standard.md
/api/{version}/{target-object-access-path}/{action}.{version} is denoted as v{number}, such as v1, v2, v3, v4, etc.{target-object-access-path} is organized in a hierarchical manner, which will be explained in detail later.{action} is optional, API implementors should utilize the HTTP METHOD to convey the operation's meaning as much as possible. Only when the HTTP methods' semantics cannot be fulfilled should the action be used. For example, if there is no HTTP method available to rename an object./primary_categories/primary_object/secondary_categories/secondary_object/.../categories/object
Taking catalog, database, table, column as examples:
/catalogs: Represents all catalogs.
/catalogs/hive: Represents the specific catalog object named "hive" under the catalog category.
/catalogs/hive/databases: Represents all databases in the "hive" catalog.
/catalogs/hive/databases/tpch_100g: Represents the database named "tpch_100g" in the "hive" catalog.
/catalogs/hive/databases/tpch_100g/tables: Represents all tables in the "tpch_100g" database.
/catalogs/hive/databases/tpch_100g/tables/lineitem: Represents the tpch_100g.lineitem table.
/catalogs/hive/databases/tpch_100g/tables/lineitem/columns: Represents all columns in the tpch_100g.lineitem table.
/catalogs/hive/databases/tpch_100g/tables/lineitem/columns/l_orderkey: Represents the specific column l_orderkey in the tpch_100g.lineitem table.
# list all of the tables in database ssb_100g
GET /api/v2/catalogs/default/databases/ssb_100g/tables
# show the table ssb_100g.lineorder
GET /api/v2/catalogs/default/databases/ssb_100g/tables/lineorder
POST /api/v2/catalogs/default/databases/ssb_100g/tables/create -d@create_customer.sql
PUT /api/v2/databases/ssb_100g/tables/create -d@create_customer.sql
DELETE /api/v2/catalogs/default/databases/ssb_100g/tables/customer
PATCH /api/v2/databases/ssb_100g/tables/customer -d '{"unique_key_constraints": ["c_custkey"]}'
When the API returns an HTTP code code of 200/201/202, the HTTP response is not empty. The API returns results in JSON format, including top-level fields "code", "message", and "result". All JSON fields are named using camel-case.
In a successful API response, the "code" is "0", the "message" is "OK", and the "result" contains the actual results.
{
"code":"0",
"message": "OK",
"result": {....}
}
{
"code":"1",
"message": "Analyze error",
"result": {....}
}
API parameters are passed in the precedence order of path, request body, query parameters, and header. Choose the appropriate method for parameter passing.
Path parameters: Required parameters that represent the object's hierarchical relationship are placed in the path parameters.
/api/v2/warehouses/{warehouseName}/backends/{backendId}
/api/v2/warehouses/ware0/backends/10027
Request body: Parameters are passed using application/json. Parameters can be of required or optional types.
Query parameters: Using query parameters and request body parameters at the same time is not allowed. For the same API, choose either one. If the number of parameters excluding header parameters and path parameters is not more than 2, query parameters can be used; otherwise, use the request body to pass parameters.
HEADER parameters: Headers should be used to pass HTTP standard parameters such as Content-type and Accept are placed in the header, implementors should not abuse http headers to pass customized parameters. When using headers to pass parameters for user extensions, the header name should be in the format x-starrocks-{name}, where the name can contain multiple English words, and each word is in lowercase and concatenated by hyphens (-).