---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.ru/dev/direct/doc/en/example.md
  - https://yandex.ru/dev/direct/doc/ru/example.md
  - href: ru/example.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: ru/reports/example.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/direct/doc/ru/llms.txt

# Пример: клики и стоимость

Пример демонстрирует получение количества кликов и их стоимости (в валюте пользователя, с учетом НДС) для кампаний в разбивке по дням. Период отчета определяется автоматически (см. раздел [Как получить актуальную статистику](https://yandex.ru/dev/direct/doc/reports/actual.html)).

## Запрос

{% list tabs %}

- JSON

  ```text translate=no
  curl \
  -H 'Authorization: Bearer 0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f' \
  -H 'Accept-Language: en' \
  -H 'Client-Login: agrom' \
  -H 'returnMoneyInMicros: false' \
  -d '{
    "params": {
      "SelectionCriteria": {
        "Filter": [{
          "Field": "CampaignId",
          "Operator": "IN",
          "Values": [ "10002", "10007" ]
        }]
      },
      "FieldNames": [ "Date", "CampaignId", "Clicks", "Cost" ], 
      "OrderBy": [{
        "Field": "Date"
      }],
      "ReportName": "Actual Data",
      "ReportType": "CAMPAIGN_PERFORMANCE_REPORT",
      "DateRangeType": "AUTO",
      "Format": "TSV",
      "IncludeVAT": "YES",
      "IncludeDiscount": "YES"
    }
  }' \
  https://api.direct.yandex.com/json/v501/reports
  ```

- XML

  ```text translate=no
  curl \
  -H 'Authorization: Bearer 0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f' \
  -H 'Accept-Language: en' \
  -H 'Client-Login: agrom' \
  -H 'returnMoneyInMicros: false' \
  -d '<?xml version="1.0" encoding="UTF-8"?>
    <ReportDefinition xmlns="http://api.direct.yandex.com/v5/reports">
      <SelectionCriteria>
        <Filter>
          <Field>CampaignId</Field>
          <Operator>IN</Operator>
          <Values>10002</Values>
          <Values>10007</Values>
        </Filter>
      </SelectionCriteria>
      <FieldNames>Date</FieldNames>
      <FieldNames>CampaignId</FieldNames>
      <FieldNames>Clicks</FieldNames>
      <FieldNames>Cost</FieldNames>
      <OrderBy>
        <Field>Date</Field>
      </OrderBy>
      <ReportName>Actual Data</ReportName>
      <ReportType>CAMPAIGN_PERFORMANCE_REPORT</ReportType>
      <DateRangeType>AUTO</DateRangeType>
      <Format>TSV</Format>
      <IncludeVAT>YES</IncludeVAT>
      <IncludeDiscount>YES</IncludeDiscount>
    </ReportDefinition>' \
  https://api.direct.yandex.com/v501/reports
  ```

{% endlist %}

## Ответ

```text translate=no
"Actual Data (2018-04-01 - 2018-04-03)"
Date CampaignId Clicks Cost
2018-04-01 10002 6 90.20
2018-04-01 10007 397 1496.50
2018-04-02 10002 13 158.60
2018-04-02 10007 314 1181.40
2018-04-03 10002 15 165.10
2018-04-03 10007 447 1619.60
Total rows: 6
```

#### Узнайте больше

[Примеры на PHP для JSON](https://yandex.ru/dev/direct/doc/ru/php5-json-curl.html)
[Примеры на Python для JSON](https://yandex.ru/dev/direct/doc/ru/python3-json.html)
[Примеры на Python для XML](https://yandex.ru/dev/direct/doc/ru/python3-xml.html)
