GeezerVison is showing docs.cube.dev — SQL query - Cube Documentation curl --request POST \
--url https://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"timezone": "<string>",
"params": [
{
"name": "<string>",
"value": "<string>"
}
],
"cache": "stale-if-slow"
}
'
import requests
url = "https://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql"
payload = {
"query": "<string>",
"timezone": "<string>",
"params": [
{
"name": "<string>",
"value": "<string>"
}
],
"cache": "stale-if-slow"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
timezone: '<string>',
params: [{name: '<string>', value: '<string>'}],
cache: 'stale-if-slow'
})
};
fetch('https://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql', 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://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql",
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([
'query' => '<string>',
'timezone' => '<string>',
'params' => [
[
'name' => '<string>',
'value' => '<string>'
]
],
'cache' => 'stale-if-slow'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"timezone\": \"<string>\",\n \"params\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"cache\": \"stale-if-slow\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"timezone\": \"<string>\",\n \"params\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"cache\": \"stale-if-slow\"\n}")
.asString();
require 'uri'
require 'net/http'
url = URI("https://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"timezone\": \"<string>\",\n \"params\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"cache\": \"stale-if-slow\"\n}"
response = http.request(request)
puts response.read_body
{
"schema": [
{
"name": "value",
"column_type": "Int64"
}
],
"lastRefreshTime": "2025-01-13T12:00:00.000Z",
"usedPreAggregations": {
"schema.orders_main20240101": {
"preAggregationId": "Orders.main",
"lastUpdatedAt": 1712000000000,
"type": "rollup"
}
}
} curl --request POST \
--url https://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "<string>",
"timezone": "<string>",
"params": [
{
"name": "<string>",
"value": "<string>"
}
],
"cache": "stale-if-slow"
}
'
import requests
url = "https://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql"
payload = {
"query": "<string>",
"timezone": "<string>",
"params": [
{
"name": "<string>",
"value": "<string>"
}
],
"cache": "stale-if-slow"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
query: '<string>',
timezone: '<string>',
params: [{name: '<string>', value: '<string>'}],
cache: 'stale-if-slow'
})
};
fetch('https://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql', 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://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql",
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([
'query' => '<string>',
'timezone' => '<string>',
'params' => [
[
'name' => '<string>',
'value' => '<string>'
]
],
'cache' => 'stale-if-slow'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$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://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql"
payload := strings.NewReader("{\n \"query\": \"<string>\",\n \"timezone\": \"<string>\",\n \"params\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"cache\": \"stale-if-slow\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
HttpResponse<String> response = Unirest.post("https://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"<string>\",\n \"timezone\": \"<string>\",\n \"params\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"cache\": \"stale-if-slow\"\n}")
.asString();
require 'uri'
require 'net/http'
url = URI("https://{deployment}.{region}.cubecloudapp.dev/cubejs-api/v1/cubesql")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"<string>\",\n \"timezone\": \"<string>\",\n \"params\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"cache\": \"stale-if-slow\"\n}"
response = http.request(request)
puts response.read_body
{
"schema": [
{
"name": "value",
"column_type": "Int64"
}
],
"lastRefreshTime": "2025-01-13T12:00:00.000Z",
"usedPreAggregations": {
"schema.orders_main20240101": {
"preAggregationId": "Orders.main",
"lastUpdatedAt": 1712000000000,
"type": "rollup"
}
}
} Cube API token (a JWT). Sent directly in the Authorization header, e.g. Authorization: <CUBE_API_TOKEN> (no "Bearer" prefix). Time zone for the query in TZ database name format, e.g. America/Los_Angeles. Values of the :name parameters in query, e.g. [{"name": "status", "value": "shipped", "type": "string"}]. number, string, time (an ISO 8601 timestamp string) and boolean values are literals of that type; a time offset is converted to UTC, and a time without one is UTC. An expr value is a SQL expression, which can't contain subqueries or parameters. A null value is SQL NULL of any type. Names are case-sensitive: :Status takes the Status value. Each name may appear only once. Every parameter in query needs a value; values not used in query are ignored, but must still match their type. cache enum<string> default:stale-if-slow In-memory cache strategy (see Cache control):
stale-if-slow (default): if refresh keys are up to date, return the cached value; if expired, fetch fresh data but fall back to the stale value when the source query is slow.
stale-while-revalidate: if expired, return stale data immediately and refresh the cache in the background.
must-revalidate: if expired, always wait for fresh data from the source, even if slow.
no-cache: skip refresh-key checks and always query the data source.
Available options: stale-if-slow,
stale-while-revalidate,
must-revalidate,
no-cache
Newline-delimited JSON stream. The first line carries schema (and optionally lastRefreshTime, external and usedPreAggregations); subsequent lines carry data chunks. |