Amazon selling partner api clients.
Project description
amazon-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.
Attention
V1.0.0 changes many api, compared with v0.x.x!
注意!V1.0.0相较于v0.x.x更改了大量的API!
Features
- ready to use;
- provide code to generate clients, in case that amazon update models;
- type hint.
Note
Because that this repo currently do not need community contribution, and is mainly for my personal usage, so I made this repo private. You can download the client from pypi and use it free. But if you want to generate a new client lib to support your business, please contact and pay me and I will provide technical support.
For technical support, please contact panhaoyu.china@outlook.com.
Previously this lib is only open access but not open source, and now it's time to make it public to serve more people.
If there's any bug, please fell free to open an issue or send a pr.
商业合作请联系 panhaoyu.china@outlook.com。
Usage
For saving time, I just paste part of my test code here as a demo.
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 amazon_sp_api_clients
endpoint = "https://sellingpartnerapi-eu.amazon.com"
marketplace_id = "XXXXXXXXXXXXXX"
refresh_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
order_pk = '123-1234567-1234567'
role_arn = "arn:aws:iam::123456789012:role/xxxxxx"
aws_access_key = 'XXXXXXXXXXXXXXXXXXXX'
aws_secret_key = "XXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
client_id = 'amzn1.application-oa2-client.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
client_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
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,
lwa_client_key=client_id,
lwa_client_secret=client_secret,
)
order_client = amazon_sp_api_clients.OrdersV0Client(**client_config, use_cache=True)
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_REGION
- 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:
- download amazon open api repository;
- copy open api 2 json files from the amazon repository to a single directory;
- convert open api 2 json files to open api 3 json files;
- 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!
Acknowledgement
The auth method is partially from python-amazon-sp-api.
Note
If this library helps you, please give me a star, thanks!
如果这个库对您有用,请为我点亮Star,谢谢!
商业合作请联系 panhaoyu.china@outlook.com。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file amazon-sp-api-clients-1.2.1.tar.gz
.
File metadata
- Download URL: amazon-sp-api-clients-1.2.1.tar.gz
- Upload date:
- Size: 78.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5810b70c9849b60c2c0b059c2a9befe02617196af6fd117d5f9175699dea8705 |
|
MD5 | dc84d48b0de7c28897a6583dd0dba090 |
|
BLAKE2b-256 | 37ca97b31b2d9518b25454b3f8f14ff6cf475c23c3a5bc3e89213d69fc2e5bdc |
File details
Details for the file amazon_sp_api_clients-1.2.1-py3-none-any.whl
.
File metadata
- Download URL: amazon_sp_api_clients-1.2.1-py3-none-any.whl
- Upload date:
- Size: 98.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e3716a9b22eae0b4229e941469116561975092d466075be7b38f9195f6f328e |
|
MD5 | 1dbc278ae4088e3e52e92c96fb80a3fa |
|
BLAKE2b-256 | 47947583515ae1ef4894d775bc871490eb843536daac5ff2bd0d721077944e4c |