Getting a pivot table
Enables you to get data broken down by time period (such as by day, week, or month). Use this type of request to build charts and track statistics over time. See an example with this request.
Request
GET
https://api-metrika.yandex.net/stat/v1/data/pivot
Query parameters
|
Name |
Description |
|
ids |
Type: integer[] Comma-separated list of tag IDs. Example: |
|
metrics |
Type: string List of metrics separated by comma. Limit: 20 metrics per request. Example: |
|
accuracy |
Type: string Sample size for the report. Use it to control the sampling rate (the number of sessions used for calculating results). Example: `` |
|
callback |
Type: string Callback function that processes the API response. Example: `` |
|
date1 |
Type: string Start date of the sample period in YYYY-MM-DD format. You can also use the values: Default: Example: `` |
|
date2 |
Type: string End date of the sample period in YYYY-MM-DD format. You can also use the values: Default: Example: `` |
|
dimensions |
Type: string Comma-separated list of dimensions. Limit: 10 dimensions per request. Example: |
|
direct_client_logins |
Type: string[] Comma-separated usernames of Yandex Direct clients. Can be used for generating the Yandex Direct — costs report. Example: |
|
filters |
Type: string Segmentation 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: `` |
|
include_undefined |
Type: boolean The response will include rows that don't have defined dimension values. This only affects the first dimension. Disabled by default. |
|
lang |
Type: string Language. Example: `` |
|
limit |
Type: string Number of items on the results page. Limit: 100,000. Default: Example: `` |
|
offset |
Type: string Index of the first row of requested data, starting from 1. Default: Example: `` |
|
pivot_dimensions |
Type: string Comma-separated list of dimensions. Limit: 10 dimensions per request. Example: |
|
pivot_limit |
Type: string Number of columns on the results page. Limit: 100. Default: Example: `` |
|
pivot_offset |
Type: string Index of the first row of requested data, starting from 1. Default: Example: `` |
|
preset |
Type: string Example: |
|
pretty |
Type: string Specifies the formatting for results. To use formatting, set the value to Default: Example: `` |
|
proposed_accuracy |
Type: boolean If the parameter is set to |
|
sort |
Type: string Comma-separated list of dimensions and metrics to use for sorting. By default, data is sorted in descending order (indicated by the Example: `` |
|
timezone |
Type: string Time zone in ±hh:mm format within the range of [-23:59; +23:59] (the plus sign should be denoted as Example: |
Responses
200 OK
OK
Body
application/json
{
"query": {
"timezone": "example",
"preset": "example",
"dimensions": [
"example"
],
"metrics": [
"example"
],
"sort": [
"example"
],
"date1": "example",
"date2": "example",
"filters": "example",
"pivot_dimensions": [
"example"
]
},
"data": [
{
"dimensions": [
{}
],
"metrics": [
[
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": [
0.5
]
}
|
Name |
Description |
|
contains_sensitive_data |
Type: boolean Indicates whether sensitive data 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 |
|
data |
Type: PivotRow[] Example
|
|
data_lag |
Type: integer Delay in updating data, in seconds. |
|
query |
Type: PivotQueryExternal Original request. Contains the request parameters, including detailed parameters from the template and parameters for attribute parametrization. Example
|
|
sample_share |
Type: number Share of data used for the calculation. Available value ranges from 0 to 1. |
|
sample_size |
Type: integer Number of rows in the data sample. |
|
sample_space |
Type: integer Number of data rows. |
|
sampled |
Type: boolean Sampling flag. Indicates whether sampling was applied. Possible values: |
|
total_rows |
Type: integer The total number of rows in the response for the entire dataset (after filtering). |
|
total_rows_rounded |
Type: boolean Indicates that the total number of rows was rounded. |
|
totals |
Type: number[] Example
|
PivotQueryExternal
Original request. Contains the request parameters, including detailed parameters from the template and parameters for attribute parametrization.
|
Name |
Description |
|
date1 |
Type: string Start date of the sample period in YYYY-MM-DD format. Example: |
|
date2 |
Type: string End date of the sample period in YYYY-MM-DD format. Example: |
|
dimensions |
Type: string[] Example
|
|
filters |
Type: string Segmentation filter. Example: |
|
metrics |
Type: string[] Example
|
|
pivot_dimensions |
Type: string[] Example
|
|
preset |
Type: string Report preset. Example: |
|
sort |
Type: string[] Example
|
|
timezone |
Type: string Time zone of the sample period in ±hh:mm format. Example: |
Example
{
"timezone": "example",
"preset": "example",
"dimensions": [
"example"
],
"metrics": [
"example"
],
"sort": [
"example"
],
"date1": "example",
"date2": "example",
"filters": "example",
"pivot_dimensions": [
"example"
]
}
PivotRow
Response rows. An array in which each item is a single row of the result.
|
Name |
Description |
||
|
dimensions |
Type: object[]
Array of dimension values for this row. Each dimension value is an object. It must have the Example
|
||
|
metrics |
Type: number[][] Array of arrays of metric values for this row. The outer array lists metrics, whereas the inner arrays list values of a specific metric for each time group. Example
|
Example
{
"dimensions": [
{}
],
"metrics": [
[
0.5
]
]
}