Skip to main content

Data Query Open API

Here is how to use the Data Query Open API.

API endpoint

The endpoint URL for Data Query API requests is as follows:

Data Query endpoint URL format
https://data-query.kr-central-2.kakaocloud.com

Run query

Request to execute a query.

info

Some queries do not return data as a result, so the query result may not be saved as a file.
e.g., CREATE TABLE, CREATE SCHEMA, DROP TABLE, DROP SCHEMA, SHOW SCHEMAS, SHOW TABLES, etc.

Request

MethodURI
POST{endpoint-url}/v1/data-query/query
Run query Request
curl -X POST 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/query' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}' \
--header 'Content-Type: application/json' \
--header 'X-Data-Source: {data source name}' \
--header 'X-Database: {database name}' \
--data-raw '{Request body}'
Request header
RequestRequiredDescription
Credential-idYesAccess key id
Credential-secretYesSecret access key
Content-TypeYesapplication/json
X-Data-SourceOptionalName of the default data source to apply to the query
X-DatabaseOptionalName of the default database to apply to the query
Request body
Request body
{
"query": "string",
"resultConfig": {
"bucketName": "string",
"path": "string"
},
"reuseConfig": {
"reuse": boolean,
"maxReuseAge": integer
}
}
Request elements
FieldRequiredDescription
queryYesQuery written in SQL
ㄴ The data source and database specified in the x-data-source and x-database headers are applied as the default table location.
ㄴ If you run the query without these headers, you must prefix the table names in the query with the data source and database, separated by a dot (.).
ㄴ If you omit them, errors may occur.
* For more details on SQL usage, see the SQL Reference.
resultConfig ▼Query result data information
    bucketNameYesName of the Object Storage bucket to store the query result
    pathYesSubdirectory path to store the query result
- A folder with the execution date {YYYY}/{MM}/{DD}/ is automatically created under the specified path, and the result file is saved inside it.
- The result includes a query result file (.csv) and a metadata file (.metadata).
- For details, refer to Query result data.
reuseConfig ▼Query result reuse information
    reuseOptionalWhether to reuse the query result
    maxReuseAgeOptionalQuery result reuse lifespan (in minutes)
- Can be set from 1 to 1440 minutes (24 hours).
- Required if reuse is set to true.

Example

Request example
Run query request example
curl -X 'POST'
'https://https://data-query.kr-central-2.kakaocloud.com/v1/data-query/query' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}' \
--header 'Content-Type: application/json' \
--header 'x-data-source: test_datasource' \
--header 'x-database: test_database' \
--data-raw '{
"query": "select * from nation, test_datasource.test_database.region limit 100",
"bucketName": "test-bucket",
"path": "data_query/result"
}'
  • The nation table, which does not specify a data source or database, is automatically assigned the location defined in the headers: test_datasource and test_database.
  • The region table explicitly specifies its data source and database, which take precedence over the headers.
  • As a result, the executed query is equivalent to: select * from test_datasource.test_database.nation, test_datasource.test_database2.region limit 100.
  • The query result is saved as two files (.csv, .metadata) under data_query/result/2024/11/26 in the test-bucket bucket.

Response

Run query response example
{
"queryInfo": {
"queryId": "data-query-20240903-011848-HcejcLZBHz",
"state": "QUEUED"
}
}
Response eements
FieldDescription
queryIdQuery ID
stateQuery status
Response codes
CodeDescription
202Success
400Bad request
401Credential authentication failed
403Forbidden
404Bucket not found
499Service agent lacks required permissions on the specified bucket

Retrieve query result

  • Retrieve the query result and detailed information.
  • You can check the query status, basic statistics, and part of the result in paginated form.
info

Query results are provided in pages of 100 rows, up to a maximum of 1,000 rows (pages 0–9).

Request

MethodURI
GET{endpoint-url}/v1/data-query/query/{query-id}?page={page-number}
Retrieve query result request

curl -X GET 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/query/{query-id}?page={page-number}' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}'
Path parameters
PathTypeRequiredDescription
query-idstringYesQuery ID
Query parameters
RequestRequiredDescription
page-numberOptionalPage number of the query result to retrieve
Request headers
RequestRequiredDescription
Credential-idYesAccess key id
Credential-secretYesSecret access key

Example

