curl
curl --request POST \
--url https://analytics.us.algolia.com/2/abtests/estimate \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"configuration": {
"featureFilters": {
"dynamicReRanking": true,
"aiPerso": true,
"multiSignalRanking": true
},
"outliers": {
"exclude": true
},
"emptySearch": {
"exclude": true
},
"minimumDetectableEffect": {
"size": 0,
"metric": "addToCartRate"
}
},
"variants": [
{
"index": "delcourt_production",
"trafficPercentage": 60,
"description": "Current production index"
},
{
"index": "delcourt_production",
"trafficPercentage": 60,
"description": "Current production index"
}
]
}
'// Initialize the client
var client = new AbtestingClient(
new AbtestingConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
);
// Call the API
var response = await client.EstimateABTestAsync(
new EstimateABTestRequest
{
Configuration = new EstimateConfiguration
{
EmptySearch = new EmptySearch { Exclude = true },
MinimumDetectableEffect = new MinimumDetectableEffect
{
Size = 0.03,
Metric = Enum.Parse<EffectMetric>("ConversionRate"),
},
},
Variants = new List<AddABTestsVariant>
{
new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_1", TrafficPercentage = 50 }),
new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_2", TrafficPercentage = 50 }),
},
}
);
// print the response
Console.WriteLine(response);// Initialize the client with your application region, eg. abtesting.ALGOLIA_APPLICATION_REGION
client, err := abtesting.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", abtesting.US)
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.EstimateABTest(client.NewApiEstimateABTestRequest(
abtesting.NewEmptyEstimateABTestRequest().SetConfiguration(
abtesting.NewEmptyEstimateConfiguration().SetEmptySearch(
abtesting.NewEmptyEmptySearch().SetExclude(true)).SetMinimumDetectableEffect(
abtesting.NewEmptyMinimumDetectableEffect().SetSize(0.03).SetMetric(abtesting.EffectMetric("conversionRate")))).SetVariants(
[]abtesting.AddABTestsVariant{*abtesting.AbTestsVariantAsAddABTestsVariant(
abtesting.NewEmptyAbTestsVariant().SetIndex("AB_TEST_1").SetTrafficPercentage(50)), *abtesting.AbTestsVariantAsAddABTestsVariant(
abtesting.NewEmptyAbTestsVariant().SetIndex("AB_TEST_2").SetTrafficPercentage(50))})))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)// Initialize the client
AbtestingClient client = new AbtestingClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");
// Call the API
EstimateABTestResponse response = client.estimateABTest(
new EstimateABTestRequest()
.setConfiguration(
new EstimateConfiguration()
.setEmptySearch(new EmptySearch().setExclude(true))
.setMinimumDetectableEffect(new MinimumDetectableEffect().setSize(0.03).setMetric(EffectMetric.CONVERSION_RATE))
)
.setVariants(
Arrays.asList(
new AbTestsVariant().setIndex("AB_TEST_1").setTrafficPercentage(50),
new AbTestsVariant().setIndex("AB_TEST_2").setTrafficPercentage(50)
)
)
);
// print the response
System.out.println(response);// Initialize the client
// Replace 'us' with your Algolia Application Region
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initAbtesting({ region: 'us' });
// Call the API
const response = await client.estimateABTest({
configuration: {
emptySearch: { exclude: true },
minimumDetectableEffect: { size: 0.03, metric: 'conversionRate' },
},
variants: [
{ index: 'AB_TEST_1', trafficPercentage: 50 },
{ index: 'AB_TEST_2', trafficPercentage: 50 },
],
});
// print the response
console.log(response);// Initialize the client
val client =
AbtestingClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = "ALGOLIA_APPLICATION_REGION",
)
// Call the API
var response =
client.estimateABTest(
estimateABTestRequest =
EstimateABTestRequest(
configuration =
EstimateConfiguration(
emptySearch = EmptySearch(exclude = true),
minimumDetectableEffect =
MinimumDetectableEffect(
size = 0.03,
metric = EffectMetric.entries.first { it.value == "conversionRate" },
),
),
variants =
listOf(
AbTestsVariant(index = "AB_TEST_1", trafficPercentage = 50),
AbTestsVariant(index = "AB_TEST_2", trafficPercentage = 50),
),
)
)
// print the response
println(response)// Initialize the client
$client = AbtestingClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');
// Call the API
$response = $client->estimateABTest(
['configuration' => ['emptySearch' => ['exclude' => true,
],
'minimumDetectableEffect' => ['size' => 0.03,
'metric' => 'conversionRate',
],
],
'variants' => [
['index' => 'AB_TEST_1',
'trafficPercentage' => 50,
],
['index' => 'AB_TEST_2',
'trafficPercentage' => 50,
],
],
],
);
// print the response
var_dump($response);# Initialize the client
# In an asynchronous context, you can use AbtestingClient instead, which exposes the exact same methods.
client = AbtestingClientSync(
"ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
)
# Call the API
response = client.estimate_ab_test(
estimate_ab_test_request={
"configuration": {
"emptySearch": {
"exclude": True,
},
"minimumDetectableEffect": {
"size": 0.03,
"metric": "conversionRate",
},
},
"variants": [
{
"index": "AB_TEST_1",
"trafficPercentage": 50,
},
{
"index": "AB_TEST_2",
"trafficPercentage": 50,
},
],
},
)
# print the response
print(response)# Initialize the client
client = Algolia::AbtestingClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
# Call the API
response = client.estimate_ab_test(
Algolia::Abtesting::EstimateABTestRequest.new(
configuration: Algolia::Abtesting::EstimateConfiguration.new(
empty_search: Algolia::Abtesting::EmptySearch.new(exclude: true),
minimum_detectable_effect: Algolia::Abtesting::MinimumDetectableEffect.new(size: 0.03, metric: "conversionRate")
),
variants: [
Algolia::Abtesting::AbTestsVariant.new(index: "AB_TEST_1", traffic_percentage: 50),
Algolia::Abtesting::AbTestsVariant.new(index: "AB_TEST_2", traffic_percentage: 50)
]
)
)
# print the response
puts(response)// Initialize the client
val client = AbtestingClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = Option("ALGOLIA_APPLICATION_REGION")
)
// Call the API
val response = Await.result(
client.estimateABTest(
estimateABTestRequest = EstimateABTestRequest(
configuration = EstimateConfiguration(
emptySearch = Some(
EmptySearch(
exclude = Some(true)
)
),
minimumDetectableEffect = MinimumDetectableEffect(
size = 0.03,
metric = EffectMetric.withName("conversionRate")
)
),
variants = Seq(
AbTestsVariant(
index = "AB_TEST_1",
trafficPercentage = 50
),
AbTestsVariant(
index = "AB_TEST_2",
trafficPercentage = 50
)
)
)
),
Duration(100, "sec")
)
// print the response
println(response)// Initialize the client
let client = try AbtestingClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)
// Call the API
let response = try await client.estimateABTest(estimateABTestRequest: AbtestingEstimateABTestRequest(
configuration: AbtestingEstimateConfiguration(
emptySearch: EmptySearch(exclude: true),
minimumDetectableEffect: AbtestingMinimumDetectableEffect(
size: 0.03,
metric: AbtestingEffectMetric.conversionRate
)
),
variants: [
AbtestingAddABTestsVariant.abtestingAbTestsVariant(AbtestingAbTestsVariant(
index: "AB_TEST_1",
trafficPercentage: 50
)),
AbtestingAddABTestsVariant.abtestingAbTestsVariant(AbtestingAbTestsVariant(
index: "AB_TEST_2",
trafficPercentage: 50
)),
]
))
// print the response
print(response){
"durationDays": 21,
"sampleSizes": [
23415
]
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}A/B testing API v2 (deprecated)
Estimate the sample size and duration of an A/B test
deprecated
This endpoint is deprecated. Use the A/B Testing API v3 instead.
POST
/
2
/
abtests
/
estimate
curl
curl --request POST \
--url https://analytics.us.algolia.com/2/abtests/estimate \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'x-algolia-api-key: ALGOLIA_API_KEY' \
--header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
--data '
{
"configuration": {
"featureFilters": {
"dynamicReRanking": true,
"aiPerso": true,
"multiSignalRanking": true
},
"outliers": {
"exclude": true
},
"emptySearch": {
"exclude": true
},
"minimumDetectableEffect": {
"size": 0,
"metric": "addToCartRate"
}
},
"variants": [
{
"index": "delcourt_production",
"trafficPercentage": 60,
"description": "Current production index"
},
{
"index": "delcourt_production",
"trafficPercentage": 60,
"description": "Current production index"
}
]
}
'// Initialize the client
var client = new AbtestingClient(
new AbtestingConfig("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
);
// Call the API
var response = await client.EstimateABTestAsync(
new EstimateABTestRequest
{
Configuration = new EstimateConfiguration
{
EmptySearch = new EmptySearch { Exclude = true },
MinimumDetectableEffect = new MinimumDetectableEffect
{
Size = 0.03,
Metric = Enum.Parse<EffectMetric>("ConversionRate"),
},
},
Variants = new List<AddABTestsVariant>
{
new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_1", TrafficPercentage = 50 }),
new AddABTestsVariant(new AbTestsVariant { Index = "AB_TEST_2", TrafficPercentage = 50 }),
},
}
);
// print the response
Console.WriteLine(response);// Initialize the client with your application region, eg. abtesting.ALGOLIA_APPLICATION_REGION
client, err := abtesting.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", abtesting.US)
if err != nil {
// The client can fail to initialize if you pass an invalid parameter.
panic(err)
}
// Call the API
response, err := client.EstimateABTest(client.NewApiEstimateABTestRequest(
abtesting.NewEmptyEstimateABTestRequest().SetConfiguration(
abtesting.NewEmptyEstimateConfiguration().SetEmptySearch(
abtesting.NewEmptyEmptySearch().SetExclude(true)).SetMinimumDetectableEffect(
abtesting.NewEmptyMinimumDetectableEffect().SetSize(0.03).SetMetric(abtesting.EffectMetric("conversionRate")))).SetVariants(
[]abtesting.AddABTestsVariant{*abtesting.AbTestsVariantAsAddABTestsVariant(
abtesting.NewEmptyAbTestsVariant().SetIndex("AB_TEST_1").SetTrafficPercentage(50)), *abtesting.AbTestsVariantAsAddABTestsVariant(
abtesting.NewEmptyAbTestsVariant().SetIndex("AB_TEST_2").SetTrafficPercentage(50))})))
if err != nil {
// handle the eventual error
panic(err)
}
// print the response
print(response)// Initialize the client
AbtestingClient client = new AbtestingClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION");
// Call the API
EstimateABTestResponse response = client.estimateABTest(
new EstimateABTestRequest()
.setConfiguration(
new EstimateConfiguration()
.setEmptySearch(new EmptySearch().setExclude(true))
.setMinimumDetectableEffect(new MinimumDetectableEffect().setSize(0.03).setMetric(EffectMetric.CONVERSION_RATE))
)
.setVariants(
Arrays.asList(
new AbTestsVariant().setIndex("AB_TEST_1").setTrafficPercentage(50),
new AbTestsVariant().setIndex("AB_TEST_2").setTrafficPercentage(50)
)
)
);
// print the response
System.out.println(response);// Initialize the client
// Replace 'us' with your Algolia Application Region
const client = algoliasearch('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY').initAbtesting({ region: 'us' });
// Call the API
const response = await client.estimateABTest({
configuration: {
emptySearch: { exclude: true },
minimumDetectableEffect: { size: 0.03, metric: 'conversionRate' },
},
variants: [
{ index: 'AB_TEST_1', trafficPercentage: 50 },
{ index: 'AB_TEST_2', trafficPercentage: 50 },
],
});
// print the response
console.log(response);// Initialize the client
val client =
AbtestingClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = "ALGOLIA_APPLICATION_REGION",
)
// Call the API
var response =
client.estimateABTest(
estimateABTestRequest =
EstimateABTestRequest(
configuration =
EstimateConfiguration(
emptySearch = EmptySearch(exclude = true),
minimumDetectableEffect =
MinimumDetectableEffect(
size = 0.03,
metric = EffectMetric.entries.first { it.value == "conversionRate" },
),
),
variants =
listOf(
AbTestsVariant(index = "AB_TEST_1", trafficPercentage = 50),
AbTestsVariant(index = "AB_TEST_2", trafficPercentage = 50),
),
)
)
// print the response
println(response)// Initialize the client
$client = AbtestingClient::create('ALGOLIA_APPLICATION_ID', 'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');
// Call the API
$response = $client->estimateABTest(
['configuration' => ['emptySearch' => ['exclude' => true,
],
'minimumDetectableEffect' => ['size' => 0.03,
'metric' => 'conversionRate',
],
],
'variants' => [
['index' => 'AB_TEST_1',
'trafficPercentage' => 50,
],
['index' => 'AB_TEST_2',
'trafficPercentage' => 50,
],
],
],
);
// print the response
var_dump($response);# Initialize the client
# In an asynchronous context, you can use AbtestingClient instead, which exposes the exact same methods.
client = AbtestingClientSync(
"ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
)
# Call the API
response = client.estimate_ab_test(
estimate_ab_test_request={
"configuration": {
"emptySearch": {
"exclude": True,
},
"minimumDetectableEffect": {
"size": 0.03,
"metric": "conversionRate",
},
},
"variants": [
{
"index": "AB_TEST_1",
"trafficPercentage": 50,
},
{
"index": "AB_TEST_2",
"trafficPercentage": 50,
},
],
},
)
# print the response
print(response)# Initialize the client
client = Algolia::AbtestingClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION")
# Call the API
response = client.estimate_ab_test(
Algolia::Abtesting::EstimateABTestRequest.new(
configuration: Algolia::Abtesting::EstimateConfiguration.new(
empty_search: Algolia::Abtesting::EmptySearch.new(exclude: true),
minimum_detectable_effect: Algolia::Abtesting::MinimumDetectableEffect.new(size: 0.03, metric: "conversionRate")
),
variants: [
Algolia::Abtesting::AbTestsVariant.new(index: "AB_TEST_1", traffic_percentage: 50),
Algolia::Abtesting::AbTestsVariant.new(index: "AB_TEST_2", traffic_percentage: 50)
]
)
)
# print the response
puts(response)// Initialize the client
val client = AbtestingClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY",
region = Option("ALGOLIA_APPLICATION_REGION")
)
// Call the API
val response = Await.result(
client.estimateABTest(
estimateABTestRequest = EstimateABTestRequest(
configuration = EstimateConfiguration(
emptySearch = Some(
EmptySearch(
exclude = Some(true)
)
),
minimumDetectableEffect = MinimumDetectableEffect(
size = 0.03,
metric = EffectMetric.withName("conversionRate")
)
),
variants = Seq(
AbTestsVariant(
index = "AB_TEST_1",
trafficPercentage = 50
),
AbTestsVariant(
index = "AB_TEST_2",
trafficPercentage = 50
)
)
)
),
Duration(100, "sec")
)
// print the response
println(response)// Initialize the client
let client = try AbtestingClient(appID: "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)
// Call the API
let response = try await client.estimateABTest(estimateABTestRequest: AbtestingEstimateABTestRequest(
configuration: AbtestingEstimateConfiguration(
emptySearch: EmptySearch(exclude: true),
minimumDetectableEffect: AbtestingMinimumDetectableEffect(
size: 0.03,
metric: AbtestingEffectMetric.conversionRate
)
),
variants: [
AbtestingAddABTestsVariant.abtestingAbTestsVariant(AbtestingAbTestsVariant(
index: "AB_TEST_1",
trafficPercentage: 50
)),
AbtestingAddABTestsVariant.abtestingAbTestsVariant(AbtestingAbTestsVariant(
index: "AB_TEST_2",
trafficPercentage: 50
)),
]
))
// print the response
print(response){
"durationDays": 21,
"sampleSizes": [
23415
]
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}{
"message": "Invalid Application-Id or API-Key"
}Replaced by
POST /3/abtests/estimate.
Given the traffic percentage and the expected effect size, this endpoint estimates the sample size and duration of an A/B test based on historical traffic.
Required ACL: analyticsAuthorizations
Body
application/json
Response
OK
Sample size estimates for each variant. The first element is the control variant. Each element is the estimated number of searches required to achieve the desired statistical significance.
Number of tracked searches needed to be able to detect the configured effect for the control variant.
Last modified on September 9, 2026
Was this page helpful?