Skip to main content
Asynchronous Exports is available on Topsort’s public API. Use an Advanced API key to call it.
An export is a file with the advertising numbers you choose. For example: impressions, clicks, and spend for each vendor and campaign, one row per day, for the month of September. You do not wait while Topsort builds the file. You ask for it, check back until it is ready, and then download it. The file is Parquet. Programs such as Python can open it as a table. For the list of dimensions, metrics, limits, and common questions, see Asynchronous Exports in the Knowledge Base.

Before you start

You need an Advanced API key. The API address is https://api.topsort.com. The examples use curl. Save these once, so you can reuse them:
Every request sends the key in this header:
If the header is missing, or the token is not valid, any endpoint answers 401 Unauthorized:

1. See what you can export

Ask which datasets exist and which columns each one allows. This call takes no parameters. A dataset is a kind of report. A dimension is how each row is split, such as the day or the vendor. A metric is a number in that row, such as clicks or spend.
Response 200 OK, shortened:
If something fails on our side, the call returns 500 with internal_error. Contact our customer support team.

2. Ask for the file

Send the dataset, the columns you want, and the days you want.
Dates are local days of your marketplace. To export one day, send the same date as both startDate and endDate. Columns in the file follow the order you send: dimensions first, then metrics.
If the window includes today, today’s numbers can still change later.
Response 201 Created:
Save exportId. You need it for the next step. Each accepted export counts toward your daily quota of 20, which resets at midnight UTC. 400 Bad Request means the request breaks an export rule:
429 Too Many Requests (daily_request_limit_exceeded) means you used today’s quota. Wait until resetsAt in details. The Retry-After header says how many seconds are left. 422 Unprocessable Entity (validation_error) means a field is missing, a list is empty, a dataset, dimension, metric, or granularity does not exist, or a date is not YYYY-MM-DD. details points to the field to fix.

3. Check until the file is ready

Ask for the export with the exportId from step 2.
While it is pending or running, the response has no download link yet:
Check again at most once a minute. Wait longer between checks for exports that take a while. Most exports finish in less than an hour. When it is completed and has rows, the response includes downloadUrl:
When it is completed and no rows matched, there is no file and no downloadUrl. The export still finishes as completed. message explains why.
When it is failed, error says why. Failed exports are not retried. Request a new one. Use a shorter window or fewer dimensions if it failed because it took too long or the file was too large.

4. Download the file

Download the Parquet file from downloadUrl. The link already carries its own signature, so do not send the Authorization header.
The link works for 1 hour from the moment you receive it, until downloadExpiresAt. If it expires, repeat step 3 to get a new link. You do not need to create a new export. To take a quick look at the file with Python:
head() prints the first rows, so you can confirm the columns and the dates before you load the file anywhere else.

Endpoints