Request example
Retrieve query result request example
curl -X GET 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/query/20241126-011848-HcejcLZBHz?page=0' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}'
  • Retrieve the query result of query ID 20241126-011848-HcejcLZBHz.
  • If the query result exists, 100 rows from page 0 will be retrieved.

Response

Retrieve query result response example
{
"queryInfo": {
"queryId": "20250327-153053-NvgfWymHmr",
"state": "FINISHED",
"queryStats": {
"progressPercentage": 100,
"inputRows": 232313,
"inputDataSize": "25.6MB",
"outputRows": 100,
"outputDataSize": "12.81KB",
"createdAt": 1743057053000,
"completedAt": 1743057054000,
"queryExecutionTime": "439ms",
"elapsedTime": "668ms",
"queuedTime": "102ms",
"planningTime": "84ms"
},
"queryTextPreview": "select * from orders limit 100",
"isScanned": true
},
"resultConfig": {
"bucketName": "hailey-test",
"path": "string/2025/03/27",
"storageUrl": "hailey-test/string/2025/03/27",
"storeType": "BASIC",
"isStored": true
},
"reuseConfig": {
"reuse": true,
"expireAt": 1743057113000
},
"columnData": [
{
"name": "orderkey",
"index": 1,
"type": "bigint"
},
{
"name": "custkey",
"index": 2,
"type": "bigint"
}, ...
],
"queryData": [
[
"20956642",
"680917",
"O",
"91063.82",
"1996-11-09",
"3-MEDIUM",
"Clerk#000005503",
"0",
"instructions sleep quickly. final ideas use slyly. carefully iron"
], ...
],
"totalPages": 1,
"totalElements": 100,
"number": 0,
"size": 100,
"numberOfElements": 100
}
Response eements
FieldDescription
queryInfo ▼Information about the retrieved query
    queryIdQuery ID
    stateQuery state
    queryStats ▼Statistics about the retrieved query
        progressPercentageQuery progress
        inputRowsNumber of input rows
        inputDataSizeSize of input data
        outputRowsNumber of output rows
        outputDataSizeSize of output data
        createdAtTime the query was requested
        completedAtTime the query result was stored
        queryExecutionTimeTime taken to execute the query
        elapsedTimeTime taken until the query completed
        queuedTimeTime the query waited before execution
        planningTimeTime spent planning the query
    queryTextPreviewPreview of the submitted query
- Displays up to 300 characters
    isScannedIndicates whether data scanning occurred
resultConfig ▼Information about the query result data
    bucketNameName of the Object Storage bucket where the result is stored
    pathSub-path in Object Storage where the result is stored
    storageUrlFull path in Object Storage where the result is stored
    storeTypeType of query result
- BASIC: general tabular format
- TEXT: text format
    isStoredWhether the query result is stored in Object Storage
reuseConfig ▼Information about result reuse
    reuseWhether the result is reused
    expireAtExpiration time of the reused result
columnDataMetadata about the query result columns
queryDataList of query results
totalPagesTotal number of pages
totalElementsTotal number of records
sizeNumber of results per page
numberCurrent page number
numberOfElementsNumber of records on the current page
Response codes
CodeDescription
200Success
400Bad request
401Credential authentication failed
403Forbidden
404Query ID not found

Retrieve query list

  • Retrieve executed query list.
  • Check summary information of executed queries.

Request

methodURI
GET{endpoint-url}/v1/data-query/query
Retrieve query list request

curl -X GET 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/query' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}'
Query parameters
RequestRequiredDescription
queryIdoptionalquery ID to search
creatorNameoptionaluser who executed the query
- filter by queries executed by a specific user
statesoptionalsearch by query state
- valid states: QUEUED, RUNNING, FINISHED, ABORTED, FAILED (see query status details)
pageoptionalpage number
sizeoptionalpage size
sortoptionalfield to sort by
- valid fields: queryId, queryTextPreview, state, createdAt, elapsedTime, inputDataSize, creatorName, storageUrl
Request header
RequestRequiredDdscription
Credential-idrequiredAccess key id
Credential-secretrequiredSecret access key

Example

Request example
Retrieve query list request example
curl -X GET 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/query?page=0&size=3&sort=elapsedTime,desc&states=FAILED&states=FINISHED' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}'
  • page (page number): 0
  • size (page size): 3
  • sort by elapsedTime in descending order
  • filter query info with state FAILED or FINISHED only

Response

