---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://www.yandex.com/dev/metrika/en/stat/openapi/comparison.md
  - https://www.yandex.com/dev/metrika/ru/stat/openapi/comparison.md
  - href: en/stat/openapi/comparison.md
    type: text/markdown
    title: Markdown version
  - href: ../../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://www.yandex.com/dev/metrika/en/llms.txt

<div class="openapi">

# Comparing segments

<!-- markdownlint-disable-file -->

Used to compare two data segments. Segments are identified as segment A and segment B. You can set different date ranges and segmentation filters for each segment. Data will be presented in a table.
Each row in the report has two sets of metrics: metrics for segment A, and metrics for segment B.
See [an example](https://www.yandex.com/dev/metrika/en/stat/examples.md#comparison) with this request.

## Request

<div class="openapi__requests">

<div class="openapi__request__wrapper" style="--method: var(--dc-openapi-methods-get);margin-bottom: 12px">

<div class="openapi__request">

GET {.openapi__method}
```text translate=no
https://api-metrika.yandex.net/stat/v1/data/comparison
```

</div>

</div>

</div>

### Query parameters

#|
|| **Name** | **Description** ||
||

_ids_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: integer[]

Comma-separated list of tag IDs.

_Example:_{.json-schema-reset .json-schema-example} `44147844,2215573`
{.table-cell}
||
||

_metrics_{.json-schema-reset .json-schema-property .json-schema-required}
{.table-cell}|
**Type**: string

List of metrics separated by comma.
Limit: 20 metrics per request.

_Example:_{.json-schema-reset .json-schema-example} `ym:s:pageviews`
{.table-cell}
||
||

_accuracy_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Sample size for the report. Use it to control the [sampling rate](https://www.yandex.com/dev/metrika/en/stat/sampling.md) (the number of sessions used for calculating results).

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_callback_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Callback function that processes the API response.

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_date1_a_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Start date of the sample period for segment A in YYYY-MM-DD format. You can also use the values `today`, `yesterday`, and `ndaysAgo`.

_Default:_{.json-schema-reset .json-schema-value} `6daysAgo`

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_date1_b_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Start date of the sample period for segment B in YYYY-MM-DD format. You can also use the values `today`, `yesterday`, and `ndaysAgo`.

_Default:_{.json-schema-reset .json-schema-value} `6daysAgo`

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_date2_a_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

End date of the sample period for segment A in YYYY-MM-DD format. You can also use the values `today`, `yesterday`, and `ndaysAgo`.

_Default:_{.json-schema-reset .json-schema-value} `today`

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_date2_b_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

End date of the sample period for segment B in YYYY-MM-DD format. You can also use the values `today`, `yesterday`, and `ndaysAgo`.

_Default:_{.json-schema-reset .json-schema-value} `today`

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_dimensions_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Comma-separated list of dimensions.
Limit: 10 dimensions per request.

_Example:_{.json-schema-reset .json-schema-example} `ym:s:trafficSource`
{.table-cell}
||
||

_direct_client_logins_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string[]

Comma-separated usernames of Yandex Direct clients. Can be used for generating the [Yandex Direct — costs](https://www.yandex.com/dev/metrika/en/stat/direct-clicks.md) report.

_Example:_{.json-schema-reset .json-schema-example} `login1,login2`
{.table-cell}
||
||

_filters_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

[Segmentation](https://www.yandex.com/dev/metrika/en/stat/segmentation.md) filter.
Limits: up to 10 unique dimensions and metrics; up to 20 separate filters; up to 10,000 characters per filter row; and up to 100 values per filtering criteria.

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_filters_a_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Segmentation filter for segment A.

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_filters_b_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Segmentation filter for segment A.

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_include_undefined_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: boolean

The response will include rows that don't have defined dimension values. This only affects the first dimension. Disabled by default.
{.table-cell}
||
||

_lang_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Language.

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_limit_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Number of items on the results page.
Limit: 100,000.

_Default:_{.json-schema-reset .json-schema-value} `100`

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_offset_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Index of the first row of requested data, starting from 1.

_Default:_{.json-schema-reset .json-schema-value} `1`

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_preset_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

[Report presets](https://www.yandex.com/dev/metrika/en/stat/presets.md).

_Example:_{.json-schema-reset .json-schema-example} `sources_summary`
{.table-cell}
||
||

_pretty_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Specifies the formatting for results. To use formatting, set the value to `true`.

_Default:_{.json-schema-reset .json-schema-value} `false`

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_proposed_accuracy_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: boolean

If the parameter is set to `true`, the API may automatically increase the accuracy to the recommended level. This can help you get meaningful results when querying small tables containing a very small sample of data.
{.table-cell}
||
||

_sort_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Comma-separated list of dimensions and metrics to use for sorting. By default, data is sorted in descending order (indicated by the `-` symbol in front of the dimension or metric). To sort data in ascending order, remove the `-` symbol.

_Example:_{.json-schema-reset .json-schema-example} ``
{.table-cell}
||
||

_timezone_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Time zone in ±hh:mm format within the range of [-23:59; +23:59] (the plus sign should be denoted as `%2B`).
This time zone is used to calculate the request sample period as well as the date- and time-specific dimensions.
By default, the tag's time zone is used.

_Example:_{.json-schema-reset .json-schema-example} `+03:00`
{.table-cell}
||
|#{.json-schema-properties}

## Responses

<div class="openapi__response__code__200">

## 200 OK

OK

<div class="openapi-entity">

### Body

{% cut "application/json" %}

```json translate=no
{
  "query": {
    "timezone": "example",
    "preset": "example",
    "dimensions": [
      "example"
    ],
    "metrics": [
      "example"
    ],
    "sort": [
      "example"
    ],
    "date1_a": "example",
    "date2_a": "example",
    "filters_a": "example",
    "date1_b": "example",
    "date2_b": "example",
    "filters_b": "example",
    "limit": 0,
    "offset": 0
  },
  "data": [
    {
      "dimensions": [
        {}
      ],
      "metrics": {
        "a": [
          0.5
        ],
        "b": [
          0.5
        ]
      }
    }
  ],
  "total_rows": 0,
  "total_rows_rounded": true,
  "sampled": true,
  "contains_sensitive_data": true,
  "sample_share": 0.5,
  "sample_size": 0,
  "sample_space": 0,
  "data_lag": 0,
  "totals": null
}
```

{% endcut %}

#|
|| **Name** | **Description** ||
||

_contains_sensitive_data_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: boolean

Indicates whether [sensitive data](https://yandex.com/support/metrica/reports/report-general.html#privacy) can be omitted from the response. Such data includes data calculated by Yandex algorithms: demographic data (gender, age, and other), login page addresses, search phrases, and robot information. If the value is `true`, the response will not display such data if the sample is less than 10 users.
Possible values: `true`, `false`.
{.table-cell}
||
||

_data_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [ComparisonRowStaticAB](#entity-ComparisonRowStaticAB)[]

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  {
    "dimensions": [
      {}
    ],
    "metrics": {
      "a": [
        0.5
      ],
      "b": [
        0.5
      ]
    }
  }
]
```

{% endcut %}
{.table-cell}
||
||

_data_lag_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

Delay in updating data, in seconds.
{.table-cell}
||
||

_query_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [ComparisonQueryAB](#entity-ComparisonQueryAB)

Original request. Contains the request parameters, including detailed parameters from the template and parameters for attribute parametrization.

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "timezone": "example",
  "preset": "example",
  "dimensions": [
    "example"
  ],
  "metrics": [
    "example"
  ],
  "sort": [
    "example"
  ],
  "date1_a": "example",
  "date2_a": "example",
  "filters_a": "example",
  "date1_b": "example",
  "date2_b": "example",
  "filters_b": "example",
  "limit": 0,
  "offset": 0
}
```

{% endcut %}
{.table-cell}
||
||

_sample_share_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: number

Share of data used for the calculation. Available value ranges from 0 to 1.
{.table-cell}
||
||

_sample_size_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

Number of rows in the data sample.
{.table-cell}
||
||

_sample_space_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

Number of data rows.
{.table-cell}
||
||

_sampled_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: boolean

Sampling flag. Indicates whether sampling was applied. Possible values: `true`, `false`.
{.table-cell}
||
||

_total_rows_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

The total number of rows in the response for the entire dataset (after filtering).
{.table-cell}
||
||

_total_rows_rounded_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: boolean

Indicates that the total number of rows was rounded.
{.table-cell}
||
||

_totals_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [ComparisonDataAB](#entity-ComparisonDataAB)

Total results for metrics across the entire dataset (after filtering).

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "a": [
    0.5
  ],
  "b": [
    0.5
  ]
}
```

{% endcut %}
{.table-cell}
||
|#{.json-schema-properties}

</div>

<div class="openapi-entity">

### ComparisonQueryAB {#entity-ComparisonQueryAB}

Original request. Contains the request parameters, including detailed parameters from the template and parameters for attribute parametrization.

#|
|| **Name** | **Description** ||
||

_date1_a_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Start date of the sample period for segment A in YYYY-MM-DD format.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_date1_b_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Start date of the sample period for segment B in YYYY-MM-DD format.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_date2_a_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

End date of the sample period for segment A in YYYY-MM-DD format.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_date2_b_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

End date of the sample period for segment B in YYYY-MM-DD format.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_dimensions_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string[]

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  "example"
]
```

{% endcut %}
{.table-cell}
||
||

_filters_a_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Segmentation filter for segment A.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_filters_b_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Segmentation filter for segment B.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_limit_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

Number of items on the results page.
{.table-cell}
||
||

_metrics_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string[]

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  "example"
]
```

{% endcut %}
{.table-cell}
||
||

_offset_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: integer

Index of the first row of requested data, starting from 1.
{.table-cell}
||
||

_preset_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Report preset.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
||

_sort_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string[]

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  "example"
]
```

{% endcut %}
{.table-cell}
||
||

_timezone_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: string

Time zone of the sample period in ±hh:mm format.

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
|#{.json-schema-properties}

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "timezone": "example",
  "preset": "example",
  "dimensions": [
    "example"
  ],
  "metrics": [
    "example"
  ],
  "sort": [
    "example"
  ],
  "date1_a": "example",
  "date2_a": "example",
  "filters_a": "example",
  "date1_b": "example",
  "date2_b": "example",
  "filters_b": "example",
  "limit": 0,
  "offset": 0
}
```

{% endcut %}

</div>

<div class="openapi-entity">

### ComparisonDataAB {#entity-ComparisonDataAB}

Total results for metrics across the entire dataset (after filtering).

#|
|| **Name** | **Description** ||
||

_a_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: number[]

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  0.5
]
```

{% endcut %}
{.table-cell}
||
||

_b_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: number[]

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  0.5
]
```

{% endcut %}
{.table-cell}
||
|#{.json-schema-properties}

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "a": [
    0.5
  ],
  "b": [
    0.5
  ]
}
```

{% endcut %}

</div>

<div class="openapi-entity">

### ComparisonRowStaticAB {#entity-ComparisonRowStaticAB}

Response rows. An array in which each item is a single row of the result.

#|
|| **Name** | **Description** ||
||

_dimensions_{.json-schema-reset .json-schema-property}
{.table-cell}|
{% cut "**Type**: object[]" %}

#|
||

_[additional]_{.json-schema-reset .json-schema-additional-property}
{.table-cell}|
**Type**: string

_Example:_{.json-schema-reset .json-schema-example} `example`
{.table-cell}
||
|#{.json-schema-properties}

{% endcut %}

Array of dimension values for this row. Each dimension value is an object. It must have the `name` field, which is a text value. But it can also have additional fields, such as `id`.

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
[
  {}
]
```

{% endcut %}
{.table-cell}
||
||

_metrics_{.json-schema-reset .json-schema-property}
{.table-cell}|
**Type**: [ComparisonDataAB](#entity-ComparisonDataAB)

Total results for metrics across the entire dataset (after filtering).

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "a": [
    0.5
  ],
  "b": [
    0.5
  ]
}
```

{% endcut %}
{.table-cell}
||
|#{.json-schema-properties}

{% cut "**Example**" %}{.json-schema-example}

```json translate=no
{
  "dimensions": [
    {}
  ],
  "metrics": {
    "a": [
      0.5
    ],
    "b": [
      0.5
    ]
  }
}
```

{% endcut %}

</div>

</div>

</div>

[*Deprecated]: No longer supported, please use an alternative and newer version.