Statistics report

Creates a report for the selected level of statistics over the specified period.

Request format

https://partner2.yandex.ru/api/statistics2/get
 ? lang=<string>
 & [pretty=<integer>]
 & period=<string>
 & field=<string>
 & [limits=<string>]
 & [dimension_field=<string|string>]
 & [entity_field=<string>]
 & [filter=<string>]
 & [order_by=<string>]
 & [vat=<boolean>]
 & [stat_type=<string>]
 & [currency=<string>]
  • lang *
    The language of the response. Must be present in all requests.
  • pretty
    Pretty prints the result. Acceptable value: pretty=1.
  • period *

    The time interval for the report. Acceptable values:

    • today: Statistics for today.
    • yesterday: Statistics for yesterday.
    • thismonth: Statistics for the current month.
    • lastmonth: Statistics for the previous month.
    • 30days: Statistics for the past 30 days (including today).
    • 90days: Statistics for the past 90 days (including today).
    • 180days: Statistics for the past 180 days (including today).
    • 365days: Statistics for the past 365 days (including today).
    • thisyear: Statistics for the current year (including today).

    Note

    You can get statistics for any time interval. To do this, specify two dates (the start and end of the period):

    period=2014-06-29&period=2014-07-28
    
  • field *

    The ID of a field to include in the report. Usually these are various indicators, like ad impressions in ad blocks and ad requests from ad blocks. The list of fields is output in the fields structure, the Statistics tree resource.

    Note

    To add multiple fields to the report, specify the parameter multiple times:

    field=shows&field=hits
    
  • limits
    Pagination. Format:
    {"limit":50,"offset":0}
    
  • dimension_field
    The ID of the field to use for grouping (like grouping by day or week). The list of fields is output in the dimension_fields structure, the Statistics tree resource.
  • entity_field

    The ID of the field to use for grouping by values of this field in the report (like the domain name and ad platform name). The list of fields is output in the entity_fields structure, the Statistics tree resource.

    Note

    To group the data by multiple fields, specify the field IDs as follows:

    entity_field=domain&entity_field=page_id
    
  • filter
    The filter used to create the report. Filter parameters are taken from the fields in the entity_filter_fields structure, the Statistics tree resource. For more information about filters, see Filtering fields.
  • order_by

    Sorting the result. Format:

    [{"field":"date","dir":"asc"}]
    

    As the field parameter value, you can add the ID of the field to use for grouping (the list of fields is output in the dimension_fields structure, the Statistics tree resource). As the dir parameter value, you can use asc/desc: sorting in ascending or descending order.

  • vat
    Include or exclude VAT.
  • stat_type

    Report type. Acceptable values:

    • stat_type=mm: Mobile mediation report.
    • stat_type=dsp: DSP report.
    • stat_type=main: Main statistics report. The default value.
  • currency

    The currency used in the report. Acceptable values:

    • USD: US dollars.
    • EUR: Euros.
    • RUB: Rubles. The default value.

* Required parameter.

Request headers

Title Description Required
Authorization The user's authorization token. Yes

The general structure of the response is given below. The order of the elements is not guaranteed.

JSON response format

{
   "data" : {
      "currencies" : [
         {
            "code" : {string},
            "id" : {string}
         },
         {
            ...
         }
      ],
      "dimensions" : {
         "field_name" : {string}
      },
      "is_last_page" : {boolean},
      "measures" : {
         "field_name" : {string}
         
      },
      "periods" : [
         [
            {string},
            {string}
         ]
      ],
      "points" : [
         {
            "dimensions" : {
               "field_name" : {string}
            },
            "measures" : [
               {
                  ...
               }
            ]
         }
      ],
      "report_title" : {string},
      "totals" : {
         "2" : [
            {
               ...
            }
         ]
      }
   },
   "result" : {string}
}      

