Ozon, one of the largest e-commerce platforms in Russia, offers an API that allows sellers to automate various aspects of their business, including promotion analytics. Understanding and utilizing Ozon’s API can significantly enhance your marketing efforts and streamline your operations. This article will guide you through the process of automating promotion analytics using Ozon’s API.

What is Ozon API?

The Ozon API is a powerful tool that provides programmatic access to Ozon’s internal advertising system. This API allows users to retrieve detailed statistics and automate promotional tasks. Unlike many other APIs, Ozon’s API is asynchronous and returns data in an archived file format, making it unique and slightly more complex to handle.

Setting Up Your Environment

Before diving into the code, it’s crucial to set up your environment. You’ll need a few key libraries for this process: requests, python-dotenv, and pandas. Setting up a virtual environment can help manage dependencies and keep your project organized.

Obtaining API Credentials

To interact with Ozon’s API, you need to obtain Client ID and Client Secret from your personal account on Ozon. These credentials are essential for generating an access token, which will be used for all subsequent API requests.

import requests
import os
from dotenv import load_dotenv


CLIENT_ID = os.getenv('CLIENT_ID')

Generating an Access Token

The first step in using the API is to generate an access token. This token is valid for 30 minutes and must be used to authenticate all API requests.

url = "https://api.ozon.ru/sell/v1/oauth/token"
headers = {
    "Content-Type": "application/json",
    "Accept": "application/json"
payload = {
    "client_id": CLIENT_ID,
    "client_secret": CLIENT_SECRET,
    "grant_type": "client_credentials"

response = requests.post(url, headers=headers, json=payload)
access_token = response.json().get('access_token')

Fetching Campaign Data

Once you have the access token, you can start fetching data from the API. For example, to get a list of your advertising campaigns, you can use the following code:

url = "https://api.ozon.ru/performance/v1/campaigns"
headers = {
    "Authorization": f"Bearer {access_token}",
    "Content-Type": "application/json",
    "Accept": "application/json"

response = requests.get(url, headers=headers)
campaigns = response.json().get('campaigns', [])

Requesting Promotion Statistics

To obtain promotion statistics, you need to send a POST request with the date range and campaign IDs. The API will return a report ID, which you can use to check the report status and download it when ready.

report_payload = {
    "campaigns": [campaign_id_list],
    "date_from": "2024-01-01",
    "date_to": "2024-01-31"

report_response = requests.post(report_url, headers=headers, json=report_payload)
report_id = report_response.json().get('report_id')

Checking Report Status and Downloading

After requesting the report, check its status periodically until it’s ready for download. The report is usually available as a ZIP file if there are multiple campaigns.

status_url = f"https://api.ozon.ru/performance/v1/report/status?report_id={report_id}"
status_response = requests.get(status_url, headers=headers)

if status_response.json().get('status') == 'done':
    download_url = f"https://api.ozon.ru/performance/v1/report/download?report_id={report_id}"
    download_response = requests.get(download_url, headers=headers)

    with open('report.zip', 'wb') as f:

Extracting and Processing Data

Once the ZIP file is downloaded, extract its contents and process the CSV files to analyze the data.

import zipfile
import pandas as pd

with zipfile.ZipFile('report.zip', 'r') as zip_ref:

csv_files = [f for f in os.listdir('extracted_reports') if f.endswith('.csv')]
data_frames = [pd.read_csv(f'extracted_reports/{file}', delimiter=';') for file in csv_files]

combined_df = pd.concat(data_frames, ignore_index=True)
combined_df.to_csv('final_report.csv', index=False)

Example Table: Promotion Statistics

Campaign IDDateImpressionsClicksSpend


Automating promotion analytics using Ozon’s API can greatly enhance your marketing efficiency and provide deeper insights into your campaigns. By following the steps outlined in this article, you can leverage the power of Ozon’s API to streamline your promotional efforts. Don’t forget to regularly check the status of your reports and handle the extracted data carefully to ensure accurate analysis. Happy automating!

Comments (0)

There are no comments here yet, you can be the first!

Leave a Reply

Your email address will not be published. Required fields are marked *

Choose and Buy Proxy

Datacenter Proxies

Rotating Proxies

UDP Proxies

Trusted By 10000+ Customers Worldwide

Proxy Customer
Proxy Customer
Proxy Customer flowch.ai
Proxy Customer
Proxy Customer
Proxy Customer