Skip to main content

The Selling Partner API Python SDK enables you to easily connect to and work with Amazon SP-API.

Project description

Python SDK for Selling Partner API

PyPI version

Video Thumbnail

Click on the image to watch the video.

The Selling Partner API SDK for Python enables you to easily connect your Python application to Amazon's REST-based Selling Partner API.

Getting started

Credentials

Before you can use the SDK, you need to be registered as a Selling Partner API developer. If you haven't done that yet, please follow the instructions in the SP-API Registration Overview. You also need to register your application to get valid credentials to call SP-API. If you haven't done that yet, please follow the instructions in Registering your Application. If you are already registered successfully, you can find instructions on how to view your credentials in Viewing your Application Information and Credentials.

Minimum requirements

To run the SDK you need Python version 3.9 or higher.

Install the SDK

  1. Find the latest version number here.
  2. Add the dependency to your project
Using pip:
pip install amzn-sp-api
Add to your project requirements.txt

Add the following line to the requirements.txt file if needed:

amzn-sp-api >= "1.0.0"

Use the SDK

In order to call one of the APIs included in the Selling Partner API, you need to:

  1. Configure credentials (Note: Use your individual credentials for clientId, clientSecret and refreshToken). You can also configure the region and the authorization scope at this level.
  2. Initialize the SPAPI Client using the configuration created in the previous step
  3. Create an instance for a specific API using the API client created
  4. Call an API operation

For example, refer to the following sample code for connecting to Sellers API.

from spapi import SellersApi, SPAPIConfig, SPAPIClient, ApiException
from spapi.models.sellers_v1 import GetMarketplaceParticipationsResponse

if __name__ == "__main__":

    # Credentials configuration
    config = SPAPIConfig(
        client_id="",
        client_secret="",
        refresh_token="",
        region="NA",
        scope = None
    )

    # Create the API Client with configuration
    client = SPAPIClient(config)
    sellers_api = SellersApi(client.api_client)

    response = None
    try:
        response = sellers_api.get_marketplace_participations()
    except ApiException as e:
        print(f"API Exception occurred: {str(e)}")

    if response is not None:
        print("Sellers API Response:")
        get_marketplace_participations_response = GetMarketplaceParticipationsResponse(response.payload)
        for marketplaceParticipation in get_marketplace_participations_response.payload:
            print(marketplaceParticipation.marketplace.id)

Note: Code can be found under python/sample-app folder

Giving Feedback

We need your help in making this SDK great. Please participate in the community and contribute to this effort by submitting issues, participating in discussion forums and submitting pull requests through the following channels:

Submit issues - this is the preferred channel to interact with our team Articulate your feature request or upvote existing ones on our Issues page

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

amzn_sp_api-1.8.0.tar.gz (964.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

amzn_sp_api-1.8.0-py3-none-any.whl (3.2 MB view details)

Uploaded Python 3

File details

Details for the file amzn_sp_api-1.8.0.tar.gz.

File metadata

  • Download URL: amzn_sp_api-1.8.0.tar.gz
  • Upload date:
  • Size: 964.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for amzn_sp_api-1.8.0.tar.gz
Algorithm Hash digest
SHA256 5b964c7c423915576bf5b975a4f18d71d17bb99c072a1d2e2b9a49fd56068f1e
MD5 e776b2b2a052e9767cdb46720bbfbf36
BLAKE2b-256 19ce5d71d39b99d4bc60449ece0dd4b1188a0124e19b4c752d5841cbdbbd470c

See more details on using hashes here.

File details

Details for the file amzn_sp_api-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: amzn_sp_api-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for amzn_sp_api-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc0d5a03e6280b84ea74506bf52127e4e630495235e71c6b600b5a3064ad7863
MD5 7aa9e5640a75a8e16d6fe0e8ee29642f
BLAKE2b-256 fef1b8c6ffaa12475407aff4b658602b3b2f9b95a720a5c0d57e2df2d6bf7e2e

See more details on using hashes here.

Supported by

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