export_to_csv
Export VK Ads statistics for ad plans, groups, or banners to a CSV file on disk. Specify object type, date range, and output path.
Instructions
Export VK Ads statistics to a CSV file on disk.
Fetches statistics for the given object type and date range via the shared
client (which transparently splits ranges longer than 92 days and id lists
longer than 50 into multiple requests), flattens each returned item into a
CSV row using the stdlib :mod:csv module, and writes the result to
output_path. Read-only: it never mutates any ad object.
The CSV header is the union of every key seen across all items, in first-seen order. Missing values for a given row are written as empty cells. All values are stringified.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| object_type | Yes | One of ``ad_plans`` (campaigns), ``ad_groups``, or ``banners``. An invalid value raises an error. | |
| date_from | Yes | Inclusive start date in ``YYYY-MM-DD`` format. | |
| date_to | Yes | Inclusive end date in ``YYYY-MM-DD`` format. | |
| output_path | Yes | Filesystem path where the CSV file is written. An existing file at this path is overwritten. | |
| period | No | ``day`` for a per-day breakdown or ``summary`` for a single aggregated row per object. Defaults to ``day``. | day |
| metrics | No | Metrics group to request, e.g. ``base``, ``all``, ``uniques``, or ``video``. Defaults to ``base``. | base |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |