How to build an API v2 report

Step 1. Get a list of parameters

Use the GET /constructor_filters/api/ operation to get the section parameters.

Step 2. Choose parameters for building the report

The parameters are classified into several sections:

  • Filters (filters) are used to filter data and group them by time.
  • Filters with groupings (conditional_filters) are used to filter data by groups.
  • Indicators (measures) determine which metrics or reward types will be shown in the final response when requesting statistics. The report must include at least one parameter from this section.
  • Currency conversion (currency_converter) is used to convert report data to the selected currency.
  • Additional parameters allow you to customize your report. For example, you can enable paginated output using the paginate parameter.

Step 3. Form a request to generate the report

The request syntax is described in the GET /constructor_filters/api/ operation. Let's generate a report with the following parameters:

Set the time range for the report

{
  "id": "filters",
  "fields": [
    {
      "id": "period",
      "value": "2022.03.01-2022.03.31"
    }
  ]
}

Group data in the report by week

{
  "id": "filters",
  "fields": [
    {
      "id": "period",
      "value": "2022.03.01-2022.03.31"
    },
    {
      "id": "detalization",
      "value": "2"
    }
  ]
}

Set the indicator parameters that you want to see in the report

```json
{
"id": "measures",
"fields": [
{
"id": "partner_reward",
"value": [
{
"id": "default_fixed_partner_reward_metric",
"value": true
}
]
}
]
}


**Group data in the report by package name**

```json
{
  "id": "conditional_filters",
  "fields": [
    {
      "id": "Packs",
      "value": [
        {
          "id": "default_constructor_field_pack_caption_container",
          "value": [
            {
              "id": "default_constructor_field_pack_caption_group",
              "value": true
            }
          ]
        }
      ]
    }
  ]
}

Filter data in the report by the CLID type

