amazon-sp-api-clients


Nameamazon-sp-api-clients JSON
Version 1.9.2 PyPI version JSON
download
home_page
SummaryAmazon selling partner api clients.
upload_time2023-12-12 11:54:26
maintainer
docs_urlNone
authorHaoyu Pan
requires_python>=3.7,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # amazon-sp-api-clients

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

The package is tested in many situations, with fully type hint supported. Enjoy it! 

![typehint 1](./docs/source/typehint1.png)

![typehint 2](./docs/source/typehint2.png)

![typehint 3](./docs/source/typehint3.png)

## 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;
* orders api, feed api, report api, and all other apis;
* automatically manage tokens.

## Installation

```shell
pip install amazon-sp-api-clients
```

## Note

For technical support, please contact [panhaoyu.china@outlook.com](mailto: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 developers.

If there's any bug, please fell free to open an issue or send a pr.

## 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.

```python
from datetime import datetime
import amazon_sp_api_clients
endpoint = "https://sellingpartnerapi-eu.amazon.com"
marketplace_id = "XXXXXXXXXXXXXX"
refresh_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
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,
)
clients = amazon_sp_api_clients.AmazonSpApiClients(**client_config)
orders = clients.orders_v0.getOrders(
    MarketplaceIds=[marketplace_id],
    CreatedAfter=datetime(2000, 1, 1).isoformat()
).payload.Orders
for order in orders:
    print(order.AmazonOrderId, order.LastUpdateDate)
```

## 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:

1. download amazon open api repository;
1. copy open api 2 json files from the amazon repository to a single directory;
1. convert open api 2 json files to open api 3 json files;
1. 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](https://github.com/saleweaver/python-amazon-sp-api).

# Note

If this library helps you, please give me a star, thanks!

如果这个库对您有用,请为我点亮Star,谢谢!

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "amazon-sp-api-clients",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Haoyu Pan",
    "author_email": "panhaoyu.china@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/8c/10/2c1fee1a5a760080aed7b4ed3b31133b10142d4087078657a415b0021901/amazon_sp_api_clients-1.9.2.tar.gz",
    "platform": null,
    "description": "# amazon-sp-api-clients\n\nThis is a package generated from amazon selling partner open api models.\n\nThe package is tested in many situations, with fully type hint supported. Enjoy it! \n\n![typehint 1](./docs/source/typehint1.png)\n\n![typehint 2](./docs/source/typehint2.png)\n\n![typehint 3](./docs/source/typehint3.png)\n\n## Attention\n\nV1.0.0 changes many api, compared with v0.x.x!\n\n\u6ce8\u610f\uff01V1.0.0\u76f8\u8f83\u4e8ev0.x.x\u66f4\u6539\u4e86\u5927\u91cf\u7684API\uff01\n\n## Features\n\n* ready to use;\n* provide code to generate clients, in case that amazon update models;\n* type hint;\n* orders api, feed api, report api, and all other apis;\n* automatically manage tokens.\n\n## Installation\n\n```shell\npip install amazon-sp-api-clients\n```\n\n## Note\n\nFor technical support, please contact [panhaoyu.china@outlook.com](mailto:panhaoyu.china@outlook.com).\n\nPreviously this lib is only open access but not open source, and now it's time to make it public to serve more developers.\n\nIf there's any bug, please fell free to open an issue or send a pr.\n\n## Usage\n\nFor saving time, I just paste part of my test code here as a demo.\n\nFor better understanding, all the fields are the same length of actual fields, and some readable information are kept.\n\n```python\nfrom datetime import datetime\nimport amazon_sp_api_clients\nendpoint = \"https://sellingpartnerapi-eu.amazon.com\"\nmarketplace_id = \"XXXXXXXXXXXXXX\"\nrefresh_token = \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\nrole_arn = \"arn:aws:iam::123456789012:role/xxxxxx\"\naws_access_key = 'XXXXXXXXXXXXXXXXXXXX'\naws_secret_key = \"XXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\nclient_id = 'amzn1.application-oa2-client.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\nclient_secret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'\nclient_config = dict(\n    role_arn=role_arn,\n    endpoint=endpoint,\n    marketplace_id=marketplace_id,\n    refresh_token=refresh_token,\n    aws_access_key=aws_access_key,\n    aws_secret_key=aws_secret_key,\n    lwa_client_key=client_id,\n    lwa_client_secret=client_secret,\n)\nclients = amazon_sp_api_clients.AmazonSpApiClients(**client_config)\norders = clients.orders_v0.getOrders(\n    MarketplaceIds=[marketplace_id],\n    CreatedAfter=datetime(2000, 1, 1).isoformat()\n).payload.Orders\nfor order in orders:\n    print(order.AmazonOrderId, order.LastUpdateDate)\n```\n\n## Configuration\n\nThe client configuration can be set both at the initiation and as environment variables.\n\n* SP_API_ROLE_ARN\n* SP_API_ENDPOINT\n* SP_API_REGION\n* SP_API_MARKETPLACE_ID\n* SP_API_REFRESH_TOKEN\n* SP_API_AWS_ACCESS_KEY\n* SP_API_AWS_SECRET_KEY\n* SP_API_LWA_CLIENT_KEY\n* SP_API_LWA_CLIENT_SECRET\n\n## Build\n\nThe client is generated in the following steps:\n\n1. download amazon open api repository;\n1. copy open api 2 json files from the amazon repository to a single directory;\n1. convert open api 2 json files to open api 3 json files;\n1. convert open api 3 json files to py clients.\n\nThe main script of generation is the `test_main` python file.\n\nWhen convert open api to py clients, I separated the process into 6 steps, which are defined in\nthe `swager_client_generator.stages` module.\n\nIf my build is not suitable for your demand, or amazon api model updates but my build do not follow, you can clone this\nrepo, modify the `api.pyt` template and build it by yourself, and please push a PR, thanks!\n\n# Acknowledgement\n\nThe auth method is partially from\n[python-amazon-sp-api](https://github.com/saleweaver/python-amazon-sp-api).\n\n# Note\n\nIf this library helps you, please give me a star, thanks!\n\n\u5982\u679c\u8fd9\u4e2a\u5e93\u5bf9\u60a8\u6709\u7528\uff0c\u8bf7\u4e3a\u6211\u70b9\u4eaeStar\uff0c\u8c22\u8c22\uff01\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Amazon selling partner api clients.",
    "version": "1.9.2",
    "project_urls": {
        "repository": "https://github.com/panhaoyu/sp-api-clients"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b9746d02b98f71817e4cfc4f6dab97f5463d026499d8e224c7c875ed162850cb",
                "md5": "79f1eaef9a5804334c0dd3e5d3527dee",
                "sha256": "c40b3eac81a6865de55dbd484d09794fdfef68efc67874c7cbbf79013d4ff072"
            },
            "downloads": -1,
            "filename": "amazon_sp_api_clients-1.9.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "79f1eaef9a5804334c0dd3e5d3527dee",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 204056,
            "upload_time": "2023-12-12T11:54:23",
            "upload_time_iso_8601": "2023-12-12T11:54:23.731996Z",
            "url": "https://files.pythonhosted.org/packages/b9/74/6d02b98f71817e4cfc4f6dab97f5463d026499d8e224c7c875ed162850cb/amazon_sp_api_clients-1.9.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c102c1fee1a5a760080aed7b4ed3b31133b10142d4087078657a415b0021901",
                "md5": "b91fc69be866964fe6339f2752a986b6",
                "sha256": "8c0a41d2a9ca585533b8b7fd5474d303367f9c8ee514819bc3615825930f2289"
            },
            "downloads": -1,
            "filename": "amazon_sp_api_clients-1.9.2.tar.gz",
            "has_sig": false,
            "md5_digest": "b91fc69be866964fe6339f2752a986b6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 156440,
            "upload_time": "2023-12-12T11:54:26",
            "upload_time_iso_8601": "2023-12-12T11:54:26.105183Z",
            "url": "https://files.pythonhosted.org/packages/8c/10/2c1fee1a5a760080aed7b4ed3b31133b10142d4087078657a415b0021901/amazon_sp_api_clients-1.9.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-12 11:54:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "panhaoyu",
    "github_project": "sp-api-clients",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "amazon-sp-api-clients"
}
        
Elapsed time: 0.15523s