A/B Testing API (2.0.0)
Download OpenAPI specification:Download
The Algolia A/B Testing API lets you manage your Algolia A/B tests to optimize your search experience.
The base URLs for requests to the A/B testing API are:
https://analytics.us.algolia.com
(alias:https://analytics.algolia.com
)https://analytics.de.algolia.com
Use the URL that matches your analytics region.
All requests must use HTTPS.
Access to the A/B testing API is available as part of the Premium or Elevate plans.
To authenticate your API requests, add these headers:
x-algolia-application-id
. Your Algolia application ID.x-algolia-api-key
. An API key with the necessary permissions to make the request. The required access control list (ACL) to make a request is listed in each endpoint's reference.
You can find your application ID and API key in the Algolia dashboard.
You can make up to 100 requests per minute per app to the A/B testing API. The response includes headers with information about the limits.
Query parameters must be URL-encoded.
Non-ASCII characters must be UTF-8 encoded.
Plus characters (+
) are interpreted as spaces.
The A/B testing API returns JSON responses. Since JSON doesn't guarantee any specific ordering, don't rely on the order of attributes in the API response.
Successful responses return a 2xx
status. Client errors return a 4xx
status. Server errors are indicated by a 5xx
status.
Error responses have a message
property with more information.
The current version of the A/B Testing API is version 2, as indicated by the /2/
in each endpoint's URL.
Manage A/B tests.
A/B tests are configurations of two indices, usually your production index and an index with different settings that you want to test.
Create an A/B test
Creates a new A/B test.
Request Body schema: application/jsonrequired
endAt required | string End date and time of the A/B test, in RFC 3339 format. |
name required | string A/B test name. |
required | Array of abTestsVariant (object) or abTestsVariantSearchParams (object) = 2 items A/B test variants. |
Responses
Request samples
- C#
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
// Initialize the client var client = new AbtestingClient( new AbtestingConfig("YOUR_APP_ID", "YOUR_API_KEY", "YOUR_APP_ID_REGION") ); // Call the API var response = await client.AddABTestsAsync( new AddABTestsRequest { EndAt = "2022-12-31T00:00:00.000Z", Name = "myABTest", Variants = new List<AddABTestsVariant> { new AddABTestsVariant( new AbTestsVariant { Index = "AB_TEST_1", TrafficPercentage = 30, } ), new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_2", TrafficPercentage = 50, }) }, } );
Response samples
- 200
- 400
- 402
- 403
- 404
{- "index": "delcourt_production",
- "abTestID": 224,
- "taskID": 1514562690001
}
List all A/B tests
Lists all A/B tests you configured for this application.
query Parameters
indexPrefix | string Example: indexPrefix=dev_ Index name prefix. Only A/B tests for indices starting with this string are included in the response. |
indexSuffix | string Example: indexSuffix=_development Index name suffix. Only A/B tests for indices ending with this string are included in the response. |
limit | integer Default: 10 Number of items to return. |
offset | integer >= 0 Default: 0 Position of the first item to return. |
Responses
Request samples
- C#
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
// Initialize the client var client = new AbtestingClient( new AbtestingConfig("YOUR_APP_ID", "YOUR_API_KEY", "YOUR_APP_ID_REGION") ); // Call the API var response = await client.ListABTestsAsync();
Response samples
- 200
- 400
- 402
- 403
- 404
{- "abtests": [
- {
- "abTestID": 224,
- "clickSignificance": 1,
- "conversionSignificance": 1,
- "addToCartSignificance": 1,
- "purchaseSignificance": 1,
- "revenueSignificance": {
- "USD": 1,
- "EUR": 0.87
}, - "updatedAt": "2023-06-15T15:06:44.400601Z",
- "createdAt": "2023-06-15T15:06:04.249906Z",
- "endAt": "2023-06-17T00:00:00Z",
- "name": "Custom ranking sales rank test",
- "status": "active",
- "variants": [
- {
- "addToCartCount": 0,
- "addToCartRate": 0,
- "averageClickPosition": 0,
- "clickCount": 65131,
- "clickThroughRate": 0.22219857724813036,
- "conversionCount": 4785,
- "conversionRate": 0.14546725846658964,
- "currencies": {
- "USD": {
- "currency": "USD",
- "revenue": 120,
- "mean": 53.7,
- "standardDeviation": 12.3
}, - "EUR": {
- "currency": "EUR",
- "revenue": 100,
- "mean": 43.7,
- "standardDeviation": 10.3
}
}, - "description": "Current production index",
- "estimatedSampleSize": 0,
- "filterEffects": {
- "outliers": {
- "usersCount": 1,
- "trackedSearchesCount": 237
}, - "emptySearch": {
- "usersCount": 1,
- "trackedSearchesCount": 237
}
}, - "index": "delcourt_production",
- "noResultCount": 0,
- "purchaseCount": 0,
- "purchaseRate": 0,
- "searchCount": 86269,
- "trackedSearchCount": 2,
- "trafficPercentage": 60,
- "userCount": 55501,
- "trackedUserCount": 55501
}
], - "configuration": {
- "outliers": {
- "exclude": true
}, - "emptySearch": {
- "exclude": true
}, - "minimumDetectableEffect": {
- "size": 1,
- "effect": "addToCartRate"
}
}
}
], - "count": 10,
- "total": 12
}
Retrieve A/B test details
Retrieves the details for an A/B test by its ID.
path Parameters
id required | integer Example: 224 Unique A/B test identifier. |
Responses
Request samples
- C#
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
// Initialize the client var client = new AbtestingClient( new AbtestingConfig("YOUR_APP_ID", "YOUR_API_KEY", "YOUR_APP_ID_REGION") ); // Call the API var response = await client.GetABTestAsync(42);
Response samples
- 200
- 400
- 402
- 403
- 404
{- "abTestID": 224,
- "clickSignificance": 1,
- "conversionSignificance": 1,
- "addToCartSignificance": 1,
- "purchaseSignificance": 1,
- "revenueSignificance": {
- "USD": 1,
- "EUR": 0.87
}, - "updatedAt": "2023-06-15T15:06:44.400601Z",
- "createdAt": "2023-06-15T15:06:04.249906Z",
- "endAt": "2023-06-17T00:00:00Z",
- "name": "Custom ranking sales rank test",
- "status": "active",
- "variants": [
- {
- "addToCartCount": 0,
- "addToCartRate": 0,
- "averageClickPosition": 0,
- "clickCount": 65131,
- "clickThroughRate": 0.22219857724813036,
- "conversionCount": 4785,
- "conversionRate": 0.14546725846658964,
- "currencies": {
- "USD": {
- "currency": "USD",
- "revenue": 120,
- "mean": 53.7,
- "standardDeviation": 12.3
}, - "EUR": {
- "currency": "EUR",
- "revenue": 100,
- "mean": 43.7,
- "standardDeviation": 10.3
}
}, - "description": "Current production index",
- "estimatedSampleSize": 0,
- "filterEffects": {
- "outliers": {
- "usersCount": 1,
- "trackedSearchesCount": 237
}, - "emptySearch": {
- "usersCount": 1,
- "trackedSearchesCount": 237
}
}, - "index": "delcourt_production",
- "noResultCount": 0,
- "purchaseCount": 0,
- "purchaseRate": 0,
- "searchCount": 86269,
- "trackedSearchCount": 2,
- "trafficPercentage": 60,
- "userCount": 55501,
- "trackedUserCount": 55501
}
], - "configuration": {
- "outliers": {
- "exclude": true
}, - "emptySearch": {
- "exclude": true
}, - "minimumDetectableEffect": {
- "size": 1,
- "effect": "addToCartRate"
}
}
}
Delete an A/B test
Deletes an A/B test by its ID.
path Parameters
id required | integer Example: 224 Unique A/B test identifier. |
Responses
Request samples
- C#
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
// Initialize the client var client = new AbtestingClient( new AbtestingConfig("YOUR_APP_ID", "YOUR_API_KEY", "YOUR_APP_ID_REGION") ); // Call the API var response = await client.DeleteABTestAsync(42);
Response samples
- 200
- 400
- 402
- 403
- 404
{- "index": "delcourt_production",
- "abTestID": 224,
- "taskID": 1514562690001
}
Stop an A/B test
Stops an A/B test by its ID.
You can't restart stopped A/B tests.
path Parameters
id required | integer Example: 224 Unique A/B test identifier. |
Responses
Request samples
- C#
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
// Initialize the client var client = new AbtestingClient( new AbtestingConfig("YOUR_APP_ID", "YOUR_API_KEY", "YOUR_APP_ID_REGION") ); // Call the API var response = await client.StopABTestAsync(42);
Response samples
- 200
- 400
- 402
- 403
- 404
{- "index": "delcourt_production",
- "abTestID": 224,
- "taskID": 1514562690001
}