curl -u 'admin@system:admin' https://my_sql_node.com/v1/execute/system \
-d '{"statement":"SELECT * FROM sys.dummy2", "format": "collection"}'import requests
url = "https://{sql_node}/v1/execute/{database}"
payload = {
"statement": "<string>",
"database": "<string>",
"format": "<string>",
"params": {},
"fetch_size": 123,
"max_rows": 123
}
headers = {
"authorization": "<authorization>",
"content-type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<authorization>', 'content-type': '<content-type>'},
body: JSON.stringify({
statement: '<string>',
database: '<string>',
format: '<string>',
params: {},
fetch_size: 123,
max_rows: 123
})
};
fetch('https://{sql_node}/v1/execute/{database}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{sql_node}/v1/execute/{database}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'statement' => '<string>',
'database' => '<string>',
'format' => '<string>',
'params' => [
],
'fetch_size' => 123,
'max_rows' => 123
]),
CURLOPT_HTTPHEADER => [
"authorization: <authorization>",
"content-type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{sql_node}/v1/execute/{database}"
payload := strings.NewReader("{\n \"statement\": \"<string>\",\n \"database\": \"<string>\",\n \"format\": \"<string>\",\n \"params\": {},\n \"fetch_size\": 123,\n \"max_rows\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
req.Header.Add("content-type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{sql_node}/v1/execute/{database}")
.header("authorization", "<authorization>")
.header("content-type", "<content-type>")
.body("{\n \"statement\": \"<string>\",\n \"database\": \"<string>\",\n \"format\": \"<string>\",\n \"params\": {},\n \"fetch_size\": 123,\n \"max_rows\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{sql_node}/v1/execute/{database}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["content-type"] = '<content-type>'
request.body = "{\n \"statement\": \"<string>\",\n \"database\": \"<string>\",\n \"format\": \"<string>\",\n \"params\": {},\n \"fetch_size\": 123,\n \"max_rows\": 123\n}"
response = http.request(request)
puts response.read_body{
"query_id": "ac4dd039-e385-400b-a428-fd1fdcd02e30",
"status": {
"reason": "The operation completed successfully",
"sql_state": "00000",
"vendor_code": 0
},
"data": [
{
"c1": 1
},
{
"c1": 2
}
]
}execute
Executes a SQL statement and returns the results. Supports requests for both regular and streaming responses. With streaming, results return as they become available using the HTTP chunked transfer encoding. Each chunk contains a valid JSON object that you can parse independently. For details on streaming, including large-response configuration, see the header parameters. You can specify the database in the request body. If you do not specify the database, the Ocient System defaults to the database specified in the authentication token or system settings. If you specify a database in the request, this value overrides any alternate database value specified as a body parameter.
curl -u 'admin@system:admin' https://my_sql_node.com/v1/execute/system \
-d '{"statement":"SELECT * FROM sys.dummy2", "format": "collection"}'import requests
url = "https://{sql_node}/v1/execute/{database}"
payload = {
"statement": "<string>",
"database": "<string>",
"format": "<string>",
"params": {},
"fetch_size": 123,
"max_rows": 123
}
headers = {
"authorization": "<authorization>",
"content-type": "<content-type>"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {authorization: '<authorization>', 'content-type': '<content-type>'},
body: JSON.stringify({
statement: '<string>',
database: '<string>',
format: '<string>',
params: {},
fetch_size: 123,
max_rows: 123
})
};
fetch('https://{sql_node}/v1/execute/{database}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{sql_node}/v1/execute/{database}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'statement' => '<string>',
'database' => '<string>',
'format' => '<string>',
'params' => [
],
'fetch_size' => 123,
'max_rows' => 123
]),
CURLOPT_HTTPHEADER => [
"authorization: <authorization>",
"content-type: <content-type>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{sql_node}/v1/execute/{database}"
payload := strings.NewReader("{\n \"statement\": \"<string>\",\n \"database\": \"<string>\",\n \"format\": \"<string>\",\n \"params\": {},\n \"fetch_size\": 123,\n \"max_rows\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("authorization", "<authorization>")
req.Header.Add("content-type", "<content-type>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{sql_node}/v1/execute/{database}")
.header("authorization", "<authorization>")
.header("content-type", "<content-type>")
.body("{\n \"statement\": \"<string>\",\n \"database\": \"<string>\",\n \"format\": \"<string>\",\n \"params\": {},\n \"fetch_size\": 123,\n \"max_rows\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{sql_node}/v1/execute/{database}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["authorization"] = '<authorization>'
request["content-type"] = '<content-type>'
request.body = "{\n \"statement\": \"<string>\",\n \"database\": \"<string>\",\n \"format\": \"<string>\",\n \"params\": {},\n \"fetch_size\": 123,\n \"max_rows\": 123\n}"
response = http.request(request)
puts response.read_body{
"query_id": "ac4dd039-e385-400b-a428-fd1fdcd02e30",
"status": {
"reason": "The operation completed successfully",
"sql_state": "00000",
"vendor_code": 0
},
"data": [
{
"c1": 1
},
{
"c1": 2
}
]
}Headers
Specifies the request body format. Options include:
application/json
Description: The standard option for submitting queries and receiving responses as a single JSON object or array. Use when submitting queries with relatively small or moderate result sets or when you want the entire result set in one response.
application/stream+json
Description: Enables streaming of multiple JSON objects, allowing the API to send results as they become available. Use when querying large tables or expecting a large volume of results or when you want to process each row or result as soon as it is received, without waiting for the full response.
Supported compression algorithms for responses. You can specify multiple algorithms as a comma-separated list.
Supported values are: "gzip" "deflate" "be" (Brotli) or combinations like: "gzip, be".
Note: For large result sets, compression can impact performance. Without compression, the result sets can be chunks of rows processed in a streaming fashion. With compression, the entire result set must be compressed before it is returned to the client. The client side must decompress the entire result set before processing any rows.
Indicates the preferred encoding type from those specified in the accept-encoding parameter. This header provides fine-grained control when the accept-encoding parameter contains multiple values, allowing the client to specify which encoding is preferred for this specific request explicitly.
Supported values are:
"gzip" "br"
Path Parameters
The specific database in your system for the API call.
If you do not specify the database, the executed query defaults to the database from the authentication token or system settings.
If you include a database in the path, this value overrides any alternate database value specified as a body parameter.
Query Parameters
Sets the format for the requested data.
Note: This parameter applies only when using Content-Type: text/plain. When using Content-Type: application/json, specify the format in the request body.
Supported values are:
"array" — Returns schema and data as arrays (more efficient for large data sets). (default) "collection" — Returns data as JSON objects (more convenient for client processing).
Example: format=collection
Body
Parameters to substitute in the SQL statement for values enclosed in braces. The keys should match the parameter names in the statement (without the enclosing braces). Wrap string values in single quotes. All other data types do not use quotes.
Example: If your SQL statement is SELECT * FROM orders WHERE order_date > {start_date}, then your API request should include values in the params body parameter, such as {'start_date': '2023-01-01'}.
The number of rows to return in each chunk for streaming responses. This value must be 0 or greater. A value of 0 (default) means the database determines how many rows to return.
Use smaller values for interactive applications (100-1000 rows). For batch processing, use larger values (5000-10000 rows).
The maximum number of rows to return. The default value is 9223372036854776000.
Note: Adding a LIMIT clause to a SQL query is generally a better method to restrict the number of rows, as the query engine still generates the total number of rows, but only returns this value to the client.
Was this page helpful?