{
  "id": "conditional_filters",
  "fields": [
    {
      "id": "Packs",
      "value": [
        {
          "id": "default_constructor_field_pack_caption_container",
          "value": [
            {
              "id": "default_constructor_field_pack_caption_group",
              "value": true
            }
          ]
        }
      ]
    },
    {
      "id": "CLIDs and Sets",
      "value": [
        {
          "id": "default_constructor_field_clid_type_id_container",
          "value": [
            {
              "id": "default_constructor_field_clid_type_id",
              "value": [
                "1003",
                "5",
                "100003"
              ]
            }
          ]
        }
      ]
    }
  ]
}
Final request
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -H "Authorization: OAuth 66..." -X POST "https://distribution.yandex.net/api/v2/constructor_statistics/api_table/?lang=ru" \
--data-raw '{
  "blocks": [
    {
      "id": "filters",
      "fields": [
        {
          "id": "period",
          "value": "2022.03.01-2022.03.31"
        },
        {
          "id": "detalization",
          "value": "2"
        }
      ]
    },
    {
      "id": "measures",
      "fields": [
        {
          "id": "partner_reward",
          "value": [
            {
              "id": "default_fixed_partner_reward_metric",
              "value": true
            }
          ]
        }
      ]
    },
    {
      "id": "conditional_filters",
      "fields": [
        {
          "id": "Packs",
          "value": [
            {
              "id": "default_constructor_field_pack_caption_container",
              "value": [
                {
                  "id": "default_constructor_field_pack_caption_group",
                  "value": true
                }
              ]
            }
          ]
        },
        {
          "id": "CLIDs and Sets",
          "value": [
            {
              "id": "default_constructor_field_clid_type_id_container",
              "value": [
                {
                  "id": "default_constructor_field_clid_type_id",
                  "value": [
                    "1003",
                    "5",
                    "100003"
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}'
Fragment of a successful response
{
  "data": {
    "id": "2a0ab5a7daa93fa3b4e7caa768b9467c",
    "label": "Table",
    "type": "statistics",
    "columns": [
      {
        "field": "default_field_dt",
        "label": "Date"
      },
      {
        "field": "default_field_pack_caption",
        "label": "Pack name"
      },
      {
        "field": "default_fixed_partner_reward_metric",
        "label": "Reward"
      }
    ],
    "totals": [
      {
        "default_field_dt": null,
        "default_field_pack_caption": null,
        "default_fixed_partner_reward_metric": "2 231 655.65 ₽"
      },
      {
        "default_field_dt": null,
        "default_field_pack_caption": null,
        "default_fixed_partner_reward_metric": "13 735.32 $"
      },
      {
        "default_field_dt": null,
        "default_field_pack_caption": null,
        "default_fixed_partner_reward_metric": "7 356.48 €"
      }
    ],
    "rows": [
      [
        {
          "default_field_pack_caption": "Pack caption example 1",
          "default_fixed_partner_reward_metric": "355.6 ₽",
          "default_field_dt": "Week 14 2022 (28.03.2022 - 03.04.2022)"
        }
      ],
      [
        {
          "default_field_pack_caption": "Pack caption example 2",
          "default_fixed_partner_reward_metric": "8.4 $",
          "default_field_dt": "Week 14 2022 (28.03.2022 - 03.04.2022)"
        }
      ],
      [
        {
          "default_field_pack_caption": "Pack caption example 1",
          "default_fixed_partner_reward_metric": "137.43 €",
          "default_field_dt": "Week 13 2022 (1.03.2022 - 27.03.2022)"
        }
      ],
      [
        {
          "default_field_pack_caption": "Pack caption example 3",
          "default_fixed_partner_reward_metric": "19 174.79 ₽",
          "default_field_dt": "Week 13 2022 (21.03.2022 - 27.03.2022)"
        }
      ]
    ],
    "current_page": null,
    "max_page": null,
    "count": 1000,
    "filters": {
      "blocks": [
        {
          "id": "filters",
          "fields": [
            {
              "id": "period",
              "value": "2022.03.01-2022.03.31"
            },
            {
              "id": "detalization",
              "value": "2",
              "choices": [
                {
                  "id": "1",
                  "label": "By days",
                  "slug": "by_days"
                },
                {
                  "id": "2",
                  "label": "By weeks",
                  "slug": "by_weeks"
                },
                {
                  "id": "3",
                  "label": "By months",
                  "slug": "by_months"
                },
                {
                  "id": "4",
                  "label": "By quarters",
                  "slug": "by_quarters"
                },
                {
                  "id": "5",
                  "label": "By years",
                  "slug": "by_years"
                },
                {
                  "id": "6",
                  "label": "Without groupings",
                  "slug": "without_detalization"
                }
              ]
            }
          ]
        },
        {
          "id": "measures",
          "fields": [
            {
              "id": "partner_reward",
              "value": [
                {
                  "id": "default_fixed_partner_reward_metric",
                  "value": true,
                  "label": "Reward"
                }
              ],
              "label": "Partner reward"
            }
          ]
        },
        {
          "id": "conditional_filters",
          "fields": [
            {
              "id": "Packs",
              "value": [
                {
                  "id": "default_constructor_field_pack_caption_container",
                  "value": [
                    {
                      "id": "default_constructor_field_pack_caption_group",
                      "value": true,
                      "label": "Pack name"
                    }
                  ]
                }
              ],
              "label": "Packs"
            },
            {
              "id": "CLIDs and Sets",
              "value": [
                {
                  "id": "default_constructor_field_clid_type_id_container",
                  "value": [
                    {
                      "id": "default_constructor_field_clid_type_id",
                      "value": [
                        "5",
                        "1003",
                        "100003"
                      ],
                      "choices": [
                        {
                          "id": "2023",
                          "label": "Alice"
                        },
                        {
                          "id": "1003",
                          "label": "Search widget"
                        },
                        {
                          "id": "5",
                          "label": "Home page"
                        },
                        {
                          "id": "1011",
                          "label": "Discovery revenue"
                        },
                        {
                          "id": "7",
                          "label": "Yandex button in Visual Bookmarks"
                        },
                        {
                          "id": "11",
                          "label": "Yandex button in the Opera side panel"
                        },
                        {
                          "id": "21",
                          "label": "Market. Advisor for sites"
                        },
                        {
                          "id": "27",
                          "label": "Partner links"
                        },
                        {
                          "id": "12",
                          "label": "Search in the Opera side bar"
                        },
                        {
                          "id": "9",
                          "label": "Search in the browser address bar"
                        },
                        {
                          "id": "1002",
                          "label": "Search in the notification panel"
                        },
                        {
                          "id": "100003",
                          "label": "Search in the search form on the partner site"
                        },
                        {
                          "id": "8",
                          "label": "Search form in Visual Bookmarks"
                        },
                        {
                          "id": "6",
                          "label": "Search form in the browser"
                        },
                        {
                          "id": "1004",
                          "label": "Search form in the app"
                        },
                        {
                          "id": "100016",
                          "label": "Link to Yandex Games"
                        },
                        {
                          "id": "20",
                          "label": "Link to Market"
                        },
                        {
                          "id": "25",
                          "label": "Link to Market from the Adviser"
                        },
                        {
                          "id": "15",
                          "label": "Link to Yandex from the \"Favorites\" Bookmarks bar"
                        },
                        {
                          "id": "1",
                          "label": "Unique installation"
                        }
                      ]
                    }
                  ]
                }
              ],
              "label": "CLIDs and sets"
            }
          ]
        },
        {
          "id": "currency_converter",
          "fields": [
            {
              "id": "convert_currency_to_field",
              "value": "-1",
              "choices": [
                {
                  "id": "-1",
                  "label": "In transaction currency"
                },
                {
                  "id": "1",
                  "label": "US dollar"
                },
                {
                  "id": "2",
                  "label": "Russian ruble"
                },
                {
                  "id": "3",
                  "label": "Euro"
                }
              ]
            }
          ]
        }
      ]
    }
  },
  "result": "ok"
}
Response to a request that fetched no data

Missing data is shown as empty totals and rows, as well as the "error" message: "There is not enough data, try to choose a different period or loosen the filters".

{
  "data": {
    "id": "2a0ab5a7daa93fa3b4e7caa768b9467c",
    "label": "Table",
    "type": "statistics",
    "columns": [
      {
        "field": "default_field_dt",
        "label": "Date"
      },
      {
        "field": "default_field_pack_caption",
        "label": "Pack name"
      },
      {
        "field": "default_field_currency",
        "label": "Contract currency"
      },
      {
        "field": "default_fixed_partner_reward_metric",
        "label": "Reward"
      }
    ],
    "totals": [],
    "rows": [],
    "current_page": null,
    "max_page": null,
    "count": 0,
    "filters": {
      "blocks": [
        {
          "id": "filters",
          "fields": [
            {
              "id": "period",
              "value": "2022.03.01-2022.03.31"
            },
            {
              "id": "detalization",
              "value": "2",
              "choices": [
                {
                  "id": "1",
                  "label": "By days",
                  "slug": "by_days"
                },
                {
                  "id": "2",
                  "label": "By weeks",
                  "slug": "by_weeks"
                },
                {
                  "id": "3",
                  "label": "By months",
                  "slug": "by_months"
                },
                {
                  "id": "4",
                  "label": "By quarters",
                  "slug": "by_quarters"
                },
                {
                  "id": "5",
                  "label": "By years",
                  "slug": "by_years"
                },
                {
                  "id": "6",
                  "label": "Without groupings",
                  "slug": "without_detalization"
                }
              ]
            }
          ]
        },
        {
          "id": "measures",
          "fields": [
            {
              "id": "partner_reward",
              "value": [
                {
                  "id": "default_fixed_partner_reward_metric",
                  "value": true,
                  "label": "Reward"
                }
              ],
              "label": "Partner reward"
            }
          ]
        },
        {
          "id": "conditional_filters",
          "fields": [
            {
              "id": "Packs",
              "value": [
                {
                  "id": "default_constructor_field_pack_caption_container",
                  "value": [
                    {
                      "id": "default_constructor_field_pack_caption_group",
                      "value": true,
                      "label": "Pack name"
                    }
                  ]
                }
              ],
              "label": "Packs"
            },
            {
              "id": "CLIDs and Sets",
              "value": [
                {
                  "id": "default_constructor_field_clid_type_id_container",
                  "value": [
                    {
                      "id": "default_constructor_field_clid_type_id",
                      "value": [
                        "5",
                        "1003",
                        "100003"
                      ],
                      "choices": [
                        {
                          "id": "2023",
                          "label": "Alice"
                        },
                        {
                          "id": "1003",
                          "label": "Search widget"
                        },
                        {
                          "id": "5",
                          "label": "Home page"
                        },
                        {
                          "id": "1011",
                          "label": "Discovery revenue"
                        },
                        {
                          "id": "7",
                          "label": "Yandex button is Visual Bookmarks"
                        },
                        {
                          "id": "11",
                          "label": "Yandex button in the Opera side panel"
                        },
                        {
                          "id": "21",
                          "label": "Market. Advisor for sites"
                        },
                        {
                          "id": "27",
                          "label": "Partner links"
                        },
                        {
                          "id": "12",
                          "label": "Search in the Opera side bar"
                        },
                        {
                          "id": "9",
                          "label": "Search in the browser address bar"
                        },
                        {
                          "id": "1002",
                          "label": "Search in the notification panel"
                        },
                        {
                          "id": "100003",
                          "label": "Search in the search form on the partner site"
                        },
                        {
                          "id": "8",
                          "label": "Search form in Visual Bookmarks"
                        },
                        {
                          "id": "6",
                          "label": "Search form in the browser"
                        },
                        {
                          "id": "1004",
                          "label": "Search form in the app"
                        },
                        {
                          "id": "100016",
                          "label": "Link to Yandex Games"
                        },
                        {
                          "id": "20",
                          "label": "Link to Market"
                        },
                        {
                          "id": "25",
                          "label": "Link to Market from the Adviser"
                        },
                        {
                          "id": "15",
                          "label": "Link to Yandex from the \"Favorites\" Bookmarks bar"
                        },
                        {
                          "id": "1",
                          "label": "Unique installation"
                        }
                      ]
                    }
                  ]
                }
              ],
              "label": "CLIDs and sets"
            }
          ]
        },
        {
          "id": "currency_converter",
          "fields": [
            {
              "id": "convert_currency_to_field",
              "value": "-1",
              "choices": [
                {
                  "id": "-1",
                  "label": "In transaction currency"
                },
                {
                  "id": "1",
                  "label": "US dollar"
                },
                {
                  "id": "2",
                  "label": "Russian ruble"
                },
                {
                  "id": "3",
                  "label": "Euro"
                }
              ]
            }
          ]
        }
      ]
    }
  },
  "result": "ok"
}