The generated API clients are a work in progress, you can also find our stable clients on the Algolia documentation.

Skip to main content

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.

Base URLs

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.

Availability and authentication

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.

Rate limits

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.

Parameters

Query parameters must be URL-encoded. Non-ASCII characters must be UTF-8 encoded. Plus characters (+) are interpreted as spaces.

Response status and errors

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.

Version

The current version of the A/B Testing API is version 2, as indicated by the /2/ in each endpoint's URL.

A/B testing

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.

acl: ["editSettings"]
Request Body schema: application/json
required
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

// 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

Content type
application/json
{
  • "index": "delcourt_production",
  • "abTestID": 224,
  • "taskID": 1514562690001
}

List all A/B tests

Lists all A/B tests you configured for this application.

acl: ["analytics"]
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

// 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

Content type
application/json
{
  • "abtests": [
    ],
  • "count": 10,
  • "total": 12
}

Retrieve A/B test details

Retrieves the details for an A/B test by its ID.

acl: ["analytics"]
path Parameters
id
required
integer
Example: 224

Unique A/B test identifier.

Responses

Request samples

// 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

Content type
application/json
{
  • "abTestID": 224,
  • "clickSignificance": 1,
  • "conversionSignificance": 1,
  • "addToCartSignificance": 1,
  • "purchaseSignificance": 1,
  • "revenueSignificance": {
    },
  • "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": [
    ],
  • "configuration": {
    }
}

Delete an A/B test

Deletes an A/B test by its ID.

acl: ["editSettings"]
path Parameters
id
required
integer
Example: 224

Unique A/B test identifier.

Responses

Request samples

// 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

Content type
application/json
{
  • "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.

acl: ["editSettings"]
path Parameters
id
required
integer
Example: 224

Unique A/B test identifier.

Responses

Request samples

// 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

Content type
application/json
{
  • "index": "delcourt_production",
  • "abTestID": 224,
  • "taskID": 1514562690001
}