curl --request POST \
--url https://api.statisfy.com/v1/integrations/{key}/sql \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sql": "<string>",
"end_date": "2023-12-25",
"limit": 100,
"start_date": "2023-12-25"
}
'import requests
url = "https://api.statisfy.com/v1/integrations/{key}/sql"
payload = {
"sql": "<string>",
"end_date": "2023-12-25",
"limit": 100,
"start_date": "2023-12-25"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({sql: '<string>', end_date: '2023-12-25', limit: 100, start_date: '2023-12-25'})
};
fetch('https://api.statisfy.com/v1/integrations/{key}/sql', 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://api.statisfy.com/v1/integrations/{key}/sql",
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([
'sql' => '<string>',
'end_date' => '2023-12-25',
'limit' => 100,
'start_date' => '2023-12-25'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.statisfy.com/v1/integrations/{key}/sql"
payload := strings.NewReader("{\n \"sql\": \"<string>\",\n \"end_date\": \"2023-12-25\",\n \"limit\": 100,\n \"start_date\": \"2023-12-25\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.statisfy.com/v1/integrations/{key}/sql")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sql\": \"<string>\",\n \"end_date\": \"2023-12-25\",\n \"limit\": 100,\n \"start_date\": \"2023-12-25\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.statisfy.com/v1/integrations/{key}/sql")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sql\": \"<string>\",\n \"end_date\": \"2023-12-25\",\n \"limit\": 100,\n \"start_date\": \"2023-12-25\"\n}"
response = http.request(request)
puts response.read_body{
"columns": [
{
"name": "<string>",
"type": "<string>"
}
],
"duration_ms": 123,
"row_count": 123,
"rows": [
{}
],
"tables_referenced": [
"<string>"
],
"truncated": true,
"window_end": "2023-11-07T05:31:56Z",
"window_start": "2023-11-07T05:31:56Z"
}Run SQL against the warehouse
Runs one SELECT against the customer’s warehouse, from Statisfy’s egress IPs, and returns its rows (up to limit, at most 1000). The SQL must stay inside the table allowlist. Date placeholders take the latest complete period (weekly by default) or start_date/end_date. The session is read-only where the warehouse allows it; the warehouse stops the query at 120 seconds (a 504), and BigQuery refuses a scan over max_bytes_billed (10 GB unless set in the config). SQL the warehouse refuses is a 422 with its message; a result over 8 MB is a 422 too. Each tenant runs a couple of these at once per server: past that, a 429 with Retry-After. Needs integrations:write: the rows can be anything the warehouse login can read.
curl --request POST \
--url https://api.statisfy.com/v1/integrations/{key}/sql \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sql": "<string>",
"end_date": "2023-12-25",
"limit": 100,
"start_date": "2023-12-25"
}
'import requests
url = "https://api.statisfy.com/v1/integrations/{key}/sql"
payload = {
"sql": "<string>",
"end_date": "2023-12-25",
"limit": 100,
"start_date": "2023-12-25"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({sql: '<string>', end_date: '2023-12-25', limit: 100, start_date: '2023-12-25'})
};
fetch('https://api.statisfy.com/v1/integrations/{key}/sql', 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://api.statisfy.com/v1/integrations/{key}/sql",
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([
'sql' => '<string>',
'end_date' => '2023-12-25',
'limit' => 100,
'start_date' => '2023-12-25'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.statisfy.com/v1/integrations/{key}/sql"
payload := strings.NewReader("{\n \"sql\": \"<string>\",\n \"end_date\": \"2023-12-25\",\n \"limit\": 100,\n \"start_date\": \"2023-12-25\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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://api.statisfy.com/v1/integrations/{key}/sql")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sql\": \"<string>\",\n \"end_date\": \"2023-12-25\",\n \"limit\": 100,\n \"start_date\": \"2023-12-25\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.statisfy.com/v1/integrations/{key}/sql")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sql\": \"<string>\",\n \"end_date\": \"2023-12-25\",\n \"limit\": 100,\n \"start_date\": \"2023-12-25\"\n}"
response = http.request(request)
puts response.read_body{
"columns": [
{
"name": "<string>",
"type": "<string>"
}
],
"duration_ms": 123,
"row_count": 123,
"rows": [
{}
],
"tables_referenced": [
"<string>"
],
"truncated": true,
"window_end": "2023-11-07T05:31:56Z",
"window_start": "2023-11-07T05:31:56Z"
}Authorizations
An API key, sent as Authorization: Bearer stfy_live_…. See Authentication for how to get one and which scopes it needs.
Body
Response
Successful Response
Was this page helpful?