Run an ad-hoc analytics query
curl --request POST \
--url https://us.api.flexprice.io/v1/analytics/query \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"definition": {
"metrics": [],
"dimensions": [
"<string>"
],
"filters": [
{
"field": "<string>",
"optional": true,
"value": [
"<string>"
]
}
],
"limit": 123,
"name": "<string>",
"sort": [
{
"field": "<string>"
}
],
"time": {
"range": "<string>"
},
"variables": [
{
"default": [
"<string>"
],
"name": "<string>",
"required": true
}
]
},
"variables": {}
}
'import requests
url = "https://us.api.flexprice.io/v1/analytics/query"
payload = {
"definition": {
"metrics": [],
"dimensions": ["<string>"],
"filters": [
{
"field": "<string>",
"optional": True,
"value": ["<string>"]
}
],
"limit": 123,
"name": "<string>",
"sort": [{ "field": "<string>" }],
"time": { "range": "<string>" },
"variables": [
{
"default": ["<string>"],
"name": "<string>",
"required": True
}
]
},
"variables": {}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
definition: {
metrics: [],
dimensions: ['<string>'],
filters: [{field: '<string>', optional: true, value: ['<string>']}],
limit: 123,
name: '<string>',
sort: [{field: '<string>'}],
time: {range: '<string>'},
variables: [{default: ['<string>'], name: '<string>', required: true}]
},
variables: {}
})
};
fetch('https://us.api.flexprice.io/v1/analytics/query', 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://us.api.flexprice.io/v1/analytics/query",
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([
'definition' => [
'metrics' => [
],
'dimensions' => [
'<string>'
],
'filters' => [
[
'field' => '<string>',
'optional' => true,
'value' => [
'<string>'
]
]
],
'limit' => 123,
'name' => '<string>',
'sort' => [
[
'field' => '<string>'
]
],
'time' => [
'range' => '<string>'
],
'variables' => [
[
'default' => [
'<string>'
],
'name' => '<string>',
'required' => true
]
]
],
'variables' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://us.api.flexprice.io/v1/analytics/query"
payload := strings.NewReader("{\n \"definition\": {\n \"metrics\": [],\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"optional\": true,\n \"value\": [\n \"<string>\"\n ]\n }\n ],\n \"limit\": 123,\n \"name\": \"<string>\",\n \"sort\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"time\": {\n \"range\": \"<string>\"\n },\n \"variables\": [\n {\n \"default\": [\n \"<string>\"\n ],\n \"name\": \"<string>\",\n \"required\": true\n }\n ]\n },\n \"variables\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://us.api.flexprice.io/v1/analytics/query")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"definition\": {\n \"metrics\": [],\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"optional\": true,\n \"value\": [\n \"<string>\"\n ]\n }\n ],\n \"limit\": 123,\n \"name\": \"<string>\",\n \"sort\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"time\": {\n \"range\": \"<string>\"\n },\n \"variables\": [\n {\n \"default\": [\n \"<string>\"\n ],\n \"name\": \"<string>\",\n \"required\": true\n }\n ]\n },\n \"variables\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us.api.flexprice.io/v1/analytics/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"definition\": {\n \"metrics\": [],\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"optional\": true,\n \"value\": [\n \"<string>\"\n ]\n }\n ],\n \"limit\": 123,\n \"name\": \"<string>\",\n \"sort\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"time\": {\n \"range\": \"<string>\"\n },\n \"variables\": [\n {\n \"default\": [\n \"<string>\"\n ],\n \"name\": \"<string>\",\n \"required\": true\n }\n ]\n },\n \"variables\": {}\n}"
response = http.request(request)
puts response.read_body{
"columns": [
{
"currency": "<string>",
"name": "<string>",
"role": "dimension",
"type": "string"
}
],
"meta": {
"query_source": "<string>"
},
"rows": [
[
"<string>"
]
]
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Analytics
Run an ad-hoc analytics query
Resolves the given view definition against the supplied variables and executes it.
POST
/
analytics
/
query
Run an ad-hoc analytics query
curl --request POST \
--url https://us.api.flexprice.io/v1/analytics/query \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"definition": {
"metrics": [],
"dimensions": [
"<string>"
],
"filters": [
{
"field": "<string>",
"optional": true,
"value": [
"<string>"
]
}
],
"limit": 123,
"name": "<string>",
"sort": [
{
"field": "<string>"
}
],
"time": {
"range": "<string>"
},
"variables": [
{
"default": [
"<string>"
],
"name": "<string>",
"required": true
}
]
},
"variables": {}
}
'import requests
url = "https://us.api.flexprice.io/v1/analytics/query"
payload = {
"definition": {
"metrics": [],
"dimensions": ["<string>"],
"filters": [
{
"field": "<string>",
"optional": True,
"value": ["<string>"]
}
],
"limit": 123,
"name": "<string>",
"sort": [{ "field": "<string>" }],
"time": { "range": "<string>" },
"variables": [
{
"default": ["<string>"],
"name": "<string>",
"required": True
}
]
},
"variables": {}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
definition: {
metrics: [],
dimensions: ['<string>'],
filters: [{field: '<string>', optional: true, value: ['<string>']}],
limit: 123,
name: '<string>',
sort: [{field: '<string>'}],
time: {range: '<string>'},
variables: [{default: ['<string>'], name: '<string>', required: true}]
},
variables: {}
})
};
fetch('https://us.api.flexprice.io/v1/analytics/query', 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://us.api.flexprice.io/v1/analytics/query",
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([
'definition' => [
'metrics' => [
],
'dimensions' => [
'<string>'
],
'filters' => [
[
'field' => '<string>',
'optional' => true,
'value' => [
'<string>'
]
]
],
'limit' => 123,
'name' => '<string>',
'sort' => [
[
'field' => '<string>'
]
],
'time' => [
'range' => '<string>'
],
'variables' => [
[
'default' => [
'<string>'
],
'name' => '<string>',
'required' => true
]
]
],
'variables' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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://us.api.flexprice.io/v1/analytics/query"
payload := strings.NewReader("{\n \"definition\": {\n \"metrics\": [],\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"optional\": true,\n \"value\": [\n \"<string>\"\n ]\n }\n ],\n \"limit\": 123,\n \"name\": \"<string>\",\n \"sort\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"time\": {\n \"range\": \"<string>\"\n },\n \"variables\": [\n {\n \"default\": [\n \"<string>\"\n ],\n \"name\": \"<string>\",\n \"required\": true\n }\n ]\n },\n \"variables\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<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://us.api.flexprice.io/v1/analytics/query")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"definition\": {\n \"metrics\": [],\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"optional\": true,\n \"value\": [\n \"<string>\"\n ]\n }\n ],\n \"limit\": 123,\n \"name\": \"<string>\",\n \"sort\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"time\": {\n \"range\": \"<string>\"\n },\n \"variables\": [\n {\n \"default\": [\n \"<string>\"\n ],\n \"name\": \"<string>\",\n \"required\": true\n }\n ]\n },\n \"variables\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us.api.flexprice.io/v1/analytics/query")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"definition\": {\n \"metrics\": [],\n \"dimensions\": [\n \"<string>\"\n ],\n \"filters\": [\n {\n \"field\": \"<string>\",\n \"optional\": true,\n \"value\": [\n \"<string>\"\n ]\n }\n ],\n \"limit\": 123,\n \"name\": \"<string>\",\n \"sort\": [\n {\n \"field\": \"<string>\"\n }\n ],\n \"time\": {\n \"range\": \"<string>\"\n },\n \"variables\": [\n {\n \"default\": [\n \"<string>\"\n ],\n \"name\": \"<string>\",\n \"required\": true\n }\n ]\n },\n \"variables\": {}\n}"
response = http.request(request)
puts response.read_body{
"columns": [
{
"currency": "<string>",
"name": "<string>",
"role": "dimension",
"type": "string"
}
],
"meta": {
"query_source": "<string>"
},
"rows": [
[
"<string>"
]
]
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Authorizations
Enter your API key in the format x-api-key <api-key>*
Body
application/json
Analytics query request