Retrieve query list response example
{
"content":[
{
"queryInfo":{
"queryId":"20250314-143349-49C99wBfqS",
"state":"FINISHED",
"queryStats":{
"scannedDataSize":"0B",
"createdAt":1741930429000,
"elapsedTime":"9.83m"
},
"queryTextPreview":"select * from orders limit 100000000",
"isScanned":false
},
"resultConfig":{
"storageUrl":"testor1-bucket/data_query/result/2024/11/19"
},
"reuseConfig":{
"reuse":false
},
"creatorName":"testor1@kakaoenterprise.com"
},
{
"queryInfo":{
"queryId":"20250314-143350-7DtipSZrfh",
"state":"FINISHED",
"queryStats":{
"scannedDataSize":"0B",
"createdAt":1741930430000,
"elapsedTime":"9.52m"
},
"queryTextPreview":"select ...",
"isScanned":false
},
"resultConfig":{
"storageUrl":"testor1-bucket/data_query/result/2024/11/04"
},
"reuseConfig":{
"reuse":false
},
"creatorName":"testor1@kakaoenterprise.com"
},
{
"queryInfo":{
"queryId":"20250317-084931-6sCSgTNeAf",
"state":"FINISHED",
"queryStats":{
"scannedDataSize":"0B",
"createdAt":1742168971000,
"elapsedTime":"9.16m"
},
"queryTextPreview":"select ... A ...",
"isScanned":true
},
"resultConfig":{
"storageUrl":"testor2-bucket/result/2024/11/04"
},
"reuseConfig":{
"reuse":true
},
"creatorName":"testor1@kakaoenterprise.com"
}
],
"pageable":{
"pageNumber":0,
"pageSize":3,
"sort":{
"unsorted":false,
"sorted":true,
"empty":false
},
"offset":0,
"unpaged":false,
"paged":true
},
"totalPages":6,
"totalElements":104,
"last":false,
"numberOfElements":20,
"size":3,
"number":0,
"sort":{
"unsorted":false,
"sorted":true,
"empty":false
},
"first":true,
"empty":false
}
Response eements
FieldDescription
content ▼List of queried queries
    queryInfo ▼Query information
        queryIdQuery ID
        stateQuery state (see query status details)
        queryStats ▼Query statistics
            scannedDataSizeScanned data size
            createdAtQuery request time
            elapsedTimeQuery completion time
        queryTextPreviewQuery text preview up to 300 characters
        isScannedWhether data scanning occurred
    resultConfig ▼Query result data information
        storageUrlFull path to the Object Storage where query results are saved
    reuseConfig ▼Query result reuse information
        reuseWhether query results are reused
    creatorNameUser who executed the query
pageable ▼Paging information
    pageNumberCurrent page number
    pageSizeCurrent page size
    sort ▼Sorting information
        sortedWhether sorting is applied
        unsortedWhether sorting is not applied
        emptyWhether sorting conditions are empty
    offsetStarting point of the page
    pagedWhether paging is applied
    unpagedWhether paging is not applied
totalPagesTotal number of pages
totalElementsTotal number of data elements
lastWhether the current page is the last page
sizeCurrent page size
firstWhether the current page is the first page
numberCurrent page number
emptyWhether the current page is empty
Response codes
FieldDescription
200Success
400Bad request
401Credential authentication failure
403forbidden
404query id not found

Abort query

  • Aborts query execution.
  • Does not work if query state is FINISHED, FAILED, or ABORTED.

Request

MethodURI
PUT{endpoint-url}/v1/data-query/query/{query-id}/abort
Abort query request
curl -X PUT 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/query/{query-id}/abort' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}'
Path parameters
RequestRequiredDescription
query-idrequiredid of the query to abort
Request header
RequestRequiredDescription
Credential-idrequiredAccess key id
Credential-secretrequiredSecret access key

Example

Request example
Abort query request example
curl -X PUT 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/query/20241104-071200-TkMfjvIieD' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}'
  • Aborts query execution with query id 20241104-071200-TkMfjvIieD

Response

Status code
FieldDescription
200   Success
400Bad request
401Credential authentication failed
403Forbidden
409Query already terminated

Retrieve data source list

  • Retrieve the list of data sources connected to data query.

Request

