Statistics tree

Returns a list of levels and parameters for each level of statistics that are available to use for creating the report.

Request format

https://partner2.yandex.ru/api/statistics2/tree
  ? lang=<string>
  & [pretty=<integer>]
  & [stat_type=<string>]
  • lang *
    The language of the response. Must be present in all requests.
  • pretty
    Pretty prints the result. Acceptable value: pretty=1.
  • 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.

* 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

{
  "result": {string},
  "data": {
    "tree": [
      {
        "title": {string},
        "id": {string},
        "conflict_fields": [],
        "dimension_fields": [
          {
            "values": [
              [
                {string},
                {string}
              ],
              [
                ...
              ]
            ],
            "type": {string},
            "title": {string},
            "id": {string}
          },
          {
            "values": [
              [
                {string},
                {string}
              ],
              [
                ...
              ]
            ],
            "type": {string},
            "title": {string},
            "id": {string}
          }
        ],
        "entity_fields": [
          {
            "type": {string},
            "label": {string},
            "index": {integer},
            "id": {string}
          }
        ],
        "entity_filter_fields": {
          "filter_field_name": {
            "type": {string},
            "index": {integer}
          }
        },
        "entity_filter_simple_fields": [
          [
            {
              "name": {string},
              "label": {string},
              "index": {integer}
            }
          ]
        ],
        "fields": [
          {
            "type": {string},
            "title": {string},
            "index": {integer},
            "id": {string},
            "category_name": {string},
            "category": {integer}
          }
        ],
        "has_product": "",
        "has_raw_stat": ""
      }
    ]
  }
}        

Response parameters

  • result
    The result of method execution. Acceptable values:
    • ok : The method call was successful.
    • error: An error occurred when calling the method.
  • data
    The response body.
    • tree
      The statistics tree.
      • title
        The name of the statistics level.
      • id
        The ID of the statistics level. The parameter is used in the request for creating the report.
      • conflict_fields
        Internal parameter. Not used.
      • dimension_fields
        Information about the fields used for grouping the report data, like grouping by day or week.
        • id
          The ID of the field. The parameter is used in the request for creating the report.
        • title
          The name of the field.
        • type
          The field type (in this case, the field type is select: select from the list of periods). This parameter is used to create a page in the Partner Interface.
        • values
          A list of possible time periods. One of the values is used in the request for creating the report.
      • entity_fields
        Information about the fields used for grouping the report data, like grouping by login.
        • id
          The ID of the field. The parameter is used in the request for creating the report.
        • label
          The name of the field. This parameter is used to create a page in the Partner Interface.
        • type
          Field type (for example, text: you can enter text information in the field). This parameter is used to create a page in the Partner Interface.
        • index
          Index.
      • entity_filter_fields
        Information about the fields used as filters in the report. SQL statements are applied to filters. For example, you can filter by the ad platform ID. For more information, see Filtering fields.
        • filter_field_name

          A field (i.e., a name) that is used as a filter. The object contains characteristics of the field.

          type: The field type. Helps you determine which SQL statements can be applied to the filter. For more information, see Filtering fields. index: Index.

      • entity_filter_simple_fields
        Information about the fields used as filters in the report.
        • name
          The name of the field.
        • label
          The name of the field. This parameter is used to create a page in the Partner Interface.
        • index
          Index.
      • fields
        Information about the fields that can be included in the report. For example, these fields can be various metrics like ad impressions in ad blocks, or turnover for RTB blocks.
        • id
          The ID of the field. The parameter is used in the request for creating the report.
        • type
          Field type (for example, text: you can enter text information in the field). This parameter is used to create a page in the Partner Interface.
        • title
          The name of the field. This parameter is used to create a page in the Partner Interface.
        • index
          Index.
        • category_name
          Internal parameter. Not used.
        • category
          Internal parameter. Not used.
      • has_product
        Internal parameter. Not used.
      • has_raw_stat
        Internal parameter. Not used.

Example for JSON

Request:

curl -i -X GET 'https://partner2.yandex.ru/api/statistics2/tree.json?lang=ru' \
-H 'Authorization: OAuth 123qwe456a...'

