Get latest Contextual Bandit results
Returns the latest contextual-bandit stats engine output (per-context responses tagged with their leaf, the per-leaf targeting conditions, and per-leaf aggregated stats), the overall (marginal) variation weights across all contexts, the health checks (traffic, SRM, multiple exposures) computed by that same run, and the status of the most recent snapshot run for the contextual bandit. Same payload the GrowthBook UI uses to render the contextual bandit results and health tabs.
GET
/
v1
/
contextual-bandits
/
{id}
/
results
cURL
curl -X GET 'https://api.growthbook.io/api/v1/contextual-bandits/{id}/results' \
-H 'Authorization: Bearer YOUR_API_KEY'import requests
url = "https://api.growthbook.io/api/v1/contextual-bandits/{id}/results"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.growthbook.io/api/v1/contextual-bandits/{id}/results', 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/contextual-bandits/{id}/results",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.growthbook.io/api/v1/contextual-bandits/{id}/results"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.growthbook.io/api/v1/contextual-bandits/{id}/results")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.growthbook.io/api/v1/contextual-bandits/{id}/results")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"contextualBanditSnapshot": {
"attributes": [
"<string>"
],
"responses": [
"<unknown>"
],
"leaf_map": [
"<unknown>"
],
"leaf_stats": [
"<unknown>"
],
"sse_trajectory": [
"<unknown>"
],
"bic_trajectory": [
"<unknown>"
]
},
"overallWeights": [
{
"variationId": "<string>",
"weight": 123
}
],
"results": {
"attributes": [
"<string>"
],
"sseTrajectory": [
{
"numSplits": 1,
"totalSse": 123,
"split": {
"leafClauses": [
{
"attribute": "<string>",
"levels": [
"<string>"
],
"operator": "in"
}
],
"attribute": "<string>",
"leftLevels": [
"<string>"
],
"rightLevels": [
"<string>"
]
}
}
],
"overall": {
"variations": [
{
"variationId": "<string>",
"weight": 123,
"mean": 123,
"users": 123,
"variationName": "<string>"
}
]
},
"leaves": [
{
"leafId": 123,
"updateMessage": "<string>",
"error": "<string>",
"clauses": [
{
"attribute": "<string>",
"levels": [
"<string>"
],
"operator": "in"
}
],
"variations": [
{
"variationId": "<string>",
"weight": 123,
"bestArmProbability": 123,
"users": 123,
"mean": 123,
"variance": 123,
"variationName": "<string>"
}
],
"contexts": [
{
"attributes": {},
"variations": [
{
"variationId": "<string>",
"users": 123,
"mean": 123,
"variance": 123,
"variationName": "<string>"
}
]
}
]
}
],
"snapshotId": "<string>",
"dateCreated": "<string>",
"health": {
"variations": [
{
"variationId": "<string>",
"weight": 123,
"variationName": "<string>"
}
],
"traffic": {
"overall": {
"name": "<string>",
"srm": 123,
"variationUnits": [
123
]
},
"dimension": {},
"error": "<string>"
},
"srm": {
"statistic": 123,
"pValue": 123,
"degreesOfFreedom": 1,
"latestPeriod": {
"banditVersion": "<string>",
"leaves": [
{
"leafId": "<string>",
"observed": [
123
],
"expected": [
123
]
}
]
}
},
"multipleExposures": 123
}
},
"latest": {
"id": "<string>",
"status": "running",
"error": "<string>",
"queries": [
{
"query": "<string>",
"status": "queued",
"name": "<string>"
}
],
"runStarted": "<string>",
"dateCreated": "<string>",
"multipleExposures": 123,
"type": "<string>",
"triggeredBy": "<string>"
}
}Authorizations
bearerAuthbasicAuth
Was this page helpful?
⌘I
cURL
curl -X GET 'https://api.growthbook.io/api/v1/contextual-bandits/{id}/results' \
-H 'Authorization: Bearer YOUR_API_KEY'import requests
url = "https://api.growthbook.io/api/v1/contextual-bandits/{id}/results"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.growthbook.io/api/v1/contextual-bandits/{id}/results', 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/contextual-bandits/{id}/results",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.growthbook.io/api/v1/contextual-bandits/{id}/results"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.growthbook.io/api/v1/contextual-bandits/{id}/results")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.growthbook.io/api/v1/contextual-bandits/{id}/results")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"contextualBanditSnapshot": {
"attributes": [
"<string>"
],
"responses": [
"<unknown>"
],
"leaf_map": [
"<unknown>"
],
"leaf_stats": [
"<unknown>"
],
"sse_trajectory": [
"<unknown>"
],
"bic_trajectory": [
"<unknown>"
]
},
"overallWeights": [
{
"variationId": "<string>",
"weight": 123
}
],
"results": {
"attributes": [
"<string>"
],
"sseTrajectory": [
{
"numSplits": 1,
"totalSse": 123,
"split": {
"leafClauses": [
{
"attribute": "<string>",
"levels": [
"<string>"
],
"operator": "in"
}
],
"attribute": "<string>",
"leftLevels": [
"<string>"
],
"rightLevels": [
"<string>"
]
}
}
],
"overall": {
"variations": [
{
"variationId": "<string>",
"weight": 123,
"mean": 123,
"users": 123,
"variationName": "<string>"
}
]
},
"leaves": [
{
"leafId": 123,
"updateMessage": "<string>",
"error": "<string>",
"clauses": [
{
"attribute": "<string>",
"levels": [
"<string>"
],
"operator": "in"
}
],
"variations": [
{
"variationId": "<string>",
"weight": 123,
"bestArmProbability": 123,
"users": 123,
"mean": 123,
"variance": 123,
"variationName": "<string>"
}
],
"contexts": [
{
"attributes": {},
"variations": [
{
"variationId": "<string>",
"users": 123,
"mean": 123,
"variance": 123,
"variationName": "<string>"
}
]
}
]
}
],
"snapshotId": "<string>",
"dateCreated": "<string>",
"health": {
"variations": [
{
"variationId": "<string>",
"weight": 123,
"variationName": "<string>"
}
],
"traffic": {
"overall": {
"name": "<string>",
"srm": 123,
"variationUnits": [
123
]
},
"dimension": {},
"error": "<string>"
},
"srm": {
"statistic": 123,
"pValue": 123,
"degreesOfFreedom": 1,
"latestPeriod": {
"banditVersion": "<string>",
"leaves": [
{
"leafId": "<string>",
"observed": [
123
],
"expected": [
123
]
}
]
}
},
"multipleExposures": 123
}
},
"latest": {
"id": "<string>",
"status": "running",
"error": "<string>",
"queries": [
{
"query": "<string>",
"status": "queued",
"name": "<string>"
}
],
"runStarted": "<string>",
"dateCreated": "<string>",
"multipleExposures": 123,
"type": "<string>",
"triggeredBy": "<string>"
}
}
