Object IDs
To use dimensions and filters in the API, you need to know the IDs of specific values. For example, to select users of a certain region, you need to know the identifier of this region.
In general, to get the identifier of a specific object, you first need to make a general request to get a list of these objects.
The following are examples of using identifiers.
Region ID
You want to analyze which search engines users from Russia come from. To do this, you need to know the region's identifier.
First, make a request to get the IDs of all regions.
https://api-metrica.yandex.net/stat/v1/data/drilldown?ids=<counter_id>&dimensions=ym:s:regionCountry&metrics=ym:s:visits
Find the country RU
in the response and see its id
= 225
.
A response with a list of countries and their IDs
"data": [
{
"dimension": {
"icon_id": "225",
"icon_type": "country",
"iso_name": "RU",
"id": "225",
"name": "Russia"
},
"metrics": [
13193
],
"expand": false
},
{
"dimension": {
"icon_id": "149",
"icon_type": "country",
"iso_name": "BY",
"id": "149",
"name": "Belarus"
},
"metrics": [
515
],
"expand": false
},
{
"dimension": {
"icon_id": "118",
"icon_type": "country",
"iso_name": "NL",
"id": "118",
"name": "Netherlands"
},
"metrics": [
435
],
"expand": false
},
{
"dimension": {
"icon_id": "159",
"icon_type": "country",
"iso_name": "KZ",
"id": "159",
"name": "Kazakhstan"
},
"metrics": [
374
],
"expand": false
},
{
"dimension": {
"icon_id": "96",
"icon_type": "country",
"iso_name": "DE",
"id": "96",
"name": "Germany"
},
"metrics": [
332
],
"expand": false
}
]
Now you can perform a targeted query to analyze the sources of search traffic from users from Russia using the filter: filters=(ym:s:regionCountry IN('225'))
.
https://api-metrica.yandex.net/stat/v1/data?ids=<counter_id>&metrics=ym:s:visits&dimensions=ym:s:<attribution>SourceEngine&filters=(ym:s:regionCountry IN('225'))
Source ID
You want to analyze the traffic from search engines. To do this, you need to know the ID of the corresponding source.
First, make a request to get the IDs of all sources for the period you are interested in.
https://api-metrica.yandex.net/stat/v1/data/drilldown?ids=<counter_id>&dimensions=ym:s:<attribution>TrafficSource,ym:s:<attribution>SourceEngine&metrics=ym:s:visits&date1=2025-01-01&date2=2025-01-31&attribution=lastsign
Find the source Search engine traffic
in the response and see its id
= organic
.
A response with a list of traffic sources and their IDs
"data": [
{
"dimension": {
"icon_id": "1",
"icon_type": "traffic-source",
"name": "Link traffic",
"id": "referral"
},
"metrics": [
7725
],
"expand": true
},
{
"dimension": {
"icon_id": "2",
"icon_type": "traffic-source",
"name": "Search engine traffic",
"id": "organic"
},
"metrics": [
6192
],
"expand": true
},
{
"dimension": {
"icon_id": "0",
"icon_type": "traffic-source",
"name": "Direct traffic",
"id": "direct"
},
"metrics": [
3685
],
"expand": false
},
{
"dimension": {
"icon_id": "-1",
"icon_type": "traffic-source",
"name": "Internal traffic",
"id": "internal"
},
"metrics": [
705
],
"expand": false
},
{
"dimension": {
"icon_id": "7",
"icon_type": "traffic-source",
"name": "Mailing traffic",
"id": "email"
},
"metrics": [
316
],
"expand": false
},
{
"dimension": {
"icon_id": "10",
"icon_type": "traffic-source",
"name": "Messenger traffic",
"id": "messenger"
},
"metrics": [
67
],
"expand": true
},
{
"dimension": {
"icon_id": "8",
"icon_type": "traffic-source",
"name": "Social network traffic",
"id": "social"
},
"metrics": [
43
],
"expand": true
},
{
"dimension": {
"icon_id": "9",
"icon_type": "traffic-source",
"name": "Recommendation system traffic",
"id": "recommend"
},
"metrics": [
18
],
"expand": true
}
]
Now you can make a targeted request to get traffic data from search engines using the desired identifier: parent_id=["organic"]
:
https://api-metrica.yandex.net/stat/v1/data/drilldown?ids=<counter_id>&dimensions=ym:s:<attribution>TrafficSource,ym:s:<attribution>SourceEngine&metrics=ym:s:visits&date1=2025-01-01&date2=2025-01-310&attribution=lastsign&parent_id=["organic"]