---
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: en/example.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
sourcePath: en/reports/example.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/direct/doc/en/llms.txt

# Example: clicks and cost

This example shows how to get the number of clicks and their cost for campaigns, broken down by day (in the user's currency, including VAT). The report period is determined automatically (see section [How to get updated statistics](https://yandex.ru/dev/direct/doc/reports/actual.html)).

## Request

{% 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 %}

## Response

```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
```

#### Learn more

[PHP examples for JSON](https://yandex.com/dev/direct/doc/php5-json-curl.html)
[Python examples for JSON](https://yandex.com/dev/direct/doc/python3-json.html)
[Python examples for XML](https://yandex.com/dev/direct/doc/python3-xml.html)
