Skip to main content

Amazon selling partner api clients.

Project description

sp-api-clients

This is a package generated from amazon selling partner open api models.

This package is for my personal usage, and may not be a good package, but enough for myself.

Features

  • ready to use;
  • provide code to generate clients, in case that amazon update models;
  • type hint.

Usage

For saving time, just paste my test code here.

For better understanding, all the fields are the same length of actual fields, and some readable information are kept.

def test_api():
    from datetime import datetime
    import sp_api_clients
    endpoint = "https://sellingpartnerapi-eu.amazon.com"
    marketplace_id = "A1F83G8C2ARO7P"

    refresh_token = "Atzr|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
                    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
                    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
                    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    order_pk = 'xxx-xxxxxxx-xxxxxxx'
    role_arn = "arn:aws:iam::xxxxxxxxxxxx:role/sp_api_role"
    aws_access_key = 'xxxxxxxxxxxxxxxxxxxx'
    aws_secret_key = "xxxxx/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    client_config = dict(
        role_arn=role_arn,
        endpoint=endpoint,
        marketplace_id=marketplace_id,
        refresh_token=refresh_token,
        aws_access_key=aws_access_key,
        aws_secret_key=aws_secret_key,
    )
    order_client = sp_api_clients.orders.OrdersClient(**client_config)

    orders = order_client.getOrders(
        MarketplaceIds=[marketplace_id],
        CreatedAfter=datetime(2000, 1, 1).isoformat()).payload.Orders
    assert len(orders) > 0
    assert orders[0].AmazonOrderId == order_pk

Configuration

The client configuration can be set both at the initiation and as environment variables.

  • SP_API_ROLE_ARN
  • SP_API_ENDPOINT
  • SP_API_MARKETPLACE_ID
  • SP_API_REFRESH_TOKEN
  • SP_API_AWS_ACCESS_KEY
  • SP_API_AWS_SECRET_KEY
  • SP_API_LWA_CLIENT_KEY
  • SP_API_LWA_CLIENT_SECRET

Build

The client is generated in the following steps:

  1. download amazon open api repository;
  2. copy open api 2 json files from the amazon repository to a single directory;
  3. convert open api 2 json files to open api 3 json files;
  4. convert open api 3 json files to py clients.

The main script of generation is the test_main python file.

When convert open api to py clients, I separated the process into 6 steps, which are defined in the swager_client_generator.stages module.

If my build is not suitable for your demand, or amazon api model updates but my build do not follow, you can clone this repo, modify the api.pyt template and build it by yourself, and please push a PR, thanks!

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

sp-api-clients-0.2.0.tar.gz (58.4 kB view details)

Uploaded Source

Built Distribution

sp_api_clients-0.2.0-py3-none-any.whl (68.7 kB view details)

Uploaded Python 3

File details

Details for the file sp-api-clients-0.2.0.tar.gz.

File metadata

  • Download URL: sp-api-clients-0.2.0.tar.gz
  • Upload date:
  • Size: 58.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.1

File hashes

Hashes for sp-api-clients-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1543eb71a5d37c9439c500065ea638e1943293f13cbec62689046a65e026e5f8
MD5 a412d8e3842fb054a079e43f109a14b5
BLAKE2b-256 633519d07457194a4098ed51ed91c333722f10964d7761f3606a899143ae6c81

See more details on using hashes here.

File details

Details for the file sp_api_clients-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: sp_api_clients-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 68.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.1

File hashes

Hashes for sp_api_clients-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 53fb817303d98bfbef564ba56979025d1a67be112dcd0d85541e529d39a80dd5
MD5 13ada163b1ec091f928221a685790d79
BLAKE2b-256 494b0db3f51c0f36b59035a30e5beb7a974d4d015874a2d6a01bdf2c441625a0

See more details on using hashes here.

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