Skip to main content

API wrapper for the Amazon Ads API

Project description

Amazon Ads API Connector

A simple Python wrapper for the latest version of the Amazon Ads API for Sponsored Products campaign management.

This module covers the key endpoints for managing Sponsored Products campaigns. This includes methods for authentication, pagination and report generation. It features keyword and negative keyword targeting, as well as product AISIN targeting.

Please note that this module does not yet support Sponsored Brands and Sponsored Display campaigns.

Installation

Amazon Ads API Connector is available on PyPI:

pip install amazon-ads-api-connector

Getting started

The primary class of the module is AmazonAdsAPIConnector. This class provides methods to create, list, update and delete

  • campaigns,
  • ad groups,
  • product ads,
  • keywords,
  • negative keywords, and
  • targeting clauses (ASIN targeting).

It furthermore provides methods to request and retrieve reports via the API.

To create an instance of the AmazonAdsAPIConnector, you need to pass your Amazon Ads API credentials as a dictionary. The dictionary must contain the following keys:

  • refresh_token
  • client_id
  • client_secret
  • profile_id

Upon initialization, the AmazonAdsAPIConnector object will create a new access token. This access token will be valid for 60 minutes, however, the object automatically requests a new access token in case it has expired when trying to make a new request.

For more information about the Amazon Ads API, please visit the official documentation.

Examples

Import the library

from amazon_ads_api_connector import AmazonAdsAPIConnector

Create an instance

api = AmazonAdsAPIConnector(
    {
        "refresh_token": "your_refresh_token",
        "client_id": "your_client_id",
        "client_secret": "your_client_secret",
        "profile_id": "your_profile_id",
    }
)

List campaigns

campaigns = api.list_campaigns()

Create campaigns

api.create_campaign(
    campaigns=[
        {
            "name": "My Campaign",
            "targetingType": "MANUAL",
            "state": "ENABLED",
            "dynamicBidding": {
                "strategy": "LEGACY_FOR_SALES",
            },
            "bugdget": {
                "budgetType": "DAILY",
                "budget": 0,
            },
        },
    ]
)

Please note that all create and update methods expect a list of dictionaries as their only argument. This reflects the fact that the Amazon Ads API allows to create or update multiple objects at once. To ensure the greatest possible flexibility, the structure of the list and the dictionaries corresponds to the structure specified by the API and described in the API documentation.

Request and retrieve a report

The module furthermore contains classes which represent basic configurations of the available report types:

  • CampaignsReport
  • TargetingReport
  • SearchTermReport
  • AdvertisedProductReports
  • PurchasedProductReport

For more information about the report types, please visit the official documentation. To request a report you need to pass an instance of one of these classes to the create_report method of the AmazonAdsAPIConnector class. To customize the report, change the properties of the class instance before passing it to the create_report method.

from amazon_ads_api_connector import SearchTermReport

report_configuration = SearchTermReport("2023-10-01", "2023-10-07")

res = api.create_report(report_configuration)
report = api.get_report(res)

Please note that report gerneration is asynchronous. The create_report method returns a dictionary containing the report ID. The get_report takes this dictionary as an argument and returns the report once it is completed and available. The completion of a report usually takes a few minutes and can take up to 3 hours.

Dependencies

This module depends on the requests library, which is not included in the standard library, but will be installed automatically when you install the amazon-ads-api-connector package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

amazon-ads-api-connector-0.1.2.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file amazon-ads-api-connector-0.1.2.tar.gz.

File metadata

File hashes

Hashes for amazon-ads-api-connector-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8b3500f61dcae58852d3792ffe01b6dc98f6c96ca99db492b5078d3fa8a745a8
MD5 3d62981bdd80b23bee1b9f9771333e31
BLAKE2b-256 4d42ae7db20b5ac9985b65a9275eb6d84c9700cd5ab11a6e79f5454db0f04e40

See more details on using hashes here.

Provenance

File details

Details for the file amazon_ads_api_connector-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for amazon_ads_api_connector-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bc2104d892f939a0aa89abb3f5be602d6243f679d5755cd3d7063e3605b89086
MD5 0dcc43c7f9fb424550210eaab68ce9d9
BLAKE2b-256 2451904dc3d85ae64b56ecbac024710fbdc5148a473c907c4559c7ed512f80f2

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page