MethodURI
GET{endpoint-url}/v1/data-query/data-source
Retrieve data source list request
curl -X GET 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/data-source' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}'
Request header
RequestRequiredDescription
Credential-idRequiredAccess key id
Credential-secretRequiredSecret access key

Example

Request example
Retrieve data source list request
curl -X GET 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/data-source' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}'

Response

Retrieve data source list response
[
{
"scope": "NONE",
"creatorName": "-",
"type": "DATA_CATALOG",
"name": "data_catalog"
},
{
"scope": "NONE",
"creatorName": "-",
"type": "DATA_CATALOG",
"name": "test_catalog"
},
{
"scope": "PUBLIC",
"creatorName": "testor1@kakaoenterprise.com",
"type": "MYSQL",
"description": "",
"name": "data_query_cbt"
},
{
"scope": "PRIVATE",
"creatorName": "testor1@kakaoenterprise.com",
"type": "MYSQL",
"name": "testor1_mysql"
},
{
"scope": "PUBLIC",
"creatorName": "testor2@kakaoenterprise.com",
"type": "MYSQL",
"name": "testor2_public"
}
]
Response eements
FieldDescription
scopedata source visibility scope
creatorNamedata source creator
nameretrieved query information
typedata source type
- DATA_CATALOG, MYSQL
DescriptionDescription of the data source
response codes
FieldDescription
200Success
400Bad request
401Credential authentication failed
403Forbidden

Create MySQL data source

  • Creates a MySQL type data source.
Notice

DATA_CATALOG type data sources are automatically created when a catalog is created in the Data Catalog service.

Request

MethodURI
POST{endpoint-url}/v1/data-query/data-source
Create MySQL data source request
curl -X POST 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/data-source' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}' \
--header 'Content-Type: application/json' \
--data-raw '{Request body}'
Request header
RequestRequiredDescription
Credential-idRequiredAccess key ID
Credential-secretRequiredSecret access key
Content-TypeRequiredapplication/json
Request body
Request body
{
"type": "MYSQL",
"name": "string",
"scope": "PRIVATE|PUBLIC",
"description": "string",
"instanceId": "string",
"mysqlUser": "string",
"mysqlPassword": "string"
}
Request elements
FieldRequiredDescription
typeRequiredType of data source
nameRequiredName of data source
- Allows only lowercase English letters, underscores (_), and numbers; length 3 to 72 characters
scopeRequiredData source public scope
descriptionOptionalDescription of the data source
instanceIdRequiredKakaoCloud MySQL instance ID to connect
mysqlUserRequiredMySQL account ID
mysqlPasswordRequiredMySQL account password
⚠️ Input as base64-encoded string

Example

Request example
Create MySQL data source request example
curl -X GET 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/data-source' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}' \
--header 'Content-Type: application/json' \
--data-raw '{
"type": "MYSQL",
"name": "test_mysql",
"scope": "PRIVATE",
"description": "test mysql",
"instanceId": "fbc16e9a-6352-11ef-952c-0a27e22384db",
"mysqlUser": "admin",
"mysqlPassword": "YWRtaW4K"
}'
  • Enter mysqlPassword as YWRtaW4K, which is the base64 encoding of the string admin

Response

Status code
FieldDescription
200Success
400Bad request
401Credential authentication failed
403Forbidden
409Duplicate data source name

Delete MySQL data source

  • Delete a MySQL type data source.
info

DATA_CATALOG type data sources cannot be deleted.

Request

MethodURI
DELETE{endpoint-url}/v1/data-query/data-source/{data-source-name}
Delete MySQL data source API call example
curl -X DELETE 'https://data-query.kr-central-2.kakaocloud.com/v1/data-query/data-source/{data-source-name}' \
--header 'Credential-ID: {credential-id}' \
--header 'Credential-Secret: {credential-secret}' \
--data-raw '{Request body}'
Path parameters
PathRequiredDescription
data-source-nameRequiredName of the data source to be deleted
Request header
RequestRequiredDescription
Credential-idRequiredAccess key ID
Credential-secretRequiredSecret access key

Example

Request example
MySQL data source delete request example
curl -X DELETE 'https://<data query API endpoint>/v1/data-query/data-source/test_mysql' \
-H 'Credential-ID: {credential-id}' \
-H 'Credential-Secret: {credential-secret}'

Response

Status code
FieldDescription
200Success
400Bad request
401Credential authentication failed
403Forbidden
404Data source not found