### Example SQL Query for Operating System Report Source: https://yandex.ru/dev/metrika/en/stat/index This SQL query demonstrates how dimensions and metrics can be conceptualized in a database context, similar to how they are used in the Yandex Metrica API. ```sql SELECT operatingSystem, avg(depth) from visits GROUP BY operatingSystem ``` -------------------------------- ### Example API Request for Page Depth by OS Source: https://yandex.ru/dev/metrika/en/stat/index This is an example of a Yandex Metrica API request to retrieve the average page views, with data grouped by operating system type. The 'limit' parameter restricts the number of results returned. ```http https://api-metrika.yandex.net/stat/v1/data.csv?id=44147844&metrics=ym:s:avgPageViews&dimensions=ym:s:operatingSystem&limit=5 ``` -------------------------------- ### Filter Data by Traffic Source and URL Source: https://yandex.ru/dev/metrika/en/stat/index Use this example to retrieve session and user counts segmented by search engine and a specific URL pattern. It demonstrates filtering by traffic source and URL dimensions. ```http https://api-metrika.yandex.net/stat/v1/data?dimensions=ym:s:searchEngineName&metrics=ym:s:visits,ym:s:users&filters=ym:s:trafficSourceName=='Search engine traffic' AND ym:pv:URL=@'help'&id=44147844 ``` -------------------------------- ### Get Statistics Data Source: https://yandex.ru/dev/metrika/en/stat/index Retrieves statistics data from Yandex Metrica in either JSON (default) or CSV format. Requires counter ID, metrics, and dimensions. ```APIDOC ## GET /stat/v1/data ### Description Retrieves statistics data from Yandex Metrica. The format can be specified as CSV in the URL, or it defaults to JSON if omitted. ### Method GET ### Endpoint https://api-metrika.yandex.net/stat/v1/data.{format}? ### Parameters #### Query Parameters - **counter_id** (integer) - Required - The ID of the counter. - **metrics** (string) - Required - The metrics to retrieve (e.g., `ym:s:visits`). - **dimensions** (string) - Optional - The dimensions to group the data by (e.g., `ym:s:date`). - **format** (string) - Optional - The desired response format. Can be `csv` or `json` (default). ### Response #### Success Response (200) - **contains_sensitive_data** (boolean) - Indicates if the provided data has limited disclosure. `true` if sensitive data is included, `false` otherwise. - The response body will be in JSON or CSV format depending on the `format` parameter, containing the requested statistics. ``` -------------------------------- ### /stat/v1/data/bytime Source: https://yandex.ru/dev/metrika/en/stat/index Retrieves data divided over units of time, suitable for building charts and tracking trends. ```APIDOC ## GET /stat/v1/data/bytime ### Description Retrieves time-series statistical data, divided by time units (days, weeks, months), useful for trend analysis and charting. ### Method GET ### Endpoint /stat/v1/data/bytime ### Parameters (Parameters are similar to /stat/v1/data, specific details would be in the linked documentation.) ### Response (Response structure would be specific to time-series data.) ``` -------------------------------- ### Requesting CSV Report Format Source: https://yandex.ru/dev/metrika/en/stat/index Use this format to request reports in CSV. Ensure to replace placeholders with your actual counter ID, metrics, and dimensions. ```http GET https://api-metrika.yandex.net/stat/v1/data.**csv**?&& ``` -------------------------------- ### /stat/v1/data/comparison/drilldown Source: https://yandex.ru/dev/metrika/en/stat/index Compares segments specified in the same request, displaying data in a tree-view report. ```APIDOC ## GET /stat/v1/data/comparison/drilldown ### Description Compares multiple segments within a single request, presenting the results in a tree-view report format. ### Method GET ### Endpoint /stat/v1/data/comparison/drilldown ### Parameters (Parameters are similar to /stat/v1/data, specific details would be in the linked documentation.) ### Response (Response structure would be specific to comparison drill-down data.) ``` -------------------------------- ### /stat/v1/data/drilldown Source: https://yandex.ru/dev/metrika/en/stat/index Generates a single branch of a tree view report for drill-down analysis. ```APIDOC ## GET /stat/v1/data/drilldown ### Description Generates a single branch of a tree view report, allowing for detailed exploration of data hierarchies. ### Method GET ### Endpoint /stat/v1/data/drilldown ### Parameters (Parameters are similar to /stat/v1/data, specific details would be in the linked documentation.) ### Response (Response structure would be specific to drill-down data.) ``` -------------------------------- ### /stat/v1/data/comparison Source: https://yandex.ru/dev/metrika/en/stat/index Compares segments specified in the same request, displaying data in a table format. ```APIDOC ## GET /stat/v1/data/comparison ### Description Compares multiple segments within a single request, presenting the results in a tabular format. ### Method GET ### Endpoint /stat/v1/data/comparison ### Parameters (Parameters are similar to /stat/v1/data, specific details would be in the linked documentation.) ### Response (Response structure would be specific to comparison data.) ``` -------------------------------- ### /stat/v1/data Source: https://yandex.ru/dev/metrika/en/stat/index Retrieves statistical data in a table format. Supports various dimensions and metrics, with options for filtering. ```APIDOC ## GET /stat/v1/data ### Description Retrieves statistical data, with dimensions and metrics grouped by sessions (`ym:s:`) or hits (`ym:pv:`). ### Method GET ### Endpoint /stat/v1/data ### Parameters #### Query Parameters - **dimensions** (string) - Required - Data grouped by specified dimensions (e.g., `ym:s:searchEngineName`). - **metrics** (string) - Required - Metrics to retrieve (e.g., `ym:s:visits,ym:s:users`). - **filters** (string) - Optional - Data segmentation by dimensions. - **id** (integer) - Required - Counter ID. ### Request Example ```json { "example": "https://api-metrika.yandex.net/stat/v1/data?dimensions=ym:s:searchEngineName&metrics=ym:s:visits,ym:s:users&filters=ym:s:trafficSourceName=='Search engine traffic' AND ym:pv:URL=@'help'&id=44147844" } ``` ### Response #### Success Response (200) - **data** (array) - Array of data rows. - **query** (object) - Information about the query. - **sample** (object) - Sampling information. #### Response Example { "example": "{\"data\":[{\"dimensions\":[{\"name\":\"Yandex\"}],\"metrics\":[\"100\",\"50\"]}],\"query\":{\"ids\":[44147844],\"dimensions\":[\"ym:s:searchEngineName\"],\"metrics\":[\"ym:s:visits\",\"ym:s:users\"],\"filters\":\"ym:s:trafficSourceName==\\'Search engine traffic\' AND ym:pv:URL=@'help'\"},\"sample\":{\"க்கூ\":100,\"க்கூ_count\":100}}" ``` -------------------------------- ### Requesting Default JSON Report Format Source: https://yandex.ru/dev/metrika/en/stat/index This is the default format for API responses. The format parameter can be omitted if JSON is desired. Replace placeholders with your actual counter ID, metrics, and dimensions. ```http GET https://api-metrika.yandex.net/stat/v1/data?&& ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.