Create a Metric based visualization
POST
/
v1
/
product-analytics
/
metric-exploration
cURL
curl -X POST 'https://api.growthbook.io/api/v1/product-analytics/metric-exploration' \
-H 'Authorization: Bearer YOUR_API_KEY'import requests
url = "https://api.growthbook.io/api/v1/product-analytics/metric-exploration"
payload = {
"datasource": "<string>",
"dimensions": [
{
"dimensionType": "date",
"column": "<string>"
}
],
"dateRange": {
"lookbackValue": 123,
"startDate": "<string>",
"endDate": "<string>"
},
"type": "metric",
"dataset": {
"type": "metric",
"values": [
{
"name": "<string>",
"rowFilters": [
{
"column": "<string>",
"values": ["<string>"]
}
],
"type": "metric",
"metricId": "<string>",
"unit": "<string>",
"denominatorUnit": "<string>"
}
]
}
}
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({
datasource: '<string>',
dimensions: [{dimensionType: 'date', column: '<string>'}],
dateRange: {lookbackValue: 123, startDate: '<string>', endDate: '<string>'},
type: 'metric',
dataset: {
type: 'metric',
values: [
{
name: '<string>',
rowFilters: [{column: '<string>', values: ['<string>']}],
type: 'metric',
metricId: '<string>',
unit: '<string>',
denominatorUnit: '<string>'
}
]
}
})
};
fetch('https://api.growthbook.io/api/v1/product-analytics/metric-exploration', 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.growthbook.io/api/v1/product-analytics/metric-exploration",
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([
'datasource' => '<string>',
'dimensions' => [
[
'dimensionType' => 'date',
'column' => '<string>'
]
],
'dateRange' => [
'lookbackValue' => 123,
'startDate' => '<string>',
'endDate' => '<string>'
],
'type' => 'metric',
'dataset' => [
'type' => 'metric',
'values' => [
[
'name' => '<string>',
'rowFilters' => [
[
'column' => '<string>',
'values' => [
'<string>'
]
]
],
'type' => 'metric',
'metricId' => '<string>',
'unit' => '<string>',
'denominatorUnit' => '<string>'
]
]
]
]),
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.growthbook.io/api/v1/product-analytics/metric-exploration"
payload := strings.NewReader("{\n \"datasource\": \"<string>\",\n \"dimensions\": [\n {\n \"dimensionType\": \"date\",\n \"column\": \"<string>\"\n }\n ],\n \"dateRange\": {\n \"lookbackValue\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n },\n \"type\": \"metric\",\n \"dataset\": {\n \"type\": \"metric\",\n \"values\": [\n {\n \"name\": \"<string>\",\n \"rowFilters\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"type\": \"metric\",\n \"metricId\": \"<string>\",\n \"unit\": \"<string>\",\n \"denominatorUnit\": \"<string>\"\n }\n ]\n }\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.growthbook.io/api/v1/product-analytics/metric-exploration")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"datasource\": \"<string>\",\n \"dimensions\": [\n {\n \"dimensionType\": \"date\",\n \"column\": \"<string>\"\n }\n ],\n \"dateRange\": {\n \"lookbackValue\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n },\n \"type\": \"metric\",\n \"dataset\": {\n \"type\": \"metric\",\n \"values\": [\n {\n \"name\": \"<string>\",\n \"rowFilters\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"type\": \"metric\",\n \"metricId\": \"<string>\",\n \"unit\": \"<string>\",\n \"denominatorUnit\": \"<string>\"\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.growthbook.io/api/v1/product-analytics/metric-exploration")
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 \"datasource\": \"<string>\",\n \"dimensions\": [\n {\n \"dimensionType\": \"date\",\n \"column\": \"<string>\"\n }\n ],\n \"dateRange\": {\n \"lookbackValue\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n },\n \"type\": \"metric\",\n \"dataset\": {\n \"type\": \"metric\",\n \"values\": [\n {\n \"name\": \"<string>\",\n \"rowFilters\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"type\": \"metric\",\n \"metricId\": \"<string>\",\n \"unit\": \"<string>\",\n \"denominatorUnit\": \"<string>\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"exploration": {
"id": "<string>",
"dateCreated": "2023-11-07T05:31:56Z",
"dateUpdated": "2023-11-07T05:31:56Z",
"datasource": "<string>",
"dateStart": "<string>",
"dateEnd": "<string>",
"result": {
"rows": [
{
"dimensions": [
"<string>"
],
"values": [
{
"metricId": "<string>",
"numerator": 123,
"denominator": 123
}
]
}
]
},
"config": {
"datasource": "<string>",
"dimensions": [
{
"dimensionType": "date",
"column": "<string>"
}
],
"dateRange": {
"lookbackValue": 123,
"startDate": "<string>",
"endDate": "<string>"
},
"type": "metric",
"dataset": {
"type": "metric",
"values": [
{
"name": "<string>",
"rowFilters": [
{
"column": "<string>",
"values": [
"<string>"
]
}
],
"type": "metric",
"metricId": "<string>",
"unit": "<string>",
"denominatorUnit": "<string>"
}
]
}
},
"error": "<string>"
},
"query": {
"id": "<string>",
"organization": "<string>",
"datasource": "<string>",
"language": "<string>",
"query": "<string>",
"queryType": "<string>",
"createdAt": "<string>",
"startedAt": "<string>",
"externalId": "<string>",
"dependencies": [
"<string>"
],
"runAtEnd": true
},
"explorationUrl": "<string>",
"message": "<string>"
}Authorizations
bearerAuthbasicAuth
If using Bearer auth, pass the Secret Key as the token:
curl https://api.growthbook.io/api/v1/features -H "Authorization: Bearer secret_abc123DEF456"
Query Parameters
Controls cache behavior for this exploration: preferred (default) returns a cached result if one exists, otherwise runs a new query; never always runs a new query, ignoring any cached results; required only returns a cached result, if none exists returns exploration: null with a message
Available options:
preferred, required, never Body
application/json
ID of the datasource to query
- Option 1
- Option 2
- Option 3
- Option 4
Show child attributes
Show child attributes
Available options:
line, area, timeseries-table, table, bar, stackedBar, horizontalBar, stackedHorizontalBar, bigNumber Show child attributes
Show child attributes
Allowed value:
"metric"Show child attributes
Show child attributes
Available options:
total, per_unit Response
200 - application/json
Resource created
Was this page helpful?
⌘I
cURL
curl -X POST 'https://api.growthbook.io/api/v1/product-analytics/metric-exploration' \
-H 'Authorization: Bearer YOUR_API_KEY'import requests
url = "https://api.growthbook.io/api/v1/product-analytics/metric-exploration"
payload = {
"datasource": "<string>",
"dimensions": [
{
"dimensionType": "date",
"column": "<string>"
}
],
"dateRange": {
"lookbackValue": 123,
"startDate": "<string>",
"endDate": "<string>"
},
"type": "metric",
"dataset": {
"type": "metric",
"values": [
{
"name": "<string>",
"rowFilters": [
{
"column": "<string>",
"values": ["<string>"]
}
],
"type": "metric",
"metricId": "<string>",
"unit": "<string>",
"denominatorUnit": "<string>"
}
]
}
}
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({
datasource: '<string>',
dimensions: [{dimensionType: 'date', column: '<string>'}],
dateRange: {lookbackValue: 123, startDate: '<string>', endDate: '<string>'},
type: 'metric',
dataset: {
type: 'metric',
values: [
{
name: '<string>',
rowFilters: [{column: '<string>', values: ['<string>']}],
type: 'metric',
metricId: '<string>',
unit: '<string>',
denominatorUnit: '<string>'
}
]
}
})
};
fetch('https://api.growthbook.io/api/v1/product-analytics/metric-exploration', 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.growthbook.io/api/v1/product-analytics/metric-exploration",
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([
'datasource' => '<string>',
'dimensions' => [
[
'dimensionType' => 'date',
'column' => '<string>'
]
],
'dateRange' => [
'lookbackValue' => 123,
'startDate' => '<string>',
'endDate' => '<string>'
],
'type' => 'metric',
'dataset' => [
'type' => 'metric',
'values' => [
[
'name' => '<string>',
'rowFilters' => [
[
'column' => '<string>',
'values' => [
'<string>'
]
]
],
'type' => 'metric',
'metricId' => '<string>',
'unit' => '<string>',
'denominatorUnit' => '<string>'
]
]
]
]),
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.growthbook.io/api/v1/product-analytics/metric-exploration"
payload := strings.NewReader("{\n \"datasource\": \"<string>\",\n \"dimensions\": [\n {\n \"dimensionType\": \"date\",\n \"column\": \"<string>\"\n }\n ],\n \"dateRange\": {\n \"lookbackValue\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n },\n \"type\": \"metric\",\n \"dataset\": {\n \"type\": \"metric\",\n \"values\": [\n {\n \"name\": \"<string>\",\n \"rowFilters\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"type\": \"metric\",\n \"metricId\": \"<string>\",\n \"unit\": \"<string>\",\n \"denominatorUnit\": \"<string>\"\n }\n ]\n }\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.growthbook.io/api/v1/product-analytics/metric-exploration")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"datasource\": \"<string>\",\n \"dimensions\": [\n {\n \"dimensionType\": \"date\",\n \"column\": \"<string>\"\n }\n ],\n \"dateRange\": {\n \"lookbackValue\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n },\n \"type\": \"metric\",\n \"dataset\": {\n \"type\": \"metric\",\n \"values\": [\n {\n \"name\": \"<string>\",\n \"rowFilters\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"type\": \"metric\",\n \"metricId\": \"<string>\",\n \"unit\": \"<string>\",\n \"denominatorUnit\": \"<string>\"\n }\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.growthbook.io/api/v1/product-analytics/metric-exploration")
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 \"datasource\": \"<string>\",\n \"dimensions\": [\n {\n \"dimensionType\": \"date\",\n \"column\": \"<string>\"\n }\n ],\n \"dateRange\": {\n \"lookbackValue\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\"\n },\n \"type\": \"metric\",\n \"dataset\": {\n \"type\": \"metric\",\n \"values\": [\n {\n \"name\": \"<string>\",\n \"rowFilters\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ]\n }\n ],\n \"type\": \"metric\",\n \"metricId\": \"<string>\",\n \"unit\": \"<string>\",\n \"denominatorUnit\": \"<string>\"\n }\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"exploration": {
"id": "<string>",
"dateCreated": "2023-11-07T05:31:56Z",
"dateUpdated": "2023-11-07T05:31:56Z",
"datasource": "<string>",
"dateStart": "<string>",
"dateEnd": "<string>",
"result": {
"rows": [
{
"dimensions": [
"<string>"
],
"values": [
{
"metricId": "<string>",
"numerator": 123,
"denominator": 123
}
]
}
]
},
"config": {
"datasource": "<string>",
"dimensions": [
{
"dimensionType": "date",
"column": "<string>"
}
],
"dateRange": {
"lookbackValue": 123,
"startDate": "<string>",
"endDate": "<string>"
},
"type": "metric",
"dataset": {
"type": "metric",
"values": [
{
"name": "<string>",
"rowFilters": [
{
"column": "<string>",
"values": [
"<string>"
]
}
],
"type": "metric",
"metricId": "<string>",
"unit": "<string>",
"denominatorUnit": "<string>"
}
]
}
},
"error": "<string>"
},
"query": {
"id": "<string>",
"organization": "<string>",
"datasource": "<string>",
"language": "<string>",
"query": "<string>",
"queryType": "<string>",
"createdAt": "<string>",
"startedAt": "<string>",
"externalId": "<string>",
"dependencies": [
"<string>"
],
"runAtEnd": true
},
"explorationUrl": "<string>",
"message": "<string>"
}
