Exports
Vendor docs |
|
Specification |
https://d1y2lf8k3vrkfu.cloudfront.net/openapi/en-us/dest/AmazonAdsAPIExports_prod_3p.json |
The export resource takes a request for a snapshot of one entity type and answers an identifier. The file is built asynchronously, so the identifier is polled afterwards until the export is ready.
Each request names its own media type, application/vnd.<entity>export.v1+json,
and the client sends that version in both the Content-Type and the Accept
header. The version argument defaults to 1.
- class ad_api.api.Exports(account: str = 'default', marketplace: Marketplaces = Marketplaces.EU, credentials: Dict[str, str] | None = None, proxies: Dict[str, str] | None = None, verify: bool = True, timeout: int | None = None, debug: bool = False, access_token: str | None = None, verify_additional_credentials: bool = True)
Ask for a snapshot of one entity type and poll it until it is ready.
Four routes request an export, one per entity, and a fifth reads the result. A request answers 202 with an export id; the file is built afterwards, so the id is polled until its status reads COMPLETED and a download url appears.
The route picks the entity, not the body: /ads/export exports ads, /campaigns/export exports campaigns, and so on. The body only narrows which rows of that entity come back, by ad product and by state.
The status moves through PROCESSING, COMPLETED and FAILED. Only COMPLETED carries a url, and that url expires at urlExpiresAt. On FAILED the answer carries an error object with the reason.
Every route names its own media type, application/vnd.<entity>export.v<n>+json, built from the entity and the version argument. The service routes on that type, so the wrong one answers 406.
### Endpoint map
:header-rows: 1 Path
Method
Media type
/ads/exportPOST
application/vnd.adsexport.v1+json/campaigns/exportPOST
application/vnd.campaignsexport.v1+json/adGroups/exportPOST
application/vnd.adgroupsexport.v1+json/targets/exportPOST
application/vnd.targetsexport.v1+json/exports/{exportId}GET
### Example python
import json from ad_api.api import Exports result = Exports(account=store).ads_export( body=json.dumps({ "adProductFilter": {"include": ["SPONSORED_PRODUCTS"]} }) ) export_id = result.payload.get("exportId") status = Exports(account=store).get_export( exportId=export_id, typeExport="ads", )
- ads_export(version: int = 1, **kwargs) ApiResponse
Requests an export of the ads.
- Keyword Args
- body body (string | dict): filters. Every field is optional, and omitting one leaves its default in place. | adProductFilter (array): which ad products to include. One to three of SPONSORED_BRANDS, SPONSORED_DISPLAY, SPONSORED_PRODUCTS. Omitted, all three are included. | stateFilter (array): which states to include. One to three of ARCHIVED, ENABLED, PAUSED. Omitted, only ENABLED and PAUSED come back, never ARCHIVED.version (int): media type version. Defaults to 1.
- Returns:
- ApiResponse, 202 with an export id
- campaigns_export(version: int = 1, **kwargs) ApiResponse
Requests an export of the campaigns.
- Keyword Args
- body body (string | dict): filters. Every field is optional, and omitting one leaves its default in place. | adProductFilter (array): which ad products to include. One to three of SPONSORED_BRANDS, SPONSORED_DISPLAY, SPONSORED_PRODUCTS. Omitted, all three are included. | stateFilter (array): which states to include. One to three of ARCHIVED, ENABLED, PAUSED. Omitted, only ENABLED and PAUSED come back, never ARCHIVED.version (int): media type version. Defaults to 1.
- Returns:
- ApiResponse, 202 with an export id
- adgroups_export(version: int = 1, **kwargs) ApiResponse
Requests an export of the ad groups.
- Keyword Args
- body body (string | dict): filters. Every field is optional, and omitting one leaves its default in place. | adProductFilter (array): which ad products to include. One to three of SPONSORED_BRANDS, SPONSORED_DISPLAY, SPONSORED_PRODUCTS. Omitted, all three are included. | stateFilter (array): which states to include. One to three of ARCHIVED, ENABLED, PAUSED. Omitted, only ENABLED and PAUSED come back, never ARCHIVED.version (int): media type version. Defaults to 1.
- Returns:
- ApiResponse, 202 with an export id
- targets_export(version: int = 1, **kwargs) ApiResponse
Requests an export of the targets.
This route adds two filters of its own on top of the shared pair.
- Keyword Args
- body body (string | dict): filters. Every field is optional, and omitting one leaves its default in place. | adProductFilter (array): which ad products to include. One to three of SPONSORED_BRANDS, SPONSORED_DISPLAY, SPONSORED_PRODUCTS. Omitted, all three are included. | stateFilter (array): which states to include. One to three of ARCHIVED, ENABLED, PAUSED. Omitted, only ENABLED and PAUSED come back, never ARCHIVED. | negativeFilter (array): booleans choosing negative targets, positive targets, or both. Omitted, both come back. | targetLevelFilter (array): AD_GROUP, CAMPAIGN, or both. Omitted, both levels come back.version (int): media type version. Defaults to 1.
- Returns:
- ApiResponse, 202 with an export id
- get_export(exportId, typeExport, version: int = 1, **kwargs) ApiResponse
Reads the state of an export requested earlier.
Answers the export with its status and, once COMPLETED, the download url and its expiry. A FAILED export carries an error object instead.
- Keyword Args
- path exportId (string): the id returned when the export was requested. [required]typeExport (string): the entity the export covers, used to build the media type: ads, campaigns, adGroups or targets. [required]version (int): media type version. Defaults to 1.
- Returns:
- ApiResponse | exportId (string), status (string) | url (string), urlExpiresAt (string) | createdAt, generatedAt, fileSize, error