Response parameters

  • data
    The statistics tree.
    • currencies
      Descriptions of currencies.
      • code
        Currency code.
      • id
        Currency ID.
    • totals
      Objects that include the report's summary data. Each object includes a field with the currency ID and a list of values (for example, the number of clicks and impressions).
    • is_last_page
      The flag that indicates whether the current page is the last one (used for pagination). Acceptable values:
      • false: This is not the last page.
      • true: This is the last page.
    • points
      An array of objects with data.
      • measures
        The fields listed in the request.
      • dimensions
        The fields used to group the data in the report.
    • dimensions
      Descriptions of the fields used to group the data in the report.
    • report_title
      Name of the report.
  • result
    The result of method execution. Acceptable values:
    • ok : The method call was successful.
    • error: An error occurred when calling the method.

Example for JSON

Request:

curl -i -g -H 'Authorization: OAuth 123qwe456a...' \
-X GET 'https://partner2.yandex.ru/api/statistics2/get.json? \
lang=ru \
&pretty=1 \
&dimension_field=date|day \
&period=thismonth \
&entity_field=page_level \
&field=shows \
&field=hits_render \
&field=hits \
&filter=["page_id","=","458472"] \
&field=fillrate' \

Response:

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 16 Dec 2020 10:40:13 GMT
Content-Type: application/json; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive

{
   "data" : {
      "currencies" : [
         {
            "code" : "USD",
            "id" : "1"
         },
         {
            "code" : "RUB",
            "id" : "2"
         },
         {
            "code" : "EUR",
            "id" : "3"
         }
      ],
      "dimensions" : {
         "date" : {
            "index" : 1,
            "title" : "Date",
            "type" : "date"
         },
         "page_level" : {
            "index" : 2,
            "title" : "Product level",
            "type" : "categories"
         }
      },
      "is_last_page" : true,
      "measures" : {
         "fillrate" : {
            "index" : 6,
            "title" : "Fill rate in blocks after the viewability check",
            "type" : "percent",
            "unit" : "percent"
         },
         "hits" : {
            "index" : 5,
            "title" : "Ad requests in blocks",
            "type" : "number",
            "unit" : "count"
         },
         "hits_render" : {
            "index" : 4,
            "title" : "Ad renderings in blocks",
            "type" : "number",
            "unit" : "count"
         },
         "shows" : {
            "index" : 3,
            "title" : "Ad impressions in blocks",
            "type" : "number",
            "unit" : "count"
         }
      },
      "periods" : [
         [
            "2020-12-01",
            "2020-12-15"
         ]
      ],
      "points" : [
         {
            "dimensions" : {
               "date" : [
                  "2020-12-15"
               ],
               "page_level" : "Content sites"
            },
            "measures" : [
               {
                  "fillrate" : 50,
                  "hits" : 2,
                  "hits_render" : 2,
                  "shows" : 1
               }
            ]
         },
         {
            "dimensions" : {
               "date" : [
                  "2020-12-02"
               ],
               "page_level" : "Content sites"
            },
            "measures" : [
               {
                  "fillrate" : 0,
                  "hits" : 0,
                  "hits_render" : 0,
                  "shows" : 0
               }
            ]
         },
         {
            "dimensions" : {
               "date" : [
                  "2020-12-11"
               ],
               "page_level" : "Content sites"
            },
            "measures" : [
               {
                  "fillrate" : 16.9291338582677,
                  "hits" : 254,
                  "hits_render" : 254,
                  "shows" : 43
               }
            ]
         },
         {
            "dimensions" : {
               "date" : [
                  "2020-12-14"
               ],
               "page_level" : "Content sites"
            },
            "measures" : [
               {
                  "fillrate" : 0,
                  "hits" : 0,
                  "hits_render" : 0,
                  "shows" : 0
               }
            ]
         },
         {
            "dimensions" : {
               "date" : [
                  "2020-12-08"
               ],
               "page_level" : "Content sites"
            },
            "measures" : [
               {
                  "fillrate" : 0,
                  "hits" : 0,
                  "hits_render" : 0,
                  "shows" : 0
               }
            ]
         }
      ],
      "report_title" : "Report for the period 01.12.2020 - 15.12.2020",
      "total_rows" : 5,
      "totals" : {
         "2" : [
            {
               "fillrate" : 17.1875,
               "hits" : 256,
               "hits_render" : 256,
               "shows" : 44
            }
         ]
      }
   },
   "result" : "ok"
}