Introduction

With the Yandex Metrica API, you can:

  • Manage tags, their settings, and access rights outside the web interface.
  • Get information about site traffic and other data.
  • Generate reports, including segmented and parameterized reports.

To access the Yandex Metrica API, you must be authenticated with an OAuth access token.

Structure of the API

The API has the following sections:

  • The Management API helps manage tags, goals, filters, and other Yandex Metrica objects (create tags, edit tag settings, create goals, manage access, and so on).
  • Reports API:

Versioning

All parts of the Yandex Metrica API support versioning. Each version has a specific identifier (v1, v2, and so on). When a new version of the API is released, the previous version continues functioning to support backward compatibility.

If you are just getting started with the API, use the latest version. If you are running previous versions of the API, we recommend gradually migrating to the latest version, because older versions deprecate over time.

When making API requests, always specify the version you want to work with.

https://api-metrica.yandex.net/stat/v1/data?id=...
https://api-metrica.yandex.net/stat/v2/data?id=...

Resources

The Yandex Metrica API is built on REST principles.

Everything that can be managed via the API is represented by resources: statistics, the list of counters, the counter itself, counter goals and each specific goal, counter access, and so on.

In other words, a resource is an integral part of the system. Here's what you can do with it:
  • Read the contents and current status of the resource (GET).
  • Modify the contents and status and write it to the resource (PUT).
  • Delete the resource (DELETE).
  • Perform special actions, such as adding new elements to a list (POST).

Each resource has its own unique URL. All actions are executed by the corresponding HTTP methods at the resource URLs.

For example, to get information about a counter, you send a GET request to the counter URL. To create a new tag, send a POST request with the tag body to the URL of the “tag list” resource.