Metrica API

The API serves to call Yandex.Metrica functions programmatically. This makes it possible to automate various features that are available in the Yandex.Metrica web interface, such as creating counters, setting up goals, and getting site visitation statistics.

Note

When using the API, a general familiarity with Yandex.Metrica is helpful. Refer to the Help for additional information.

How to make an API request

You must have a Yandex account and an access token. The token confirms a particular user's agreement to allow access to personal data in Yandex.Metrica via the API. The samples below use the token 05dd3dd84ff948fdae2bc4fb91f13e22. This token allows us to read Yandex.Metrica data belonging to a test user, so we can explore the API.

The following request returns a list of counters for the test user:

By default, the API responds in XML format. To receive a JSON response, add .json to the address part of the request. The pretty=1 parameter improves the readability of the response:

Use GET requests to get data about counters, goals, filters, and other Yandex.Metrica objects. For creating objects, use the POST method; for editing, use PUT; and for deleting, use DELETE. A complete list of objects is provided in the Resource guide section.

How to get statistics

Use GET requests to get Yandex.Metrica reports. The following address returns site visitation data by time of day in JSON format for the test user:

A complete list of reports and sample requests are provided in the section Getting statistics.

How to start developing an application

1Get an access token.
2Choose the interaction format — JSON or XML.
3

Review the resource guide. It lists Yandex.Metrica objects and provides links to descriptions of how to work with them: creating, editing, deleting, and getting information.