> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# List A/B tests

> List A/B tests information and results.

export const Legacy = ({title, href}) => {
  return <Note>

    This page documents an earlier version of the API client.
    For the latest version, see <a href={href}>{title}</a>.

    </Note>;
};

<Legacy title="List all A/B tests" href="/doc/libraries/sdk/methods/abtesting/list-ab-tests" />

**Required ACL:** `analytics`

## Examples

<CodeGroup>
  ```cs C# theme={"system"}
  AnalyticsClient analytics = new AnalyticsClient("YourApplicationID", "YourWriteAPIKey");

  var abTests = analytics.GetABTests(10, 20);

  // Asynchronous
  var abTests = await analytics.GetABTestsAsync(10, 20);
  ```

  ```go Go theme={"system"}
  opts := []interface{}{
  	opt.Offset(10),
  	opt.Limit(20),
  }

  client := analytics.NewClient("YourApplicationID", "YourWriteAPIKey")
  res, err := client.GetABTests(opts...)
  ```

  ```java Java theme={"system"}
  AnalyticsClient analytics = 
  DefaultAnalyticsClient.create("YourApplicationID", "YourWriteAPIKey");

  ABTests abtests = analytics.getABTests(10, 20);

  // Asynchronous
  CompletableFuture<ABTests> abtests = analytics.getABTests(10, 2);
  ```

  ```js JavaScript theme={"system"}
  const analytics = client.initAnalytics({
    // optional parameters
    region: "de",
    appId: "YourApplicationID",
    apiKey: "YourWriteAPIKey",
  });
  analytics.getABTests({ limit: 1, offset: 10 }).then(({ abtests }) => {
    console.log(abtests);
  });
  ```

  ```kotlin Kotlin theme={"system"}
  clientAnalytics.listABTests(10, 20)
  ```

  ```php PHP theme={"system"}
  $analytics = AnalyticsClient::create(
    'YourApplicationID',
    'YourWriteAPIKey'
  );

  $analytics->getABTests([
    'offset' => 10,
    'limit' => 20
  ]);
  ```

  ```python Python theme={"system"}
  analytics = AnalyticsClient.create("YourApplicationID", "YourWriteAPIKey")

  analytics.get_ab_tests({"offset": 10, "limit": 20})
  ```

  ```ruby Ruby theme={"system"}
  analytics = Algolia::Analytics::Client.create("YourApplicationID", "YourWriteAPIKey")
  analytics.get_ab_tests({offset: 10, limit: 20})
  ```

  ```scala Scala theme={"system"}
  client.execute {
    get all abTests offset 10 limit 20
  }
  ```

  ```swift Swift theme={"system"}
  analyticsClient.listABTests(offset: 10,
                              limit: 20) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="indexPrefix" type="string">
  Prefix of index names. Returns A/B test variants whose index names start with this prefix.
</ParamField>

<ParamField body="indexSuffix" type="string">
  Suffix of index names. Returns A/B test variants whose index names end with this suffix.
</ParamField>

<ParamField body="limit" type="integer" default={10}>
  Number of A/B tests to retrieve.
</ParamField>

<ParamField body="offset" type="integer" default={0}>
  Position of the first A/B test to retrieve.
</ParamField>

## Response

<ResponseField name="abtests" type="object[]">
  List of A/B test objects.

  <Expandable>
    <ResponseField name="abTestID" type="integer">
      ID of the A/B test.
    </ResponseField>

    <ResponseField name="addToCartSignificance" type="number">
      A/B test significance based on `addToCart` conversions.
      Should be greater than 0.95 to be considered significant,
      no matter which variant is winning.
    </ResponseField>

    <ResponseField name="clickSignificance" type="number">
      A/B test significance based on click data.
      Should be greater than 0.95 to be considered significant,
      no matter which variant is winning.
    </ResponseField>

    <ResponseField name="configuration" type="object">
      Configuration parameters for the A/B test.

      **Example:**

      ```jsonc JSON icon=braces theme={"system"}
      {
        "outliers": {"exclude": true},
        "emptySearch": {"exclude": true},
        "minimumDetectableEffect": {}
      }
      ```

      <Expandable>
        <ResponseField name="emptySearch" type="object">
          Configuration effect of empty search exclusion from metrics calculations.

          <Expandable>
            <ResponseField name="exclude" type="boolean">
              Whether empty searches are excluded when calculating A/B test results.
            </ResponseField>
          </Expandable>
        </ResponseField>

        <ResponseField name="minimumDetectableEffect" type="object">
          Configuration for minimum detectable effect.

          <Expandable>
            <ResponseField name="effect" type="enum<string>">
              The effect you want to detect. One of:

              * `addToCartRate`
              * `clickThroughRate`
              * `conversionRate`
              * `purchaseRate`
            </ResponseField>

            <ResponseField name="size" type="number">
              The smallest relative difference between the variants you want to detect.
              For example, to detect a 10% difference between the variants, set this to 0.1.
              The size must be between 0 and 1.
            </ResponseField>
          </Expandable>
        </ResponseField>

        <ResponseField name="outliers" type="object">
          Configuration effect of outlier exclusion from metrics calculations.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="conversionSignificance" type="number">
      A/B test significance based on conversion data.
      Should be greater than 0.95 to be considered significant,
      no matter which variant is winning.
    </ResponseField>

    <ResponseField name="createdAt" type="string">
      Time at which the A/B test has been created.
      The date will be in the following format: `Y-m-d\TH:i:s\Z`
    </ResponseField>

    <ResponseField name="endAt" type="string">
      Time at which the A/B test will automatically stop.
      The date will be in the following format: `Y-m-d\TH:i:s\Z`
    </ResponseField>

    <ResponseField name="name" type="string">
      Name of the A/B test.
    </ResponseField>

    <ResponseField name="purchaseSignificance" type="number">
      A/B test significance based on `purchase` conversions.
      Should be greater than 0.95 to be considered significant,
      no matter which variant is winning.
    </ResponseField>

    <ResponseField name="revenueSignificance" type="object">
      A/B test revenue significance for each currency.
      The object has currency codes as keys and significance scores as values.
    </ResponseField>

    <ResponseField name="status" type="string">
      Current status of the A/B test.
    </ResponseField>

    <ResponseField name="variants" type="object[]">
      List of 2 variants:

      * The base index
      * The index to test against

      <Expandable>
        <ResponseField name="addToCartCount" type="integer">
          Distinct number of converted clicks with the `eventSubtype` set to `addToCart` and `clickAnalytics` set to `true`.
        </ResponseField>

        <ResponseField name="addToCartRate" type="number">
          Add-to-cart rate is based on conversion events that have [`eventSubType`](/doc/rest-api/insights) set to `addToCart`, and the total number of
          tracked searches within the specified timeframe. The rates are computed as the number of add-to-cart conversion events divided by the
          number of tracked searches.
        </ResponseField>

        <ResponseField name="averageClickPosition" type="integer">
          Average click position for the variant.
        </ResponseField>

        <ResponseField name="clickCount" type="integer">
          Distinct click count for the variant.
        </ResponseField>

        <ResponseField name="clickThroughRate" type="number">
          Click through rate for the variant.
        </ResponseField>

        <ResponseField name="conversionCount" type="integer">
          Distinct conversion count for the variant.
        </ResponseField>

        <ResponseField name="conversionRate" type="number">
          Conversion rate for the variant.
        </ResponseField>

        <ResponseField name="currencies" type="object">
          Revenue metrics for each currency.

          **Example:**

          ```jsonc JSON icon=braces theme={"system"}
          {
            "USD": {
              "currency": "USD",
              "revenue": "...",
              "mean": "...",
              "standardDeviation": "..."
            },
            "EUR": {}
          }
          ```

          <Expandable>
            <ResponseField name="currency" type="string">
              Currency code in [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) format.
            </ResponseField>

            <ResponseField name="mean" type="number">
              Mean revenue for this currency.
            </ResponseField>

            <ResponseField name="revenue" type="number">
              Revenue made in this currency.
            </ResponseField>

            <ResponseField name="standardDeviation" type="number">
              Standard deviation of revenue for this currency.
            </ResponseField>
          </Expandable>
        </ResponseField>

        <ResponseField name="description" type="string">
          Description of this variant.
        </ResponseField>

        <ResponseField name="estimatedSampleSize" type="integer">
          Estimated number of searches needed to achieve confidence for this variant. This number is pre-computed and is based on the
          `minimumDetectableEffect` configuration parameter.
        </ResponseField>

        <ResponseField name="filterEffects" type="object">
          Effects of the outlier or empty search exclusion.
          Each effect has these properties:

          * `usersCount`: number of users excluded by this filter
          * `trackedSearchesCount`: number of tracked searches excluded by this filter

          **Example:**

          ```jsonc JSON icon=braces theme={"system"}
          {
            "outliers": {
                  "usersCount": "...",
                  "trackedSearchesCount": "..."
            },
            "emptySearch": {
                  "usersCount": "...",
                  "trackedSearchesCount": "..."
              }
          }
          ```
        </ResponseField>

        <ResponseField name="index" type="string">
          Index name for this variant.
        </ResponseField>

        <ResponseField name="noResultCount" type="integer">
          Number of tracked searches without any results.
        </ResponseField>

        <ResponseField name="purchaseCount" type="integer">
          Distinct number of converted clicks with the `eventSubtype` set to `purchase` and `clickAnalytics` set to `true`.
        </ResponseField>

        <ResponseField name="purchaseRate" type="number">
          Purchase rate is based on conversion events that have [`eventSubType`](/doc/rest-api/insights) set to `purchase`, and the total number of
          tracked searches within the specified timeframe. The rates are computed as the number of purchase conversion events divided by the
          number of tracked searches.
        </ResponseField>

        <ResponseField name="searchCount" type="integer">
          Total number of searches for this variant, including untracked searches.
        </ResponseField>

        <ResponseField name="trackedSearchCount" type="integer">
          Number of tracked searches.
          Tracked searches are searches with [`clickAnalytics`](/doc/api-reference/api-parameters/clickAnalytics) enabled.
        </ResponseField>

        <ResponseField name="trackedUserCount" type="integer">
          Number of users who searched this variant with at least one search that had [`clickAnalytics`](/doc/api-reference/api-parameters/clickAnalytics) enabled.
        </ResponseField>

        <ResponseField name="userCount" type="integer">
          Total number of users who searched this variant, including untracked users.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="count" type="integer">
  Number of returned A/B tests.
</ResponseField>

<ResponseField name="total" type="integer">
  Total number of A/B tests that can be fetched.
</ResponseField>

### Response as JSON

This section shows the JSON response returned by the API.
Each API client wraps this response in language-specific objects, so the structure may vary.
To view the response, use the `getLogs` method.
Don't rely on the order of properties—JSON objects don't preserve key order.

```jsonc JSON icon=braces theme={"system"}
{
  "count": 1,
  "total": 1,
  "abtests": [
    {
      "abtestID": 102,
      "name": "ABTest custom name",
      "createdAt": "2018-06-04T10:25:40.459519Z",
      "endAt": "2018-06-11T23:59:59Z",
      "status": "active",
      "configuration": {
        "outliers": {
          "exclude": true
        },
        "emptySearch": {
          "exclude": false
        },
      },
      "variants": [
        {
          "averageClickPosition": null,
          "clickCount": null,
          "clickThroughRate": null,
          "conversionCount": null,
          "conversionRate": null,
          "description": "my current scenario description",
          "index": "scout_airports",
          "noResultCount": null,
          "searchCount": null,
          "trackedSearchCount": null,
          "trafficPercentage": 61,
          "userCount": null,
          "trackedUserCount": null,
          "filterEffects": {
            "outliers": {
              "usersCount": 0,
              "trackedSearchesCount": 0
            }
          }
        },
        {
          "averageClickPosition": null,
          "clickCount": null,
          "clickThroughRate": null,
          "conversionCount": null,
          "conversionRate": null,
          "description": "the test scenarios is based on locations",
          "index": "airport_demo_airports",
          "noResultCount": null,
          "searchCount": null,
          "trackedSearchCount": null,
          "trafficPercentage": 39,
          "userCount": null,
          "trackedUserCount": null,
          "filterEffects": {
            "outliers": {
              "usersCount": 1,
              "trackedSearchesCount": 300
            }
          }
        }
      ],
      "clickSignificance": null,
      "conversionSignificance": null
    }
  ]
}
```