Response:

HTTP/1.1 200 OK
Server: nginx
Date: Fri, 02 Jul 2020 10:20:13 GMT
Content-Type: application/json; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
 
{
   "data" : {
      "tree" : [
         {
            "conflict_fields" : [],
            "dimension_fields" : [
               {
                  "id" : "date",
                  "title" : "Date",
                  "type" : "select",
                  "values" : [
                     [
                        "month",
                        "by month"
                     ],
                     [
                        "week",
                        "by week"
                     ],
                     [
                        "day",
                        "by day"
                     ],
                     [
                        "year",
                        "by year"
                     ]
                  ]
               },
               {
                  "id" : "geo",
                  "title" : "Geography",
                  "type" : "select",
                  "values" : [
                     [
                        "country",
                        "by country"
                     ],
                     [
                        "city",
                        "by city"
                     ],
                     [
                        "area",
                        "by region"
                     ]
                  ]
               }
            ],
            "entity_fields" : [
               {
                  "category" : 14,
                  "category_name" : "Product",
                  "id" : "block_level",
                  "index" : 4,
                  "label" : "Product block level",
                  "type" : "tree"
               },
               {
                  "category" : 14,
                  "category_name" : "Product",
                  "id" : "page_level",
                  "index" : 5,
                  "label" : "Product level",
                  "type" : "tree"
               },
               {
                  "category" : 12,
                  "category_name" : "Site",
                  "id" : "page_id",
                  "index" : 11,
                  "label" : "Page ID",
                  "type" : "publicid"
               },
               {
                  "category" : 12,
                  "category_name" : "Site",
                  "id" : "page_caption",
                  "index" : 12,
                  "label" : "Page name",
                  "type" : "text"
               },
               {
                  "category" : 10,
                  "category_name" : "Block",
                  "id" : "complex_block_id",
                  "index" : 14,
                  "label" : "Block ID",
                  "type" : "publicid"
               },
               {
                  "category" : 10,
                  "category_name" : "Block",
                  "id" : "block_caption",
                  "index" : 15,
                  "label" : "Block name",
                  "type" : "text"
               },
               {
                  "category" : 10,
                  "category_name" : "Block",
                  "id" : "tag_id",
                  "index" : 16,
                  "label" : "Cross-section ID",
                  "type" : "publicid"
               },
               {
                  "category" : 9,
                  "category_name" : "ADFOX",
                  "id" : "adfox_block",
                  "index" : 17,
                  "label" : "ADFOX block",
                  "type" : "boolean"
               },
               {
                  "category" : 9,
                  "category_name" : "ADFOX",
                  "id" : "deal_id",
                  "index" : 18,
                  "label" : "Deal ID",
                  "type" : "publicid"
               },
               {
                  "category" : 9,
                  "category_name" : "ADFOX",
                  "id" : "deal_caption",
                  "index" : 19,
                  "label" : "Deal name",
                  "type" : "text"
               },
               {
                  "id" : "business_rule_id",
                  "index" : 20,
                  "label" : "Rule ID",
                  "type" : "publicid"
               },
               {
                  "id" : "business_rule_title",
                  "index" : 21,
                  "label" : "Rule name",
                  "type" : "text"
               },
               {
                  "category" : 7,
                  "category_name" : "Traffic",
                  "id" : "os",
                  "index" : 22,
                  "label" : "Operating system",
                  "type" : "publicid"
               },
               {
                  "category" : 7,
                  "category_name" : "Traffic",
                  "id" : "browser",
                  "index" : 23,
                  "label" : "Browser",
                  "type" : "publicid"
               },
...
               {
                  "category" : 6,
                  "category_name" : "Indicators for recommendations",
                  "id" : "RecommendationWidgetCTR",
                  "index" : 58,
                  "title" : "Recommendation widget CTR",
                  "type" : "text"
               }
            ],
            "has_product" : "",
            "has_raw_stat" : "",
            "id" : "payment",
            "title" : "Rewards"
         }
      ]
   },
   "result" : "ok"
}