Example. Campaign report
Let's walk through the full scenario: retrieving statistics for campaign 12345 for January 2024 — impressions, clicks, and daily CTR.
Step 1. Get metadata
curl -H 'Authorization: OAuth <token>' \
'https://adfox.yandex.ru/api/v2/reports/metadata?ownerId=67890'
In the response, find the required name values for the metrics and dimensions.
Step 2. Create a task
curl -X POST \
-H 'Authorization: OAuth <token>' \
-H 'Content-Type: application/json' \
-d '{
"metrics": ["loads_commercial", "clicks_total", "ctr"],
"dimensions": ["date"],
"dateRange": { "from": "2024-01-01", "to": "2024-01-31" },
"filters": [
{ "field": "campaign_id", "operator": "eq", "value": "12345" }
],
"ownerId": 67890
}' \
'https://adfox.yandex.ru/api/v2/reports'
Response:
{
"result": {
"taskId": "umr-a-rsr-b5555555-5555-5555-5555-555555555501",
"status": "PENDING"
}
}
Step 3. Check the task status
curl -H 'Authorization: OAuth <token>' \
'https://adfox.yandex.ru/api/v2/reports/umr-a-rsr-b5555555-5555-5555-5555-555555555501'
Repeat the request until the status becomes SUCCESS.
Step 4. Get the result
curl -H 'Authorization: OAuth <token>' \
'https://adfox.yandex.ru/api/v2/reports/umr-a-rsr-b5555555-5555-5555-5555-555555555501/result'
Response:
{
"result": {
"taskId": "umr-a-rsr-b5555555-5555-5555-5555-555555555501",
"columns": [
{ "name": "date", "type": "string" },
{ "name": "loads_commercial", "type": "integer" },
{ "name": "clicks_total", "type": "integer" },
{ "name": "ctr", "type": "number", "format": "float", "unit": "percent" }
],
"rows": [
["2024-01-01", 15000, 225, 1.5],
["2024-01-02", 18000, 270, 1.5]
],
"totals": [null, 33000, 495, null]
}
}
The order of values in each row of rows matches the order of columns in columns.
Was the article helpful?
Previous