GET /api/v1/experiments
Fetch experiments and their weighted variants. The SDK calls this endpoint on initialization to retrieve active experiment configurations.
Request
GET https://xaiku.com/api/v1/experiments
Headers
| Header | Required | Description |
|---|---|---|
X-public-key | Yes | Your public key (pk_*) |
X-experiment-ids | No | Comma-separated list of experiment IDs to filter by |
X-xaiku-test | No | Set to 'true' to bypass the live gate (test mode) |
X-experiment-ids is built from the array of experiment IDs passed to the SDK at initialization. When omitted, all experiments associated with the key are returned.
Test mode is activated automatically when localStorage.getItem('xaiku_test') equals 'true' in the browser.
Response
Returns a JSON object with a experiments array. Each experiment contains weighted variants, and each variant includes a parts map, weight, id, and control flag.
{
"experiments": [
{
"id": "exp_abc123",
"variants": [
{
"id": "var_001",
"weight": 50,
"control": true,
"parts": {
"headline": "Welcome to our site",
"cta": "Get started"
}
},
{
"id": "var_002",
"weight": 50,
"control": false,
"parts": {
"headline": "Try something new",
"cta": "Sign up now"
}
}
]
}
]
}
Variant Fields
| Field | Type | Description |
|---|---|---|
id | string | Unique variant identifier |
weight | number | Traffic allocation weight (variants within a experiment sum to 100) |
control | boolean | Whether this variant is the control group |
parts | object | Map of field names to text content |
Examples
curl
curl -X GET "https://xaiku.com/api/v1/experiments" \
-H "Accept: application/json" \
-H "X-public-key: pk_dGhpcyBpcyBhIHRlc3Q" \
-H "X-experiment-ids: exp_abc123,exp_def456"
JavaScript fetch
const response = await fetch('https://xaiku.com/api/v1/experiments', {
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
'X-public-key': 'pk_dGhpcyBpcyBhIHRlc3Q',
'X-experiment-ids': 'exp_abc123,exp_def456',
},
});
const { experiments } = await response.json();