├── .coveragerc ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml └── workflows │ ├── dependabot-automerge.yml │ ├── manual.yml │ ├── python-publish.yml │ └── version_increment.yml ├── .gitignore ├── .readthedocs.yaml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── SECURITY.md ├── credentials.yml ├── docs ├── .gitignore ├── .well-known │ ├── apple-developer-merchantid-domain-association │ └── apple-developer-merchantid-domain-association.json ├── Makefile ├── _static │ ├── apple-developer-merchantid-domain-association │ ├── apple-developer-merchantid-domain-association.json │ ├── button.css │ ├── cookie.js │ ├── cookieconsent.min.js │ ├── cookieconsent.min.map │ ├── favicon.ico │ ├── favicon.ico.f │ ├── fireworks.html │ ├── helpful-widget.js │ ├── images │ │ ├── 15df61f856834dd2a935d78ca80930d3.png │ │ ├── 33d0dab07d52479e9e4fcc21ff17e9d5.png │ │ ├── 3e168715082642cd9fee10f38dc6e004.png │ │ ├── 815da4f3df064233ae798d61d683dda1.png │ │ ├── 8627ad626d39430f8e105fe67a021167.png │ │ ├── App_Overview.png │ │ ├── Authorise_Application.png │ │ ├── Create_App.png │ │ ├── LWA_Credentials.png │ │ ├── bfb7a8859c53401db3ccd3a27a48e6ea.png │ │ ├── hellocoding.png │ │ └── tubemagic.png │ ├── logo.svg │ └── redoc │ │ ├── aplusContent_2020-11-01.html │ │ ├── authorization.html │ │ ├── catalogItemsV0.html │ │ ├── catalogItems_2020-12-01.html │ │ ├── definitionsProductTypes_2020-09-01.html │ │ ├── fbaInbound.html │ │ ├── fbaInventory.html │ │ ├── fbaSmallandLight.html │ │ ├── feeds_2020-09-04.html │ │ ├── feeds_2021-06-30.html │ │ ├── financesV0.html │ │ ├── fulfillmentInboundV0.html │ │ ├── fulfillmentOutbound_2020-07-01.html │ │ ├── listingsItems_2020-09-01.html │ │ ├── listingsItems_2021-08-01.html │ │ ├── listingsRestrictions_2021-08-01.html │ │ ├── merchantFulfillmentV0.html │ │ ├── messaging.html │ │ ├── notifications.html │ │ ├── ordersV0.html │ │ ├── productFeesV0.html │ │ ├── productPricingV0.html │ │ ├── reports_2020-09-04.html │ │ ├── reports_2021-06-30.html │ │ ├── sales.html │ │ ├── sellers.html │ │ ├── services.html │ │ ├── shipmentInvoicingV0.html │ │ ├── shipping.html │ │ ├── solicitations.html │ │ ├── tokens_2021-03-01.html │ │ ├── uploads_2020-11-01.html │ │ ├── vendorDirectFulfillmentInventoryV1.html │ │ ├── vendorDirectFulfillmentOrdersV1.html │ │ ├── vendorDirectFulfillmentPaymentsV1.html │ │ ├── vendorDirectFulfillmentShippingV1.html │ │ ├── vendorDirectFulfillmentTransactionsV1.html │ │ ├── vendorInvoices.html │ │ ├── vendorOrders.html │ │ ├── vendorShipments.html │ │ └── vendorTransactionStatus.html ├── _templates │ ├── footer.html │ └── layout.html ├── button.py ├── client_usage.rst ├── conf.py ├── config_file.rst ├── cookieconsent.py ├── credentials.rst ├── endpoints.rst ├── endpoints │ ├── aplus_content.rst │ ├── application_integrations.rst │ ├── application_management.rst │ ├── authorization.rst │ ├── awd.rst │ ├── catalog.rst │ ├── catalog_items.rst │ ├── data_kiosk.rst │ ├── easy_ship.rst │ ├── fba_inbound_eligibility.rst │ ├── fba_small_and_light.rst │ ├── feeds.rst │ ├── finances.rst │ ├── fulfillment_inbound.rst │ ├── fulfillment_outbound.rst │ ├── inventories.rst │ ├── listings_items.rst │ ├── listings_restrictions.rst │ ├── merchant_fulfillment.rst │ ├── messaging.rst │ ├── notifications.rst │ ├── orders.rst │ ├── product_fees.rst │ ├── product_type_definitions.rst │ ├── products.rst │ ├── replenishment.rst │ ├── reports.rst │ ├── sales.rst │ ├── sellers.rst │ ├── services.rst │ ├── shipping.rst │ ├── solicitations.rst │ ├── supply_sources.rst │ ├── tokens.rst │ ├── upload.rst │ ├── vendor_direct_fulfillment_inventory.rst │ ├── vendor_direct_fulfillment_orders.rst │ ├── vendor_direct_fulfillment_payments.rst │ ├── vendor_direct_fulfillment_shipping.rst │ ├── vendor_direct_fulfillment_transactions.rst │ ├── vendor_invoices.rst │ ├── vendor_orders.rst │ ├── vendor_shipments.rst │ └── vendor_transaction_status.rst ├── enums.rst ├── env_variables.rst ├── examples.rst ├── examples │ └── authorisation_example.rst ├── exceptions.rst ├── favicon.ico ├── from_code.rst ├── index.rst ├── installation.rst ├── make.bat ├── pii.rst ├── quickstart.rst ├── requirements.txt ├── responses.rst ├── testing.rst ├── utils.rst ├── utils │ ├── key_maker.rst │ ├── load_all_pages.rst │ └── retry.rst ├── versions.rst └── well-known │ ├── apple-developer-merchantid-domain-association │ └── apple-developer-merchantid-domain-association.json ├── generate_changelog.py ├── make_endpoint ├── __init__.py ├── make_docs.py ├── make_endpoint └── template.py.jinja2 ├── requirements.txt ├── setup.cfg ├── setup.py ├── sp_api ├── __init__.py ├── __version__.py ├── api │ ├── __init__.py │ ├── amazon_warehousing_and_distribu │ │ ├── __init__.py │ │ └── amazon_warehousing_and_distribu.py │ ├── aplus_content │ │ ├── __init__.py │ │ └── aplus_content.py │ ├── application_integrations │ │ ├── __init__.py │ │ └── application_integrations.py │ ├── application_management │ │ ├── __init__.py │ │ └── application_management.py │ ├── authorization │ │ ├── __init__.py │ │ └── authorization.py │ ├── catalog │ │ ├── __init__.py │ │ └── catalog.py │ ├── catalog_items │ │ ├── __init__.py │ │ └── catalog_items.py │ ├── data_kiosk │ │ ├── __init__.py │ │ └── data_kiosk.py │ ├── easy_ship │ │ ├── __init__.py │ │ └── easy_ship.py │ ├── fba_inbound_eligibility │ │ ├── __init__.py │ │ └── fba_inbound_eligibility.py │ ├── fba_small_and_light │ │ ├── __init__.py │ │ └── fba_small_and_light.py │ ├── feeds │ │ ├── __init__.py │ │ ├── docs │ │ │ ├── CancelFeedResponse.md │ │ │ ├── CreateFeedDocumentResponse.md │ │ │ ├── CreateFeedDocumentResult.md │ │ │ ├── CreateFeedDocumentSpecification.md │ │ │ ├── CreateFeedResponse.md │ │ │ ├── CreateFeedResult.md │ │ │ ├── CreateFeedSpecification.md │ │ │ ├── Error.md │ │ │ ├── ErrorList.md │ │ │ ├── Feed.md │ │ │ ├── FeedDocument.md │ │ │ ├── FeedDocumentEncryptionDetails.md │ │ │ ├── FeedList.md │ │ │ ├── FeedOptions.md │ │ │ ├── GetFeedDocumentResponse.md │ │ │ ├── GetFeedResponse.md │ │ │ └── GetFeedsResponse.md │ │ └── feeds.py │ ├── finances │ │ ├── __init__.py │ │ └── finances.py │ ├── fulfillment_inbound │ │ ├── __init__.py │ │ └── fulfillment_inbound.py │ ├── fulfillment_outbound │ │ ├── __init__.py │ │ └── fulfillment_outbound.py │ ├── inventories │ │ ├── __init__.py │ │ ├── docs │ │ │ ├── Error.md │ │ │ ├── ErrorList.md │ │ │ ├── GetInventorySummariesResponse.md │ │ │ ├── GetInventorySummariesResult.md │ │ │ ├── Granularity.md │ │ │ ├── InventoryDetails.md │ │ │ ├── InventorySummaries.md │ │ │ ├── InventorySummary.md │ │ │ ├── Pagination.md │ │ │ ├── ResearchingQuantity.md │ │ │ ├── ResearchingQuantityEntry.md │ │ │ ├── ReservedQuantity.md │ │ │ └── UnfulfillableQuantity.md │ │ └── inventories.py │ ├── listings_items │ │ ├── __init__.py │ │ └── listings_items.py │ ├── listings_restrictions │ │ ├── __init__.py │ │ └── listings_restrictions.py │ ├── merchant_fulfillment │ │ ├── __init__.py │ │ └── merchant_fulfillment.py │ ├── messaging │ │ ├── __init__.py │ │ └── messaging.py │ ├── notifications │ │ ├── __init__.py │ │ └── notifications.py │ ├── orders │ │ ├── __init__.py │ │ └── orders.py │ ├── product_fees │ │ ├── __init__.py │ │ └── product_fees.py │ ├── product_type_definitions │ │ ├── __init__.py │ │ └── product_type_definitions.py │ ├── products │ │ ├── __init__.py │ │ ├── products.py │ │ └── products_definitions.py │ ├── replenishment │ │ ├── __init__.py │ │ └── replenishment.py │ ├── reports │ │ ├── __init__.py │ │ ├── docs │ │ │ ├── CancelReportResponse.md │ │ │ ├── CancelReportScheduleResponse.md │ │ │ ├── CreateReportResponse.md │ │ │ ├── CreateReportResult.md │ │ │ ├── CreateReportScheduleResponse.md │ │ │ ├── CreateReportScheduleResult.md │ │ │ ├── CreateReportScheduleSpecification.md │ │ │ ├── CreateReportSpecification.md │ │ │ ├── Error.md │ │ │ ├── ErrorList.md │ │ │ ├── GetReportDocumentResponse.md │ │ │ ├── GetReportResponse.md │ │ │ ├── GetReportScheduleResponse.md │ │ │ ├── GetReportSchedulesResponse.md │ │ │ ├── GetReportsResponse.md │ │ │ ├── Report.md │ │ │ ├── ReportDocument.md │ │ │ ├── ReportDocumentEncryptionDetails.md │ │ │ ├── ReportList.md │ │ │ ├── ReportOptions.md │ │ │ ├── ReportSchedule.md │ │ │ └── ReportScheduleList.md │ │ └── reports.py │ ├── sales │ │ ├── __init__.py │ │ ├── docs.md │ │ └── sales.py │ ├── sellers │ │ ├── __init__.py │ │ └── sellers.py │ ├── services │ │ ├── __init__.py │ │ └── services.py │ ├── shipping │ │ ├── __init__.py │ │ ├── shipping.py │ │ └── shippingV2.py │ ├── solicitations │ │ ├── __init__.py │ │ └── solicitations.py │ ├── supply_sources │ │ ├── __init__.py │ │ └── supply_sources.py │ ├── tokens │ │ ├── __init__.py │ │ └── tokens.py │ ├── upload │ │ ├── __init__.py │ │ ├── docs │ │ │ ├── CreateUploadDestinationResponse.md │ │ │ ├── Error.md │ │ │ ├── ErrorList.md │ │ │ └── UploadDestination.md │ │ └── upload.py │ ├── vendor_direct_fulfillment_inventory │ │ ├── __init__.py │ │ └── vendor_direct_fulfillment_inventory.py │ ├── vendor_direct_fulfillment_orders │ │ ├── __init__.py │ │ └── vendor_direct_fulfillment_orders.py │ ├── vendor_direct_fulfillment_payments │ │ ├── __init__.py │ │ └── vendor_direct_fulfillment_payments.py │ ├── vendor_direct_fulfillment_shipping │ │ ├── __init__.py │ │ └── vendor_direct_fulfillment_shipping.py │ ├── vendor_direct_fulfillment_transactions │ │ ├── __init__.py │ │ └── vendor_direct_fulfillment_transactions.py │ ├── vendor_invoices │ │ ├── __init__.py │ │ └── vendor_invoices.py │ ├── vendor_orders │ │ ├── __init__.py │ │ └── vendor_orders.py │ ├── vendor_shipments │ │ ├── __init__.py │ │ └── vendor_shipments.py │ └── vendor_transaction_status │ │ ├── __init__.py │ │ └── vendor_transaction_status.py ├── auth │ ├── __init__.py │ ├── access_token_client.py │ ├── access_token_response.py │ ├── credentials.py │ └── exceptions.py ├── base │ ├── ApiResponse.py │ ├── InventoryEnums.py │ ├── __init__.py │ ├── base_client.py │ ├── client.py │ ├── credential_provider.py │ ├── exceptions.py │ ├── feedTypes.py │ ├── fulfillment_channel.py │ ├── helpers.py │ ├── identifiersType.py │ ├── included_data.py │ ├── inegibility_reasons.py │ ├── marketplaces.py │ ├── notifications.py │ ├── processing_status.py │ ├── reportTypes.py │ ├── report_status.py │ ├── sales_enum.py │ └── schedules.py └── util │ ├── __init__.py │ ├── key_maker.py │ ├── load_all_pages.py │ ├── load_date_bound.py │ └── retry.py ├── tests ├── __init__.py ├── api │ ├── __init__.py │ ├── authorization │ │ ├── __init__.py │ │ └── test_authorization.py │ ├── catalog │ │ ├── __init__.py │ │ └── test_catalog.py │ ├── catalog_items │ │ ├── __init__.py │ │ └── test_catalog_items.py │ ├── feeds │ │ ├── __init__.py │ │ └── test_feeds.py │ ├── finances │ │ ├── __init__.py │ │ └── test_finances.py │ ├── fulfillment_inbound │ │ ├── __init__.py │ │ └── test_fulfillment_inbound.py │ ├── inbound_eligibility │ │ ├── __init__.py │ │ └── test_inbound_eligibility.py │ ├── inventories │ │ ├── __init__.py │ │ └── test_inventories.py │ ├── listings_items │ │ ├── __init__.py │ │ └── test_listings_items.py │ ├── listings_restrictions │ │ ├── __init__.py │ │ └── test_listings_restrictions.py │ ├── merchant_fullfillment │ │ ├── __init__.py │ │ └── test_merchant_fullfillment.py │ ├── messaging │ │ ├── __init__.py │ │ └── test_messaging.py │ ├── notifications │ │ ├── __init__.py │ │ └── test_notifications.py │ ├── orders │ │ ├── __init__.py │ │ └── test_orders.py │ ├── product_fees │ │ ├── __init__.py │ │ └── product_fees.py │ ├── product_type_definitions │ │ ├── __init__.py │ │ └── test_product_type_definitions.py │ ├── products │ │ ├── __init__.py │ │ └── test_products.py │ ├── reports │ │ ├── __init__.py │ │ └── test_reports.py │ ├── sales │ │ ├── __init__.py │ │ └── test_sales.py │ ├── sellers │ │ ├── __init__.py │ │ └── test_sellers.py │ ├── shipping │ │ └── test_shipping_v2.py │ ├── small_and_light │ │ ├── __init__.py │ │ └── test_small_and_light.py │ ├── tokens │ │ ├── __init__.py │ │ └── test_tokens.py │ └── upload │ │ ├── __init__.py │ │ └── test_upload.py └── client │ ├── __init__.py │ ├── test_auth.py │ ├── test_base.py │ ├── test_credential_provider.py │ └── test_helpers.py └── votes.png /.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | omit = 3 | */venv/* 4 | 5 | [report] 6 | # Regexes for lines to exclude from consideration 7 | exclude_lines = 8 | pragma: no cover 9 | def __repr__ 10 | if self.debug: 11 | raise AssertionError 12 | raise NotImplementedError 13 | (.*)except Exception as e:(.*) 14 | if 0: 15 | if __name__ == .__main__.: 16 | (.*)return self\._request(.*) 17 | raise KeyError(\"AWS Access Key ID and Secret Access Key are required\") 18 | (.*)super\(SellingApi(.*) 19 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: saleweaver 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: 'bug' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | 15 | Steps to reproduce the behavior: 16 | 17 | **Expected behavior** 18 | 19 | A clear and concise description of what you expected to happen. 20 | 21 | **Desktop (please complete the following information):** 22 | 23 | - OS: [e.g. Linux/Mac/Windows] 24 | 25 | **Additional context** 26 | 27 | Add any other context about the problem here. 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Which API - Endpoint is your request about.** 11 | 12 | A clear and concise description of what you want to happen. 13 | 14 | 15 | **Additional context** 16 | 17 | Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "pip" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | target-branch: "master" 11 | schedule: 12 | interval: "daily" 13 | assignees: 14 | - "saleweaver" 15 | commit-message: 16 | prefix: "DEP" 17 | include: "scope" 18 | -------------------------------------------------------------------------------- /.github/workflows/dependabot-automerge.yml: -------------------------------------------------------------------------------- 1 | name: auto-merge 2 | 3 | on: 4 | pull_request: 5 | 6 | jobs: 7 | auto-merge: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: ahmadnassri/action-dependabot-auto-merge@v2 12 | with: 13 | target: minor 14 | github-token: ${{ secrets.mytoken }} 15 | -------------------------------------------------------------------------------- /.github/workflows/manual.yml: -------------------------------------------------------------------------------- 1 | name: 'Close stale issues and PRs' 2 | on: 3 | schedule: 4 | - cron: '30 1 * * *' 5 | 6 | jobs: 7 | stale: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/stale@v4 11 | -------------------------------------------------------------------------------- /.github/workflows/python-publish.yml: -------------------------------------------------------------------------------- 1 | # This workflows will upload a Python Package using Twine when a release is created 2 | # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries 3 | 4 | name: Upload Python Package 5 | 6 | on: 7 | release: 8 | types: [created] 9 | repository_dispatch: 10 | types: [release_created] 11 | jobs: 12 | deploy: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2 18 | - name: Set up Python 19 | uses: actions/setup-python@v2 20 | with: 21 | python-version: '3.9' 22 | - name: Install dependencies 23 | run: | 24 | python -m pip install --upgrade pip 25 | pip install --upgrade setuptools wheel twine 26 | - name: Build and publish 27 | env: 28 | TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} 29 | TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} 30 | run: | 31 | python setup.py sdist bdist_wheel 32 | twine upload dist/* 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by .ignore support plugin (hsz.mobi) 2 | ### Python template 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | *$py.class 7 | to_doc.py 8 | # C extensions 9 | *.so 10 | .credentials.yml 11 | clear_build.sh 12 | # Distribution / packaging 13 | .Python 14 | build/ 15 | develop-eggs/ 16 | dist/ 17 | downloads/ 18 | eggs/ 19 | .eggs/ 20 | lib/ 21 | lib64/ 22 | parts/ 23 | sdist/ 24 | var/ 25 | wheels/ 26 | share/python-wheels/ 27 | *.egg-info/ 28 | .installed.cfg 29 | *.egg 30 | MANIFEST 31 | .idea/ 32 | # PyInstaller 33 | # Usually these files are written by a python script from a template 34 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 35 | *.manifest 36 | *.spec 37 | 38 | # Installer logs 39 | pip-log.txt 40 | pip-delete-this-directory.txt 41 | 42 | # Unit test / coverage reports 43 | htmlcov/ 44 | .tox/ 45 | .nox/ 46 | .coverage 47 | .coverage.* 48 | .cache 49 | nosetests.xml 50 | coverage.xml 51 | *.cover 52 | *.py,cover 53 | .hypothesis/ 54 | .pytest_cache/ 55 | cover/ 56 | 57 | # Translations 58 | *.mo 59 | *.pot 60 | 61 | # Django stuff: 62 | *.log 63 | local_settings.py 64 | db.sqlite3 65 | db.sqlite3-journal 66 | 67 | # Flask stuff: 68 | instance/ 69 | .webassets-cache 70 | 71 | # Scrapy stuff: 72 | .scrapy 73 | 74 | # Sphinx documentation 75 | docs/_build/ 76 | 77 | # PyBuilder 78 | .pybuilder/ 79 | target/ 80 | 81 | # Jupyter Notebook 82 | .ipynb_checkpoints 83 | 84 | # IPython 85 | profile_default/ 86 | ipython_config.py 87 | 88 | # pyenv 89 | # For a library or package, you might want to ignore these files since the code is 90 | # intended to run in multiple environments; otherwise, check them in: 91 | # .python-version 92 | 93 | # pipenv 94 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 95 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 96 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 97 | # install all needed dependencies. 98 | #Pipfile.lock 99 | 100 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 101 | __pypackages__/ 102 | 103 | # Celery stuff 104 | celerybeat-schedule 105 | celerybeat.pid 106 | 107 | # SageMath parsed files 108 | *.sage.py 109 | 110 | # Environments 111 | .env 112 | .venv 113 | env/ 114 | venv/ 115 | ENV/ 116 | env.bak/ 117 | venv.bak/ 118 | 119 | # Spyder project settings 120 | .spyderproject 121 | .spyproject 122 | 123 | # Rope project settings 124 | .ropeproject 125 | 126 | # mkdocs documentation 127 | /site 128 | 129 | # mypy 130 | .mypy_cache/ 131 | .dmypy.json 132 | dmypy.json 133 | 134 | # Pyre type checker 135 | .pyre/ 136 | 137 | # pytype static type analyzer 138 | .pytype/ 139 | 140 | # Cython debug symbols 141 | cython_debug/ 142 | 143 | env.env 144 | -------------------------------------------------------------------------------- /.readthedocs.yaml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file for Sphinx projects 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | # Required 5 | version: 2 6 | 7 | # Set the OS, Python version and other tools you might need 8 | build: 9 | os: ubuntu-22.04 10 | tools: 11 | python: "3.11" 12 | 13 | # Build documentation in the "docs/" directory with Sphinx 14 | sphinx: 15 | configuration: docs/conf.py 16 | 17 | # Optional but recommended, declare the Python requirements required 18 | # to build your documentation 19 | # See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html 20 | python: 21 | install: 22 | - requirements: docs/requirements.txt 23 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at primke.michael@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Michael Primke 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | We actively maintain the following versions of the **python-amazon-sp-api** library. Security updates will be provided for these versions: 6 | 7 | | Version | Supported | 8 | | --------------- | ------------------ | 9 | | `1.x.x` | :white_check_mark: | 10 | | `0.x.x` | :x: | 11 | 12 | ## Reporting a Vulnerability 13 | 14 | If you discover a security vulnerability in this project, we appreciate your responsible disclosure. Please follow the steps below to report it: 15 | 16 | 1. **Slack** 17 | Send a detailed report to **Michael** or **saleweaver** in the slack channel. An invite to the channel is available in the readme. Please include the following in your email: 18 | - A description of the vulnerability. 19 | - Steps to reproduce the issue. 20 | - Any potential impact it may have. 21 | - Your recommendations for fixing the vulnerability (if applicable). 22 | 23 | 2. **Do Not Publicly Disclose** 24 | Please do not publicly disclose any vulnerabilities until we have had an opportunity to investigate and issue a fix. 25 | 26 | 3. **Acknowledgment** 27 | We will acknowledge receipt of your report within **48 hours** and provide an estimated timeline for resolution. Once the vulnerability has been resolved, we will notify you before publishing any fixes. 28 | 29 | ## Vulnerability Handling Process 30 | 31 | Upon receiving a security vulnerability report, we will: 32 | 33 | 1. Investigate the report and verify the vulnerability. 34 | 2. Develop a fix or workaround. 35 | 3. Release a patch in a timely manner. 36 | 4. Credit the reporter (if applicable and desired) in the release notes. 37 | 38 | ## Security Best Practices 39 | 40 | We encourage users of **python-amazon-sp-api** to follow these best practices to protect their systems: 41 | 42 | - Keep your environment and dependencies up to date. 43 | - Use secure authentication methods when accessing the Amazon SP-API. 44 | - Avoid hardcoding credentials in your source code or version control. 45 | - Regularly review and audit your usage of this library for security concerns. 46 | 47 | ## Thank You 48 | 49 | We value the efforts of the security community in helping keep this project safe and secure for everyone. 50 | -------------------------------------------------------------------------------- /credentials.yml: -------------------------------------------------------------------------------- 1 | version: '1.0' 2 | 3 | default: 4 | refresh_token: '' 5 | lwa_app_id: '' 6 | lwa_client_secret: '' 7 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/_static/button.css: -------------------------------------------------------------------------------- 1 | .redoc-btn { 2 | padding: 5px 15px; 3 | background: rgba(3, 73, 126, 1); 4 | color: white; 5 | border-radius: 7px; 6 | margin-bottom: 15px; 7 | box-shadow: 2px 2px rgb(255 200 130); 8 | border: none; 9 | outline: none; 10 | } 11 | 12 | .donate-btn-form { 13 | padding: 10px 15px; 14 | background: linear-gradient( 15 | 45deg, rgba(3, 73, 126, .65), rgba(3, 73, 126, 1), rgba(3, 73, 126, .4)); 16 | color: white; 17 | border: none; 18 | outline: none; 19 | width: 100%; 20 | margin-top: 15px; 21 | display: flex; 22 | justify-content: center; 23 | align-items: center; 24 | font-weight: 300; 25 | } 26 | -------------------------------------------------------------------------------- /docs/_static/cookie.js: -------------------------------------------------------------------------------- 1 | window.CookieConsent.init({ 2 | // More link URL on bar 3 | modalMainTextMoreLink: null, 4 | // How lond to wait until bar comes up 5 | barTimeout: 1000, 6 | // Look and feel 7 | theme: { 8 | barColor: '#2980b9', 9 | barTextColor: '#FFF', 10 | barMainButtonColor: '#FFF', 11 | barMainButtonTextColor: '#2980b9', 12 | modalMainButtonColor: '#4285F4', 13 | modalMainButtonTextColor: '#FFF', 14 | }, 15 | language: { 16 | // Current language 17 | current: 'en', 18 | locale: { 19 | en: { 20 | barMainText: 'This website uses cookies to ensure you get the best experience on our website.', 21 | barLinkSetting: 'Cookie Settings', 22 | barBtnAcceptAll: 'Accept all cookies', 23 | modalMainTitle: 'Cookie settings', 24 | modalMainText: 'Cookies are small piece of data sent from a website and stored on the user\'s computer by the user\'s web browser while the user is browsing. Your browser stores each message in a small file, called cookie. When you request another page from the server, your browser sends the cookie back to the server. Cookies were designed to be a reliable mechanism for websites to remember information or to record the user\'s browsing activity.', 25 | modalBtnSave: 'Save current settings', 26 | modalBtnAcceptAll: 'Accept all cookies and close', 27 | modalAffectedSolutions: 'Affected solutions:', 28 | learnMore: 'Learn More', 29 | on: 'On', 30 | off: 'Off', 31 | } 32 | } 33 | }, 34 | // List all the categories you want to display 35 | categories: { 36 | // Unique name 37 | // This probably will be the default category 38 | necessary: { 39 | // The cookies here are necessary and category cant be turned off. 40 | // Wanted config value will be ignored. 41 | needed: true, 42 | // The cookies in this category will be let trough. 43 | // This probably should be false if not necessary category 44 | wanted: true, 45 | // If the checkbox is on or off at first run. 46 | checked: true, 47 | // Language settings for categories 48 | language: { 49 | locale: { 50 | en: { 51 | name: 'Strictly Necessary Cookies', 52 | description: 'Cookies to help optimize documentation.', 53 | }, 54 | } 55 | } 56 | } 57 | }, 58 | // List actual services here 59 | services: { 60 | // Unique name 61 | analytics: { 62 | // Existing category Unique name 63 | // This example shows how to block Google Analytics 64 | category: 'necessary', 65 | // Type of blocking to apply here. 66 | // This depends on the type of script we are trying to block 67 | // Can be: dynamic-script, script-tag, wrapped, localcookie 68 | type: 'dynamic-script', 69 | // Only needed if "type: dynamic-script" 70 | // The filter will look for this keyword in inserted scipt tags 71 | // and block if match found 72 | search: 'analytics', 73 | // List of known cookie names or Regular expressions matching 74 | // cookie names placed by this service. 75 | // These willbe removed from current domain and .domain. 76 | cookies: [ 77 | { 78 | // Known cookie name. 79 | name: '_gid', 80 | // Expected cookie domain. 81 | domain: `.${window.location.hostname}` 82 | }, 83 | { 84 | // Regex matching cookie name. 85 | name: /^_ga/, 86 | domain: `.${window.location.hostname}` 87 | } 88 | ], 89 | language: { 90 | locale: { 91 | en: { 92 | name: 'Google Analytics' 93 | }, 94 | hu: { 95 | name: 'Google Analytics' 96 | } 97 | } 98 | } 99 | } 100 | } 101 | }); 102 | -------------------------------------------------------------------------------- /docs/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/favicon.ico -------------------------------------------------------------------------------- /docs/_static/favicon.ico.f: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/favicon.ico.f -------------------------------------------------------------------------------- /docs/_static/helpful-widget.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/helpful-widget.js -------------------------------------------------------------------------------- /docs/_static/images/15df61f856834dd2a935d78ca80930d3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/15df61f856834dd2a935d78ca80930d3.png -------------------------------------------------------------------------------- /docs/_static/images/33d0dab07d52479e9e4fcc21ff17e9d5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/33d0dab07d52479e9e4fcc21ff17e9d5.png -------------------------------------------------------------------------------- /docs/_static/images/3e168715082642cd9fee10f38dc6e004.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/3e168715082642cd9fee10f38dc6e004.png -------------------------------------------------------------------------------- /docs/_static/images/815da4f3df064233ae798d61d683dda1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/815da4f3df064233ae798d61d683dda1.png -------------------------------------------------------------------------------- /docs/_static/images/8627ad626d39430f8e105fe67a021167.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/8627ad626d39430f8e105fe67a021167.png -------------------------------------------------------------------------------- /docs/_static/images/App_Overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/App_Overview.png -------------------------------------------------------------------------------- /docs/_static/images/Authorise_Application.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/Authorise_Application.png -------------------------------------------------------------------------------- /docs/_static/images/Create_App.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/Create_App.png -------------------------------------------------------------------------------- /docs/_static/images/LWA_Credentials.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/LWA_Credentials.png -------------------------------------------------------------------------------- /docs/_static/images/bfb7a8859c53401db3ccd3a27a48e6ea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/bfb7a8859c53401db3ccd3a27a48e6ea.png -------------------------------------------------------------------------------- /docs/_static/images/hellocoding.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/hellocoding.png -------------------------------------------------------------------------------- /docs/_static/images/tubemagic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/_static/images/tubemagic.png -------------------------------------------------------------------------------- /docs/_static/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/button.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from docutils import nodes 3 | import jinja2 4 | from docutils.parsers.rst.directives import unchanged 5 | from docutils.parsers.rst import Directive 6 | 7 | BUTTON_TEMPLATE = jinja2.Template(u""" 8 | 11 | """) 12 | 13 | # placeholder node for document graph 14 | class button_node(nodes.General, nodes.Element): 15 | pass 16 | 17 | class ButtonDirective(Directive): 18 | required_arguments = 0 19 | 20 | option_spec = { 21 | 'text': unchanged, 22 | 'link': unchanged, 23 | } 24 | 25 | # this will execute when your directive is encountered 26 | # it will insert a button_node into the document that will 27 | # get visisted during the build phase 28 | def run(self): 29 | env = self.state.document.settings.env 30 | app = env.app 31 | 32 | 33 | 34 | node = button_node() 35 | node['text'] = self.options['text'] 36 | node['link'] = self.options['link'] 37 | return [node] 38 | 39 | # build phase visitor emits HTML to append to output 40 | def html_visit_button_node(self, node): 41 | html = BUTTON_TEMPLATE.render(text=node['text'], link=node['link'], id='redoc-btn') 42 | self.body.append(html) 43 | raise nodes.SkipNode 44 | 45 | # if you want to be pedantic, define text, latex, manpage visitors too.. 46 | 47 | def setup(app): 48 | app.add_node(button_node, 49 | html=(html_visit_button_node, None)) 50 | app.add_css_file('button.css') 51 | app.add_directive('button', ButtonDirective) 52 | -------------------------------------------------------------------------------- /docs/client_usage.rst: -------------------------------------------------------------------------------- 1 | Client Usage 2 | ============ 3 | 4 | 5 | 6 | 7 | 8 | 9 | All endpoint's clients have the following signature and default values: 10 | 11 | 12 | 13 | .. code-block:: python 14 | 15 | SomeClient( 16 | marketplace=Marketplaces.US, *, 17 | refresh_token=None, 18 | account='default', 19 | credentials=None, 20 | restricted_data_token=None 21 | ) 22 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | import inspect 7 | # -- Path setup -------------------------------------------------------------- 8 | 9 | # If extensions (or modules to document with autodoc) are in another directory, 10 | # add these directories to sys.path here. If the directory is relative to the 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. 12 | # 13 | # import os 14 | # import sys 15 | import os 16 | import sys 17 | 18 | sys.path.insert(0, os.path.abspath('.')) 19 | 20 | currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) 21 | parentdir = os.path.dirname(currentdir) 22 | sys.path.insert(0, parentdir) 23 | import sp_api 24 | 25 | # -- Project information ----------------------------------------------------- 26 | 27 | project = 'PYTHON-AMAZON-SP-API' 28 | copyright = '2021, Michael Primke' 29 | author = 'Michael Primke' 30 | 31 | # -- General configuration --------------------------------------------------- 32 | 33 | # Add any Sphinx extension module names here, as strings. They can be 34 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 35 | # ones. 36 | extensions = [ 37 | "sphinx_rtd_theme", 'button', 'cookieconsent', 38 | 'sphinx.ext.autodoc', 'sphinx.ext.coverage', 'sphinx.ext.napoleon', 39 | 'enum_tools.autoenum', 40 | 41 | ] 42 | 43 | # Add any paths that contain templates here, relative to this directory. 44 | templates_path = ['_templates'] 45 | 46 | # List of patterns, relative to source directory, that match files and 47 | # directories to ignore when looking for source files. 48 | # This pattern also affects html_static_path and html_extra_path. 49 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 50 | autodoc_default_options = {"members": True, "undoc-members": True, 'member-order': 'bysource'} 51 | html_theme_options = { 52 | "collapse_navigation": False 53 | } 54 | # -- Options for HTML output ------------------------------------------------- 55 | 56 | # The theme to use for HTML and HTML Help pages. See the documentation for 57 | # a list of builtin themes. 58 | # 59 | html_theme = 'sphinx_rtd_theme' 60 | 61 | # Add any paths that contain custom static files (such as style sheets) here, 62 | # relative to this directory. They are copied after the builtin static files, 63 | # so a file named "default.css" will overwrite the builtin "default.css". 64 | html_static_path = ['_static'] 65 | 66 | 67 | napoleon_google_docstring = True 68 | napoleon_numpy_docstring = False 69 | napoleon_include_init_with_doc = False 70 | napoleon_include_private_with_doc = True 71 | napoleon_include_special_with_doc = True 72 | napoleon_use_admonition_for_examples = True 73 | napoleon_use_admonition_for_notes = True 74 | napoleon_use_admonition_for_references = False 75 | napoleon_use_ivar = False 76 | napoleon_use_param = True 77 | napoleon_use_rtype = True 78 | napoleon_preprocess_types = False 79 | napoleon_type_aliases = None 80 | napoleon_attr_annotations = True 81 | -------------------------------------------------------------------------------- /docs/config_file.rst: -------------------------------------------------------------------------------- 1 | Config File 2 | =========== 3 | 4 | 5 | 6 | An example config file is provided in this repository, it supports multiple accounts. 7 | The programm looks for a file called `credentials.yml`_ 8 | 9 | The config is parsed by `confused`_, see their docs for more in depth information. 10 | Search paths are: 11 | 12 | .. code-block:: bash 13 | 14 | macOS: ~/.config/python-sp-api 15 | Other Unix: ~/.config/python-sp-api 16 | Windows: %APPDATA%\python-sp-api where the APPDATA environment variable falls back to %HOME%\AppData\Roaming if undefined 17 | 18 | If you're only using one account, place it under default. You can pass the account's name to the client to use any other account used in the `credentials.yml`_ file. 19 | 20 | .. note:: 21 | Required fields are: 22 | 23 | - lwa_app_id 24 | - lwa_client_secret 25 | 26 | If you don't set the refresh_token, you have to pass it to the client. 27 | 28 | .. code-block:: python 29 | 30 | Orders(refresh_token='...') 31 | 32 | .. code-block:: yaml 33 | 34 | version: '1.0' 35 | 36 | default: 37 | refresh_token: '' 38 | lwa_app_id: '' 39 | lwa_client_secret: '' 40 | 41 | another_account: 42 | refresh_token: '' 43 | lwa_app_id: '' 44 | lwa_client_secret: '' 45 | 46 | 47 | 48 | ************************** 49 | Usage with default account 50 | ************************** 51 | 52 | .. code-block:: python 53 | 54 | Orders().get_orders(CreatedAfter=(datetime.utcnow() - timedelta(days=7)).isoformat()) 55 | 56 | 57 | ************************** 58 | Usage with another_account 59 | ************************** 60 | 61 | You can use every account's name from the config file for account 62 | 63 | .. code-block:: python 64 | 65 | Orders(account=another_account).get_orders(CreatedAfter=(datetime.utcnow() - timedelta(days=7)).isoformat()) 66 | 67 | .. note:: 68 | 69 | The refresh token can be passed directly to the client, too. You don't need to pass the whole credentials if all that changes is the refresh token. 70 | 71 | .. code-block:: python 72 | 73 | Orders(account='another_account', refresh_token='').get_orders(CreatedAfter=(datetime.utcnow() - timedelta(days=7)).isoformat()) 74 | 75 | 76 | ********** 77 | References 78 | ********** 79 | 80 | .. target-notes:: 81 | 82 | .. _`credentials.yml`: https://github.com/saleweaver/python-amazon-sp-api/blob/master/credentials.yml 83 | .. _`confused`: https://confuse.readthedocs.io/en/latest/usage.html#search-paths 84 | 85 | 86 | -------------------------------------------------------------------------------- /docs/cookieconsent.py: -------------------------------------------------------------------------------- 1 | def setup(app): 2 | app.add_js_file('cookieconsent.min.js') 3 | app.add_js_file('cookie.js') 4 | -------------------------------------------------------------------------------- /docs/credentials.rst: -------------------------------------------------------------------------------- 1 | Credentials 2 | =========== 3 | 4 | Please refer to `Amazon's documentation`_ on how to obtain the needed credentials. 5 | 6 | .. _Amazon's documentation: https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md#creating-and-configuring-iam-policies-and-entities 7 | 8 | You can pass your credentials multiple ways, use one of them. 9 | The order of searching for credentials is: 10 | 11 | 1. Parameters passed from code 12 | 2. Environment variables 13 | 3. Config File 14 | 15 | 16 | 17 | .. toctree:: 18 | :maxdepth: 1 19 | 20 | env_variables 21 | config_file 22 | from_code 23 | 24 | -------------------------------------------------------------------------------- /docs/endpoints.rst: -------------------------------------------------------------------------------- 1 | Endpoints 2 | ========= 3 | 4 | You can use the playground to test endpoints: 5 | 6 | 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | endpoints/aplus_content 12 | endpoints/authorization 13 | endpoints/application_integrations 14 | endpoints/application_management 15 | endpoints/awd 16 | endpoints/catalog 17 | endpoints/catalog_items 18 | endpoints/data_kiosk 19 | endpoints/easy_ship 20 | endpoints/fba_inbound_eligibility 21 | endpoints/fba_small_and_light 22 | endpoints/feeds 23 | endpoints/finances 24 | endpoints/fulfillment_inbound 25 | endpoints/fulfillment_outbound 26 | endpoints/inventories 27 | endpoints/listings_items 28 | endpoints/listings_restrictions 29 | endpoints/merchant_fulfillment 30 | endpoints/messaging 31 | endpoints/notifications 32 | endpoints/orders 33 | endpoints/product_fees 34 | endpoints/product_type_definitions 35 | endpoints/products 36 | endpoints/replenishment 37 | endpoints/reports 38 | endpoints/sales 39 | endpoints/sellers 40 | endpoints/services 41 | endpoints/shipping 42 | endpoints/solicitations 43 | endpoints/supply_sources 44 | endpoints/tokens 45 | endpoints/upload 46 | endpoints/vendor_direct_fulfillment_inventory 47 | endpoints/vendor_direct_fulfillment_orders 48 | endpoints/vendor_direct_fulfillment_payments 49 | endpoints/vendor_direct_fulfillment_shipping 50 | endpoints/vendor_direct_fulfillment_transactions 51 | endpoints/vendor_invoices 52 | endpoints/vendor_orders 53 | endpoints/vendor_shipments 54 | endpoints/vendor_transaction_status 55 | 56 | 57 | -------------------------------------------------------------------------------- /docs/endpoints/aplus_content.rst: -------------------------------------------------------------------------------- 1 | AplusContent 2 | ============ 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.AplusContent 7 | -------------------------------------------------------------------------------- /docs/endpoints/application_integrations.rst: -------------------------------------------------------------------------------- 1 | ApplicationIntegrations 2 | ======================= 3 | 4 | 5 | .. autoclass:: sp_api.api.ApplicationIntegrations -------------------------------------------------------------------------------- /docs/endpoints/application_management.rst: -------------------------------------------------------------------------------- 1 | ApplicationManagement 2 | ===================== 3 | 4 | 5 | .. autoclass:: sp_api.api.ApplicationManagement -------------------------------------------------------------------------------- /docs/endpoints/authorization.rst: -------------------------------------------------------------------------------- 1 | Authorization 2 | ============= 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.Authorization 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/endpoints/awd.rst: -------------------------------------------------------------------------------- 1 | AmazonWarehousingAndDistribution 2 | ================================ 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.AmazonWarehousingAndDistribution 7 | :members: 8 | :inherited-members: 9 | -------------------------------------------------------------------------------- /docs/endpoints/catalog.rst: -------------------------------------------------------------------------------- 1 | Catalog 2 | ======= 3 | 4 | 5 | 6 | 7 | .. autoclass:: sp_api.api.Catalog 8 | -------------------------------------------------------------------------------- /docs/endpoints/catalog_items.rst: -------------------------------------------------------------------------------- 1 | CatalogItems 2 | ============ 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.CatalogItems 7 | -------------------------------------------------------------------------------- /docs/endpoints/data_kiosk.rst: -------------------------------------------------------------------------------- 1 | Data Kiosk 2 | ============= 3 | 4 | 5 | .. autoclass:: sp_api.api.DataKiosk 6 | -------------------------------------------------------------------------------- /docs/endpoints/easy_ship.rst: -------------------------------------------------------------------------------- 1 | EasyShip 2 | ======== 3 | 4 | 5 | .. autoclass:: sp_api.api.EasyShip -------------------------------------------------------------------------------- /docs/endpoints/fba_inbound_eligibility.rst: -------------------------------------------------------------------------------- 1 | FbaInboundEligibility 2 | ===================== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.FbaInboundEligibility 7 | -------------------------------------------------------------------------------- /docs/endpoints/fba_small_and_light.rst: -------------------------------------------------------------------------------- 1 | FbaSmallAndLight 2 | ================ 3 | 4 | 5 | 6 | 7 | .. autoclass:: sp_api.api.FbaSmallAndLight 8 | -------------------------------------------------------------------------------- /docs/endpoints/feeds.rst: -------------------------------------------------------------------------------- 1 | Feeds 2 | ===== 3 | 4 | 5 | 6 | 7 | 8 | .. autoclass:: sp_api.api.Feeds 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/endpoints/finances.rst: -------------------------------------------------------------------------------- 1 | Finances 2 | ======== 3 | 4 | 5 | 6 | 7 | .. autoclass:: sp_api.api.Finances 8 | -------------------------------------------------------------------------------- /docs/endpoints/fulfillment_inbound.rst: -------------------------------------------------------------------------------- 1 | FulfillmentInbound 2 | ================== 3 | 4 | 5 | 6 | .. info:: 7 | 8 | To use the `load all pages decorator`_ for this endpoints, pass `extras` to it 9 | 10 | .. _`load all pages decorator`: https://sp-api-docs.saleweaver.com/utils/load_all_pages/ 11 | 12 | 13 | .. code-block:: python 14 | 15 | @load_all_pages(extras=dict(QueryType='NEXT_TOKEN')) 16 | 17 | 18 | 19 | 20 | .. autoclass:: sp_api.api.FulfillmentInbound 21 | -------------------------------------------------------------------------------- /docs/endpoints/fulfillment_outbound.rst: -------------------------------------------------------------------------------- 1 | FulfillmentOutbound 2 | =================== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.FulfillmentOutbound 7 | -------------------------------------------------------------------------------- /docs/endpoints/inventories.rst: -------------------------------------------------------------------------------- 1 | Inventories 2 | =========== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.Inventories 7 | -------------------------------------------------------------------------------- /docs/endpoints/listings_items.rst: -------------------------------------------------------------------------------- 1 | ListingsItems 2 | ============= 3 | 4 | 5 | .. autoclass:: sp_api.api.ListingsItems 6 | -------------------------------------------------------------------------------- /docs/endpoints/listings_restrictions.rst: -------------------------------------------------------------------------------- 1 | ListingsRestrictions 2 | ==================== 3 | 4 | 5 | .. autoclass:: sp_api.api.ListingsRestrictions -------------------------------------------------------------------------------- /docs/endpoints/merchant_fulfillment.rst: -------------------------------------------------------------------------------- 1 | MerchantFulfillment 2 | =================== 3 | 4 | 5 | .. autoclass:: sp_api.api.MerchantFulfillment 6 | -------------------------------------------------------------------------------- /docs/endpoints/messaging.rst: -------------------------------------------------------------------------------- 1 | Messaging 2 | ========= 3 | 4 | 5 | .. autoclass:: sp_api.api.Messaging 6 | -------------------------------------------------------------------------------- /docs/endpoints/notifications.rst: -------------------------------------------------------------------------------- 1 | Notifications 2 | ============= 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.Notifications 7 | -------------------------------------------------------------------------------- /docs/endpoints/orders.rst: -------------------------------------------------------------------------------- 1 | Orders 2 | ====== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.Orders 7 | 8 | 9 | 10 | Restricted Data Token 11 | ===================== 12 | 13 | To use a restricted data token to access PII data, you can pass the token obtained from the Token endpoint to the client: 14 | 15 | .. code-block:: python 16 | 17 | Orders(restricted_data_token='......').get_orders(...) 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/endpoints/product_fees.rst: -------------------------------------------------------------------------------- 1 | Product Fees 2 | ============ 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.ProductFees 7 | -------------------------------------------------------------------------------- /docs/endpoints/product_type_definitions.rst: -------------------------------------------------------------------------------- 1 | ProductTypeDefinitions 2 | ====================== 3 | 4 | 5 | .. autoclass:: sp_api.api.ProductTypeDefinitions 6 | -------------------------------------------------------------------------------- /docs/endpoints/products.rst: -------------------------------------------------------------------------------- 1 | Products 2 | ======== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.Products 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/endpoints/replenishment.rst: -------------------------------------------------------------------------------- 1 | Replenishment 2 | ============= 3 | 4 | 5 | .. autoclass:: sp_api.api.Replenishment 6 | -------------------------------------------------------------------------------- /docs/endpoints/reports.rst: -------------------------------------------------------------------------------- 1 | Reports 2 | ======= 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.Reports 7 | -------------------------------------------------------------------------------- /docs/endpoints/sales.rst: -------------------------------------------------------------------------------- 1 | Sales 2 | ===== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.Sales 7 | -------------------------------------------------------------------------------- /docs/endpoints/sellers.rst: -------------------------------------------------------------------------------- 1 | Sellers 2 | ======= 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.Sellers 7 | -------------------------------------------------------------------------------- /docs/endpoints/services.rst: -------------------------------------------------------------------------------- 1 | Services 2 | ======== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.Services 7 | -------------------------------------------------------------------------------- /docs/endpoints/shipping.rst: -------------------------------------------------------------------------------- 1 | Shipping 2 | ======== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.Shipping 7 | -------------------------------------------------------------------------------- /docs/endpoints/solicitations.rst: -------------------------------------------------------------------------------- 1 | Solicitations 2 | ============= 3 | 4 | 5 | .. autoclass:: sp_api.api.Solicitations 6 | -------------------------------------------------------------------------------- /docs/endpoints/supply_sources.rst: -------------------------------------------------------------------------------- 1 | Supply Sources 2 | ============== 3 | 4 | 5 | .. autoclass:: sp_api.api.SupplySources 6 | 7 | -------------------------------------------------------------------------------- /docs/endpoints/tokens.rst: -------------------------------------------------------------------------------- 1 | Tokens 2 | ====== 3 | 4 | 5 | .. autoclass:: sp_api.api.Tokens 6 | -------------------------------------------------------------------------------- /docs/endpoints/upload.rst: -------------------------------------------------------------------------------- 1 | Upload 2 | ====== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.Upload 7 | -------------------------------------------------------------------------------- /docs/endpoints/vendor_direct_fulfillment_inventory.rst: -------------------------------------------------------------------------------- 1 | VendorDirectFulfillmentInventory 2 | ================================ 3 | 4 | 5 | .. autoclass:: sp_api.api.VendorDirectFulfillmentInventory 6 | -------------------------------------------------------------------------------- /docs/endpoints/vendor_direct_fulfillment_orders.rst: -------------------------------------------------------------------------------- 1 | VendorDirectFulfillmentOrders 2 | ============================= 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.VendorDirectFulfillmentOrders 7 | -------------------------------------------------------------------------------- /docs/endpoints/vendor_direct_fulfillment_payments.rst: -------------------------------------------------------------------------------- 1 | VendorDirectFulfillmentPayments 2 | =============================== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.VendorDirectFulfillmentPayments 7 | -------------------------------------------------------------------------------- /docs/endpoints/vendor_direct_fulfillment_shipping.rst: -------------------------------------------------------------------------------- 1 | VendorDirectFulfillmentShipping 2 | =============================== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.VendorDirectFulfillmentShipping 7 | -------------------------------------------------------------------------------- /docs/endpoints/vendor_direct_fulfillment_transactions.rst: -------------------------------------------------------------------------------- 1 | VendorDirectFulfillmentTransactions 2 | =================================== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.VendorDirectFulfillmentTransactions 7 | -------------------------------------------------------------------------------- /docs/endpoints/vendor_invoices.rst: -------------------------------------------------------------------------------- 1 | VendorInvoices 2 | ============== 3 | 4 | 5 | .. autoclass:: sp_api.api.VendorInvoices 6 | -------------------------------------------------------------------------------- /docs/endpoints/vendor_orders.rst: -------------------------------------------------------------------------------- 1 | VendorOrders 2 | ============ 3 | 4 | 5 | .. autoclass:: sp_api.api.VendorOrders 6 | -------------------------------------------------------------------------------- /docs/endpoints/vendor_shipments.rst: -------------------------------------------------------------------------------- 1 | VendorShipments 2 | =============== 3 | 4 | 5 | 6 | .. autoclass:: sp_api.api.VendorShipments 7 | -------------------------------------------------------------------------------- /docs/endpoints/vendor_transaction_status.rst: -------------------------------------------------------------------------------- 1 | VendorTransactionStatus 2 | ======================= 3 | 4 | 5 | .. autoclass:: sp_api.api.VendorTransactionStatus 6 | -------------------------------------------------------------------------------- /docs/enums.rst: -------------------------------------------------------------------------------- 1 | Enums 2 | ====== 3 | 4 | .. autoclass:: sp_api.base.Marketplaces 5 | :show-inheritance: 6 | 7 | 8 | .. autoclass:: sp_api.base.FeedTypes 9 | :show-inheritance: 10 | 11 | 12 | .. autoclass:: sp_api.base.FulfillmentChannels 13 | :show-inheritance: 14 | 15 | .. autoclass:: sp_api.base.IdentifiersType 16 | :show-inheritance: 17 | 18 | 19 | .. autoclass:: sp_api.base.IncludedData 20 | :show-inheritance: 21 | 22 | 23 | .. autoclass:: sp_api.base.ListingItemsIncludedData 24 | :show-inheritance: 25 | 26 | 27 | .. autoclass:: sp_api.base.CatalogItemsIncludedData 28 | :show-inheritance: 29 | 30 | 31 | .. autoclass:: sp_api.base.IneligibilityReasonList 32 | :show-inheritance: 33 | 34 | 35 | .. autoclass:: sp_api.base.InventoryGranularity 36 | :show-inheritance: 37 | 38 | .. autoclass:: sp_api.base.NotificationType 39 | :show-inheritance: 40 | 41 | .. autoclass:: sp_api.base.ProcessingStatus 42 | :show-inheritance: 43 | 44 | 45 | .. autoclass:: sp_api.base.ReportStatus 46 | :show-inheritance: 47 | 48 | 49 | .. autoclass:: sp_api.base.ReportType 50 | :show-inheritance: 51 | 52 | 53 | .. autoclass:: sp_api.base.Granularity 54 | :show-inheritance: 55 | 56 | 57 | .. autoclass:: sp_api.base.BuyerType 58 | :show-inheritance: 59 | 60 | 61 | .. autoclass:: sp_api.base.FirstDayOfWeek 62 | :show-inheritance: 63 | 64 | .. autoclass:: sp_api.base.Schedules 65 | :show-inheritance: 66 | 67 | .. autoclass:: sp_api.base.AwsEnv 68 | :show-inheritance: 69 | -------------------------------------------------------------------------------- /docs/env_variables.rst: -------------------------------------------------------------------------------- 1 | Environment Variables 2 | ===================== 3 | 4 | 5 | ===================== ========================================================================================================= 6 | ENVIRONMENT VARIABLE DESCRIPTION 7 | ===================== ========================================================================================================= 8 | SP_API_REFRESH_TOKEN The refresh token used obtained via authorization (can be passed to the client instead) 9 | LWA_APP_ID Your login with amazon app id 10 | LWA_CLIENT_SECRET Your login with amazon client secret 11 | ===================== ========================================================================================================= 12 | 13 | .. note:: 14 | Required fields are: 15 | 16 | - lwa_app_id 17 | - lwa_client_secret 18 | 19 | 20 | If you don't set the refresh_token, you have to pass it to the client. 21 | 22 | .. code-block:: python 23 | 24 | Orders(refresh_token='...') 25 | 26 | To set environment variables under linux/mac, use 27 | 28 | .. code-block:: bash 29 | 30 | export SP_API_REFRESH_TOKEN="" 31 | 32 | 33 | You can (but don't have to) suffix each of these variables with `_` if you want to set multiple accounts via env variables. 34 | 35 | .. code-block:: bash 36 | 37 | export SP_API_REFRESH_TOKEN_ANOTHER_ACCOUNT="" 38 | 39 | 40 | ************************** 41 | Usage with default account 42 | ************************** 43 | 44 | .. code-block:: python 45 | 46 | Orders().get_orders(CreatedAfter=(datetime.utcnow() - timedelta(days=7)).isoformat()) 47 | 48 | 49 | ************************** 50 | Usage with another_account 51 | ************************** 52 | 53 | You can use every account's name 54 | 55 | .. code-block:: python 56 | 57 | Orders(account='ANOTHER_ACCOUNT').get_orders(CreatedAfter=(datetime.utcnow() - timedelta(days=7)).isoformat()) 58 | 59 | .. note:: 60 | 61 | The refresh token can be passed directly to the client, too. You don't need to pass the whole credentials if all that changes is the refresh token. 62 | 63 | .. code-block:: python 64 | 65 | Orders(account='ANOTHER_ACCOUNT', refresh_token='').get_orders(CreatedAfter=(datetime.utcnow() - timedelta(days=7)).isoformat()) 66 | 67 | -------------------------------------------------------------------------------- /docs/examples.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ========= 3 | 4 | 5 | 6 | 7 | .. toctree:: 8 | :maxdepth: 1 9 | 10 | examples/authorisation_example -------------------------------------------------------------------------------- /docs/examples/authorisation_example.rst: -------------------------------------------------------------------------------- 1 | Initial Authorisation 2 | ===================== 3 | 4 | 5 | Internal Seller Access 6 | ---------------------- 7 | 8 | To gain initial access to the Api you will need to follow the authorisation process as documented by 9 | Amazon https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/developer-guide/SellingPartnerApiDeveloperGuide.md 10 | 11 | This involves two main stages: 12 | 13 | - Adding an App to your Seller Central account. 14 | - Configuring Python-SPAPI with the correct credentials. 15 | 16 | Configuring the App in Seller Central: 17 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 18 | 19 | .. note:: 20 | **To add an App to your Seller central account you must be logged in the account owner.** 21 | 22 | Overview: 23 | 24 | - Seller Central -> Partner Network -> Develop Apps. 25 | - Add a new client app 26 | - Click the `LWA Credentials View` link to see your `Login With Amazon` credentials. 27 | - Click *Authorise* and copy the `REFRESH_TOKEN` that is provided to you. *This is your only chance to see this token!, you will nee to regenerate it if you lose it.* 28 | 29 | 30 | Configuring Python SPAPI. 31 | ^^^^^^^^^^^^^^^^^^^^^^^^^ 32 | 33 | Using the credentials dict as our example (Note you can use file or environment variables): 34 | 35 | The following is an overview of which credentials go with which key. 36 | 37 | - `refresh_token` -> This is from Seller Central, Authorisation of the app window 38 | - `lws_app_id` -> This is from Seller central under LWA client credentials -> Client Identifier and will look like `amzn1.application-oa2-client.7b18cd......` 39 | - `lwa_client_secret` -> This is from Seller central under LWA client credentials -> Client Secret and will look like `b5f7f8...` 40 | 41 | .. code-block:: python 42 | 43 | credentials = dict( 44 | refresh_token='your_refresh_token', # From Seller central under Authorise -> Refresh Token 45 | lwa_app_id='your_lwa_app_id', # From Seller Central, named CLIENT IDENTIFIER on website. 46 | lwa_client_secret='your_lwa_client_secret', # From Seller Central, named CLIENT SECRET on website. 47 | ) 48 | 49 | 50 | 51 | 52 | **Example Screenshots** 53 | 54 | 55 | *App Overview* 56 | 57 | On this screen you can both create a new app, gain your LWA credentials for an existing app, and authorise your app (get refresh token). 58 | 59 | .. image:: ../_static/images/App_Overview.png 60 | 61 | **Create Application** 62 | 63 | .. image:: ../_static/images/Create_App.png 64 | 65 | **Authorise Application** 66 | 67 | .. image:: ../_static/images/Authorise_Application.png 68 | 69 | **LWA Credentials View** 70 | 71 | .. image:: ../_static/images/LWA_Credentials.png 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /docs/exceptions.rst: -------------------------------------------------------------------------------- 1 | Exceptions 2 | ========== 3 | 4 | .. autoclass:: sp_api.base.MissingCredentials 5 | 6 | .. autoclass:: sp_api.base.exceptions.SellingApiException 7 | :show-inheritance: 8 | 9 | .. autoclass:: sp_api.base.SellingApiBadRequestException 10 | :show-inheritance: 11 | 12 | .. autoclass:: sp_api.base.SellingApiForbiddenException 13 | :show-inheritance: 14 | 15 | .. autoclass:: sp_api.base.SellingApiNotFoundException 16 | :show-inheritance: 17 | 18 | .. autoclass:: sp_api.base.SellingApiRequestThrottledException 19 | :show-inheritance: 20 | 21 | .. autoclass:: sp_api.base.SellingApiServerException 22 | :show-inheritance: 23 | 24 | .. autoclass:: sp_api.base.SellingApiTemporarilyUnavailableException 25 | :show-inheritance: 26 | 27 | -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/docs/favicon.ico -------------------------------------------------------------------------------- /docs/from_code.rst: -------------------------------------------------------------------------------- 1 | From Code 2 | ========= 3 | 4 | 5 | You can override/set credentials from code by passing a ``dict`` to the client. 6 | 7 | If you pass a value in credentials, other credentials from env variables or from a config file will be ignored. 8 | 9 | .. note:: 10 | Required fields are: 11 | 12 | - lwa_app_id 13 | - lwa_client_secret 14 | 15 | If you don't set the refresh_token, you have to pass it to the client. 16 | 17 | .. code-block:: python 18 | 19 | Orders(refresh_token='...') 20 | 21 | 22 | .. code-block:: python 23 | 24 | credentials=dict( 25 | refresh_token='', 26 | lwa_app_id='', 27 | lwa_client_secret='' 28 | ) 29 | 30 | 31 | 32 | ***** 33 | Usage 34 | ***** 35 | 36 | .. code-block:: python 37 | 38 | Orders(credentials=credentials).get_orders(CreatedAfter=(datetime.utcnow() - timedelta(days=7)).isoformat()) 39 | 40 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. PYTHON-AMAZON-SP-API documentation master file, created by 2 | sphinx-quickstart on Thu Jan 28 17:29:02 2021. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to PYTHON-AMAZON-SP-API's documentation! 7 | ================================================ 8 | 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | installation 14 | credentials 15 | examples 16 | quickstart 17 | versions 18 | endpoints 19 | pii 20 | responses 21 | exceptions 22 | utils 23 | enums 24 | testing 25 | 26 | 27 | Indices and tables 28 | ================== 29 | * :ref:`genindex` 30 | * :ref:`modindex` 31 | * :ref:`search` 32 | 33 | -------------------------------------------------------------------------------- /docs/installation.rst: -------------------------------------------------------------------------------- 1 | Installation 2 | ============ 3 | 4 | 5 | 6 | 7 | 8 | 9 | You can install using pip 10 | 11 | 12 | 13 | 14 | .. code-block:: bash 15 | 16 | pip install python-amazon-sp-api 17 | 18 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/pii.rst: -------------------------------------------------------------------------------- 1 | Personally identifiable information (PII) 2 | ========================================= 3 | 4 | If your application has access to PII-Data, you can request a token with the `Token`_ client, then use the returned token to access protected resources. 5 | 6 | .. _Token: https://sp-api-docs.saleweaver.com/endpoints/tokens/ 7 | 8 | .. code-block:: python 9 | 10 | token_res = Tokens().create_restricted_data_token(restrictedResources=[{ 11 | "method": "GET", 12 | "path": "/orders/v0/orders", 13 | "dataElements": ["buyerInfo", "shippingAddress"] 14 | } 15 | ]) 16 | orders = Orders(restricted_data_token=token_res.payload['restrictedDataToken']).get_orders(LastUpdatedAfter=(datetime.utcnow() - timedelta(days=7)).isoformat()) 17 | 18 | # orders have buyerInfo and shippingAddress 19 | print(orders) 20 | 21 | Starting with v0.9.0, you can also pass the `RestrictedResources` to the `Orders` calls: 22 | 23 | .. code-block:: python 24 | 25 | orders = Orders().get_orders( 26 | RestrictedResources=['buyerInfo', 'shippingAddress'], 27 | LastUpdatedAfter=(datetime.utcnow() - timedelta(days=1)).isoformat() 28 | ) 29 | 30 | order = Orders().get_order( 31 | 'order-id', 32 | RestrictedResources=['buyerInfo', 'shippingAddress'] 33 | ) 34 | 35 | order_items = Orders().get_order_items( 36 | 'order-id', 37 | RestrictedResources=['buyerInfo'] 38 | ) 39 | 40 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | 2 | sphinx_rtd_theme 3 | point 4 | pytest 5 | requests~=2.32.3 6 | 7 | boto3~=1.38.31 8 | 9 | cachetools~=5.5.2 10 | setuptools~=77.0.3 11 | pytz~=2025.1 12 | confuse~=2.0.1 13 | jinja2 14 | 15 | sphinxcontrib-napoleon 16 | 17 | sphinx-jinja2-compat>=0.1.1 18 | sphinx-toolbox>=2.16.0 19 | enum-tools[sphinx] 20 | -------------------------------------------------------------------------------- /docs/responses.rst: -------------------------------------------------------------------------------- 1 | Responses 2 | ========= 3 | 4 | All endpoints return `sp_api.base.ApiResponse` with the following signature. `payload` contains Amazon's response. 5 | 6 | .. code-block:: python 7 | 8 | response = Orders().get_orders(CreatedAfter='TEST_CASE_200', MarketplaceIds=["ATVPDKIKX0DER"]) 9 | 10 | print(response.payload) # original response data 11 | # Access one of `payload`s properties using `__getattr__` 12 | print(response.Orders) # Array of orders 13 | # Access one of `payload`s properties using `__call__` 14 | print(response('Orders')) # Array of orders 15 | # Shorthand for response.payload 16 | print(response()) # original response data 17 | 18 | ----------------------------------------- 19 | 20 | .. autoclass:: sp_api.base.ApiResponse 21 | 22 | 23 | -------------------------------------------------------------------------------- /docs/testing.rst: -------------------------------------------------------------------------------- 1 | Testing / Sandbox 2 | ================= 3 | 4 | For testing, you can use the sandbox endpoints by setting `AWS_ENV="SANDBOX"` 5 | 6 | .. code-block:: bash 7 | 8 | export AWS_ENV="SANDBOX" 9 | -------------------------------------------------------------------------------- /docs/utils.rst: -------------------------------------------------------------------------------- 1 | Utils 2 | ===== 3 | 4 | 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | utils/retry 10 | utils/load_all_pages 11 | utils/key_maker 12 | -------------------------------------------------------------------------------- /docs/utils/key_maker.rst: -------------------------------------------------------------------------------- 1 | Key Maker 2 | ========= 3 | 4 | .. autoclass:: sp_api.util.KeyMaker 5 | -------------------------------------------------------------------------------- /docs/utils/load_all_pages.rst: -------------------------------------------------------------------------------- 1 | Load All Pages Decorator 2 | ======================== 3 | 4 | .. automethod:: sp_api.util.load_all_pages 5 | 6 | The example below will load all pages, transforming the decorated function to a generator. 7 | The generator yields a page at a time. 8 | 9 | Some examples: 10 | 11 | .. code-block:: python 12 | 13 | from datetime import datetime, timedelta 14 | from sp_api.base import Marketplaces 15 | from sp_api.api import Orders 16 | from sp_api.util import throttle_retry, load_all_pages 17 | 18 | 19 | @throttle_retry() 20 | @load_all_pages() 21 | def load_all_orders(**kwargs): 22 | """ 23 | a generator function to return all pages, obtained by NextToken 24 | """ 25 | return Orders().get_orders(**kwargs) 26 | 27 | 28 | for page in load_all_orders(LastUpdatedAfter=(datetime.utcnow() - timedelta(days=7)).isoformat()): 29 | for order in page.payload.get('Orders'): 30 | print(order) 31 | 32 | 33 | .. code-block:: python 34 | 35 | @throttle_retry() 36 | @load_all_pages() 37 | def get_financial_events(**kwargs): 38 | return Finances().list_financial_events(**kwargs) 39 | 40 | for page in get_financial_events(PostedAfter='2021-05-10', PostedBefore='2021-05-11', MaxResultsPerPage=100): 41 | for event in page.payload.get('FinancialEvents').get('ShipmentEventList'): 42 | print(event) 43 | 44 | 45 | .. warning:: 46 | 47 | Amazon's endpoints don't follow naming conventions within the API. The parameter `NextToken` sometimes is called `next_token`, or differently. 48 | @load_all_pages accepts `next_token_param` as a parameter: 49 | 50 | .. code-block:: python 51 | 52 | @load_all_pages(next_token_param='next_token') 53 | 54 | Now it will look for a key named `next_token` in payload, instead of `NextToken` 55 | 56 | 57 | -------------------------------------------------------------------------------- /docs/utils/retry.rst: -------------------------------------------------------------------------------- 1 | Retry Decorators 2 | ================ 3 | 4 | .. automethod:: sp_api.util.retry 5 | .. automethod:: sp_api.util.sp_retry 6 | .. automethod:: sp_api.util.throttle_retry 7 | 8 | 9 | The example below will retry the call when a throttled exception was thrown: 10 | 11 | .. code-block:: python 12 | 13 | @throttle_retry(tries=10, delay=5, rate=1.3) 14 | def get_orders(**kwargs): 15 | return Orders().get_orders(**kwargs) 16 | 17 | 18 | The example below will return all pages, retrying each call up to times 19 | 20 | .. code-block:: python 21 | 22 | @sp_retry(tries=10, delay=10, rate=1.2) 23 | @load_all_pages() 24 | def get_orders(**kwargs): 25 | return Orders().get_orders(**kwargs) 26 | -------------------------------------------------------------------------------- /docs/versions.rst: -------------------------------------------------------------------------------- 1 | Versioning 2 | ========== 3 | 4 | 5 | Some clients have multiple versions, and the versioning is done by setting the version when constructing a new client. 6 | 7 | .. note:: 8 | 9 | All clients have a default version, and if you don't specify a version, the default version will be used. The default version is the oldest version available at the time of the client's release. 10 | 11 | 12 | To use the latest version available, you can use the `LATEST` enum. 13 | 14 | 15 | .. code-block:: python 16 | 17 | CatalogItems(version=CatalogItemsVersion.LATEST) 18 | 19 | -------------------------------------------------------------------------------- /generate_changelog.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os 3 | import openai 4 | from sp_api.__version__ import __version__ 5 | 6 | 7 | openai.api_key = os.getenv("OPENAI_API_KEY") 8 | 9 | if len(sys.argv) < 2: 10 | print("No diff file provided.") 11 | sys.exit(1) 12 | 13 | diff_file = sys.argv[1] 14 | with open(diff_file, 'r') as f: 15 | diff = f.read() 16 | 17 | prompt = f""" 18 | You are a helpful assistant who generates changelog entries for the python-amazon-sp-api, a wrapper to access Amazon's Selling Partner API with an easy-to-use interface. This tool helps developers and businesses connect seamlessly with Amazon's vast marketplace, enabling powerful automations and data management. 19 | This is a growing changelog entry for the project. Only add changes that are relevant to the end-users, such as new features, changes to existing features, and bug fixes. Categorize and group changes between internal and relevant to the project.. 20 | The current version is {__version__}. Add this to the Changelog header. Never include dates or release status in the changelog entry. 21 | 22 | Given the following git diff, generate a concise, well-formatted Markdown changelog entry. Add mermaid diagrams to showcase changes. Do not enclose the resulting markdown in backticks.: 23 | 24 | ```diff 25 | {diff} 26 | ``` 27 | """ 28 | 29 | response = openai.chat.completions.create( 30 | model="gpt-4o", 31 | messages=[ 32 | {"role": "system", "content": "You are a helpful assistant that generates changelog entries."}, 33 | {"role": "user", "content": prompt} 34 | ], 35 | temperature=0.3, 36 | max_tokens=750 37 | ) 38 | 39 | changelog_entry = response.choices[0].message.content.strip() 40 | print(changelog_entry) 41 | with open('changelog_entry.md', 'w') as out_file: 42 | out_file.write(changelog_entry.strip('`') + "\n") 43 | -------------------------------------------------------------------------------- /make_endpoint/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/make_endpoint/__init__.py -------------------------------------------------------------------------------- /make_endpoint/make_docs.py: -------------------------------------------------------------------------------- 1 | import os 2 | import re 3 | 4 | dirs = [ 5 | 'application_integrations' 6 | ] 7 | 8 | 9 | def to_class_name(s): 10 | return re.sub(r'_([a-z])', lambda match: match.group(1).upper(), s[0].upper() + s[1:]) 11 | 12 | 13 | def get_endpoint_link(s): 14 | return f""" endpoints/{s} 15 | """ 16 | 17 | 18 | def get_endpoint_file_template(s): 19 | class_name = to_class_name(s) 20 | return f"""{class_name} 21 | {'=' * len(class_name)} 22 | 23 | 24 | .. autoclass:: sp_api.api.{class_name}""" 25 | 26 | 27 | def append_to_links(link): 28 | with open('../docs/endpoints.rst', 'a') as f: 29 | f.write(link) 30 | f.close() 31 | 32 | 33 | def create_endpoint_file(file_contents, endpoint): 34 | with open(f'../docs/endpoints/{endpoint}.rst', 'w+') as f: 35 | f.write(file_contents) 36 | f.close() 37 | 38 | 39 | if __name__ == '__main__': 40 | for endpoint in dirs: 41 | append_to_links(get_endpoint_link(endpoint)) 42 | create_endpoint_file(get_endpoint_file_template(endpoint), endpoint) 43 | -------------------------------------------------------------------------------- /make_endpoint/template.py.jinja2: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | 3 | from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse 4 | 5 | 6 | class {{ endpoint }}(Client): 7 | """ 8 | {{ endpoint }} SP-API Client 9 | :link: {{ docs_link }} 10 | 11 | {{ description }} 12 | """ 13 | 14 | {% for operation in operations %} 15 | @sp_endpoint('{{ operation.uri }}', method='{{ operation.method }}') 16 | def {{ operation.title }}(self, {{ (operation.query_param + ', ') if operation.has_query_params }}**kwargs) -> ApiResponse: 17 | """ 18 | {{ operation.title }}(self, {{ (operation.query_param + ', ') if operation.has_query_params }}**kwargs) -> ApiResponse 19 | 20 | {{ operation.description }} 21 | 22 | Args: 23 | {% for arg in operation.params %} 24 | {{ 'key ' if arg['in'] == 'query' else ''}}{{ arg.name }}:{{ arg.type }} | {{ '* REQUIRED' if arg.required else '' }} {{ arg.description }} 25 | {% endfor %} 26 | 27 | Returns: 28 | ApiResponse: 29 | """ 30 | {% if operation.has_query_params %} 31 | return self._request(fill_query_params(kwargs.pop('path'), {{ operation.query_param }}), {{ operation.params_or_data }}=kwargs) 32 | {% else %} 33 | return self._request(kwargs.pop('path'), {{ operation.params_or_data }}=kwargs) 34 | {% endif %} 35 | {% endfor %} 36 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | pytest 2 | requests~=2.32.3 3 | 4 | boto3~=1.38.31 5 | 6 | cachetools~=5.5.2 7 | setuptools~=77.0.3 8 | pytz~=2025.1 9 | confuse~=2.0.1 10 | jinja2 11 | 12 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | name = python_amazon_sp_api 3 | description= file: README.md 4 | long_description=file: README.md 5 | long_description_content_type=text/markdown 6 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | from sp_api.__version__ import __version__ 4 | 5 | setup( 6 | name='python-amazon-sp-api', 7 | version=__version__, 8 | install_requires=[ 9 | "requests>=2.32.1", 10 | "cachetools>=4.2", 11 | "confuse>=1.4" 12 | ], 13 | extras_require={ 14 | "aws-caching": ["aws-secretsmanager-caching", "boto3"], 15 | "aws": ["boto3"] 16 | }, 17 | packages=['tests', 'tests.api', 'tests.api.orders', 'tests.api.sellers', 'tests.api.finances', 18 | 'tests.api.product_fees', 'tests.api.notifications', 'tests.api.reports', 'tests.client', 19 | 'sp_api', 20 | 'sp_api.api', 21 | 'sp_api.api.orders', 22 | 'sp_api.api.sellers', 23 | 'sp_api.api.finances', 24 | 'sp_api.api.product_fees', 25 | 'sp_api.api.products', 26 | 'sp_api.api.feeds', 27 | 'sp_api.api.sales', 28 | 'sp_api.api.catalog', 29 | 'sp_api.api.notifications', 30 | 'sp_api.api.reports', 31 | 'sp_api.api.inventories', 32 | 'sp_api.api.messaging', 33 | 'sp_api.api.upload', 34 | 'sp_api.api.merchant_fulfillment', 35 | 'sp_api.api.fulfillment_inbound', 36 | 'sp_api.api.data_kiosk', 37 | 'sp_api.api.replenishment', 38 | 'sp_api.api.supply_sources', 39 | 'sp_api.auth', 40 | 'sp_api.base', 41 | 'sp_api.util', 42 | ##### DO NOT DELETE ########## INSERT PACKAGE HERE ####### 43 | 'sp_api.api.application_integrations', 44 | 45 | 'sp_api.api.easy_ship', 46 | 'sp_api.api.listings_restrictions', 47 | 'sp_api.api.amazon_warehousing_and_distribu', 48 | 'sp_api.api.catalog_items', 49 | 'sp_api.api.product_type_definitions', 50 | 'sp_api.api.listings_items', 51 | 'sp_api.api.vendor_transaction_status', 52 | 'sp_api.api.vendor_shipments', 53 | 'sp_api.api.vendor_orders', 54 | 'sp_api.api.vendor_invoices', 55 | 'sp_api.api.vendor_direct_fulfillment_transactions', 56 | 'sp_api.api.vendor_direct_fulfillment_shipping', 57 | 'sp_api.api.vendor_direct_fulfillment_payments', 58 | 'sp_api.api.vendor_direct_fulfillment_orders', 59 | 'sp_api.api.vendor_direct_fulfillment_inventory', 60 | 'sp_api.api.tokens', 61 | 'sp_api.api.solicitations', 62 | 'sp_api.api.shipping', 63 | 'sp_api.api.services', 64 | 'sp_api.api.fba_small_and_light', 65 | 'sp_api.api.fba_inbound_eligibility', 66 | 'sp_api.api.authorization', 67 | 'sp_api.api.aplus_content', 68 | 'sp_api.api.fulfillment_outbound', 69 | 'sp_api.api.application_management', 70 | ], 71 | scripts=['make_endpoint/make_endpoint'], 72 | url='https://github.com/saleweaver/python-amazon-sp-api', 73 | license='MIT', 74 | author='Michael', 75 | author_email='primke.michael@gmail.com', 76 | description='Python wrapper for the Amazon Selling-Partner API' 77 | ) 78 | -------------------------------------------------------------------------------- /sp_api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/__init__.py -------------------------------------------------------------------------------- /sp_api/__version__.py: -------------------------------------------------------------------------------- 1 | __version__ = '1.9.36' 2 | -------------------------------------------------------------------------------- /sp_api/api/amazon_warehousing_and_distribu/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/amazon_warehousing_and_distribu/__init__.py -------------------------------------------------------------------------------- /sp_api/api/aplus_content/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/aplus_content/__init__.py -------------------------------------------------------------------------------- /sp_api/api/application_integrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/application_integrations/__init__.py -------------------------------------------------------------------------------- /sp_api/api/application_management/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/application_management/__init__.py -------------------------------------------------------------------------------- /sp_api/api/application_management/application_management.py: -------------------------------------------------------------------------------- 1 | from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse 2 | 3 | 4 | class ApplicationManagement(Client): 5 | """ 6 | ApplicationManagement SP-API Client 7 | :link: 8 | 9 | The Selling Partner API for Application Management lets you programmatically update the client secret on registered applications. 10 | """ 11 | grantless_scope = 'sellingpartnerapi::client_credential:rotation' 12 | 13 | @sp_endpoint("/applications/2023-11-30/clientSecret", method="POST") 14 | def rotate_application_client_secret(self, **kwargs) -> ApiResponse: 15 | """ 16 | rotate_application_client_secret(self, **kwargs) -> ApiResponse 17 | 18 | Rotates application client secrets for a developer application. Developers must register a destination queue in the developer console before calling this operation. When this operation is called a new client secret is generated and sent to the developer-registered queue. For more information, refer to [Rotate your application client secret](https://developer-docs.amazon.com/sp-api/docs/application-management-api-v2023-11-30-use-case-guide). 19 | 20 | **Usage Plan:** 21 | 22 | | Rate (requests per second) | Burst | 23 | | ---- | ---- | 24 | | 0.0167 | 1 | 25 | 26 | The `x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may see higher rate and burst values than those shown here. For more information, refer to [Usage Plans and Rate Limits in the Selling Partner API](https://developer-docs.amazon.com/sp-api/docs/usage-plans-and-rate-limits-in-the-sp-api). 27 | 28 | Args: 29 | 30 | 31 | Returns: 32 | ApiResponse: 33 | """ 34 | 35 | return self._request_grantless_operation(kwargs.pop("path"), data=kwargs) 36 | -------------------------------------------------------------------------------- /sp_api/api/authorization/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/authorization/__init__.py -------------------------------------------------------------------------------- /sp_api/api/authorization/authorization.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | 3 | from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse 4 | 5 | 6 | class Authorization(Client): 7 | """ 8 | Authorization SP-API Client 9 | :link: 10 | 11 | The Selling Partner API for Authorization helps developers manage authorizations and check the specific permissions associated with a given authorization. 12 | """ 13 | 14 | grantless_scope = "sellingpartnerapi::migration" 15 | 16 | @sp_endpoint("/authorization/v1/authorizationCode", method="GET") 17 | def get_authorization_code(self, **kwargs) -> ApiResponse: 18 | """ 19 | get_authorization_code(self, **kwargs) -> ApiResponse 20 | 21 | With the getAuthorizationCode operation, you can request a Login With Amazon (LWA) authorization code that will allow you to call a Selling Partner API on behalf of a seller who has already authorized you to call Amazon Marketplace Web Service (Amazon MWS). You specify a developer ID, an MWS auth token, and a seller ID. Taken together, these represent the Amazon MWS authorization that the seller previously granted you. The operation returns an LWA authorization code that can be exchanged for a refresh token and access token representing authorization to call the Selling Partner API on the seller's behalf. By using this API, sellers who have already authorized you for Amazon MWS do not need to re-authorize you for the Selling Partner API. 22 | 23 | **Usage Plan:** 24 | 25 | 26 | ====================================== ============== 27 | Rate (requests per second) Burst 28 | ====================================== ============== 29 | 1 5 30 | ====================================== ============== 31 | 32 | For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. 33 | 34 | Examples: 35 | literal blocks:: 36 | 37 | res = Authorization().get_authorization_code( 38 | mwsAuthToken='test', 39 | developerId='test', 40 | sellingPartnerId='test' 41 | ) 42 | 43 | 44 | Args: 45 | key sellingPartnerId:string | * REQUIRED The seller ID of the seller for whom you are requesting Selling Partner API authorization. This must be the seller ID of the seller who authorized your application on the Marketplace Appstore. 46 | key developerId:string | * REQUIRED Your developer ID. This must be one of the developer ID values that you provided when you registered your application in Developer Central. 47 | key mwsAuthToken:string | * REQUIRED The MWS Auth Token that was generated when the seller authorized your application on the Marketplace Appstore. 48 | 49 | Returns: 50 | ApiResponse: 51 | """ 52 | 53 | return self._request_grantless_operation(kwargs.pop("path"), params=kwargs) 54 | -------------------------------------------------------------------------------- /sp_api/api/catalog/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/catalog/__init__.py -------------------------------------------------------------------------------- /sp_api/api/catalog_items/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/catalog_items/__init__.py -------------------------------------------------------------------------------- /sp_api/api/data_kiosk/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/data_kiosk/__init__.py -------------------------------------------------------------------------------- /sp_api/api/easy_ship/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/easy_ship/__init__.py -------------------------------------------------------------------------------- /sp_api/api/fba_inbound_eligibility/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/fba_inbound_eligibility/__init__.py -------------------------------------------------------------------------------- /sp_api/api/fba_small_and_light/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/fba_small_and_light/__init__.py -------------------------------------------------------------------------------- /sp_api/api/feeds/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/feeds/__init__.py -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/CancelFeedResponse.md: -------------------------------------------------------------------------------- 1 | # CancelFeedResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/CreateFeedDocumentResponse.md: -------------------------------------------------------------------------------- 1 | # CreateFeedDocumentResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**CreateFeedDocumentResult**](CreateFeedDocumentResult.md) | | [optional] 7 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/CreateFeedDocumentResult.md: -------------------------------------------------------------------------------- 1 | # CreateFeedDocumentResult 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **feed_document_id** | **str** | The identifier of the feed document. | 7 | **url** | **str** | The presigned URL for uploading the feed contents. This URL expires after 5 minutes. | 8 | **encryption_details** | [**FeedDocumentEncryptionDetails**](FeedDocumentEncryptionDetails.md) | | 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/CreateFeedDocumentSpecification.md: -------------------------------------------------------------------------------- 1 | # CreateFeedDocumentSpecification 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **content_type** | **str** | The content type of the feed. | 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/CreateFeedResponse.md: -------------------------------------------------------------------------------- 1 | # CreateFeedResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**CreateFeedResult**](CreateFeedResult.md) | | [optional] 7 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/CreateFeedResult.md: -------------------------------------------------------------------------------- 1 | # CreateFeedResult 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **feed_id** | **str** | The identifier for the feed. This identifier is unique only in combination with a seller ID. | 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/CreateFeedSpecification.md: -------------------------------------------------------------------------------- 1 | # CreateFeedSpecification 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **feed_type** | **str** | The feed type. | 7 | **marketplace_ids** | **list[str]** | A list of identifiers for marketplaces that you want the feed to be applied to. | 8 | **input_feed_document_id** | **str** | The document identifier returned by the createFeedDocument operation. Encrypt and upload the feed document contents before calling the createFeed operation. | 9 | **feed_options** | [**FeedOptions**](FeedOptions.md) | | [optional] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/Error.md: -------------------------------------------------------------------------------- 1 | # Error 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **code** | **str** | An error code that identifies the type of error that occurred. | 7 | **message** | **str** | A message that describes the error condition in a human-readable form. | 8 | **details** | **str** | Additional details that can help the caller understand or fix the issue. | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/ErrorList.md: -------------------------------------------------------------------------------- 1 | # ErrorList 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/Feed.md: -------------------------------------------------------------------------------- 1 | # Feed 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **feed_id** | **str** | The identifier for the feed. This identifier is unique only in combination with a seller ID. | 7 | **feed_type** | **str** | The feed type. | 8 | **marketplace_ids** | **list[str]** | A list of identifiers for the marketplaces that the feed is applied to. | [optional] 9 | **created_time** | **datetime** | The date and time when the feed was created, in ISO 8601 date time format. | 10 | **processing_status** | **str** | The processing status of the feed. | 11 | **processing_start_time** | **datetime** | The date and time when feed processing started, in ISO 8601 date time format. | [optional] 12 | **processing_end_time** | **datetime** | The date and time when feed processing completed, in ISO 8601 date time format. | [optional] 13 | **result_feed_document_id** | **str** | The identifier for the feed document. This identifier is unique only in combination with a seller ID. | [optional] 14 | 15 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 16 | 17 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/FeedDocument.md: -------------------------------------------------------------------------------- 1 | # FeedDocument 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **feed_document_id** | **str** | The identifier for the feed document. This identifier is unique only in combination with a seller ID. | 7 | **url** | **str** | A presigned URL for the feed document. This URL expires after 5 minutes. | 8 | **encryption_details** | [**FeedDocumentEncryptionDetails**](FeedDocumentEncryptionDetails.md) | | 9 | **compression_algorithm** | **str** | If present, the feed document contents are compressed using the indicated algorithm. | [optional] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/FeedDocumentEncryptionDetails.md: -------------------------------------------------------------------------------- 1 | # FeedDocumentEncryptionDetails 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **standard** | **str** | The encryption standard required to encrypt or decrypt the document contents. | 7 | **initialization_vector** | **str** | The vector to encrypt or decrypt the document contents using Cipher Block Chaining (CBC). | 8 | **key** | **str** | The encryption key used to encrypt or decrypt the document contents. | 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/FeedList.md: -------------------------------------------------------------------------------- 1 | # FeedList 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/FeedOptions.md: -------------------------------------------------------------------------------- 1 | # FeedOptions 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/GetFeedDocumentResponse.md: -------------------------------------------------------------------------------- 1 | # GetFeedDocumentResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**FeedDocument**](FeedDocument.md) | | [optional] 7 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/GetFeedResponse.md: -------------------------------------------------------------------------------- 1 | # GetFeedResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**Feed**](Feed.md) | | [optional] 7 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/feeds/docs/GetFeedsResponse.md: -------------------------------------------------------------------------------- 1 | # GetFeedsResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**FeedList**](FeedList.md) | | [optional] 7 | **next_token** | **str** | Returned when the number of results exceeds pageSize. To get the next page of results, call the getFeeds operation with this token as the only parameter. | [optional] 8 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sp_api/api/finances/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/finances/__init__.py -------------------------------------------------------------------------------- /sp_api/api/finances/finances.py: -------------------------------------------------------------------------------- 1 | import enum 2 | 3 | from sp_api.base import Client, Marketplaces, ApiResponse 4 | from sp_api.base import sp_endpoint, fill_query_params 5 | 6 | class FinancesVersion(str, enum.Enum): 7 | V_0 = "v0" 8 | V_2024_06_19 = "2024-06-19" 9 | LATEST = "2024-06-19" 10 | 11 | 12 | class Finances(Client): 13 | version: FinancesVersion = FinancesVersion.V_0 14 | 15 | def __init__(self, *args, **kwargs): 16 | if "version" in kwargs: 17 | self.version = kwargs.get("version", FinancesVersion.V_0) 18 | super().__init__(*args, **{**kwargs, "version": self.version}) 19 | 20 | @sp_endpoint("/finances//orders/{}/financialEvents") 21 | def get_financial_events_for_order(self, order_id, **kwargs) -> ApiResponse: 22 | """ 23 | get_financial_events_for_order(self, order_id, **kwargs) -> ApiResponse 24 | 25 | Examples: 26 | literal blocks:: 27 | 28 | Finances().get_financial_events_for_order('485-734-5434857', MaxResultsPerPage=10) 29 | 30 | Args: 31 | order_id: 32 | **kwargs: 33 | 34 | Returns: 35 | 36 | """ 37 | return self._request( 38 | fill_query_params(kwargs.pop("path"), order_id), params={**kwargs} 39 | ) 40 | 41 | @sp_endpoint("/finances//financialEvents") 42 | def list_financial_events(self, **kwargs) -> ApiResponse: 43 | """ 44 | list_financial_events(self, **kwargs) -> ApiResponse: 45 | 46 | 47 | Args: 48 | **kwargs: 49 | 50 | Returns: 51 | 52 | """ 53 | return self._request(fill_query_params(kwargs.pop("path")), params={**kwargs}) 54 | 55 | @sp_endpoint("/finances//financialEventGroups/{}/financialEvents") 56 | def list_financial_events_by_group_id( 57 | self, event_group_id, **kwargs 58 | ) -> ApiResponse: 59 | """ 60 | list_financial_events_by_groupid(self, event_group_id, **kwargs) -> ApiResponse: 61 | 62 | 63 | Args: 64 | event_group_id 65 | **kwargs: 66 | 67 | Returns: 68 | 69 | """ 70 | return self._request( 71 | fill_query_params(kwargs.pop("path"), event_group_id), params={**kwargs} 72 | ) 73 | 74 | @sp_endpoint("/finances//financialEventGroups") 75 | def list_financial_event_groups(self, **kwargs) -> ApiResponse: 76 | """ 77 | list_financial_event_groups(self, **kwargs) -> ApiResponse: 78 | 79 | 80 | Args: 81 | **kwargs: 82 | 83 | Returns: 84 | 85 | """ 86 | return self._request(kwargs.pop("path"), params={**kwargs}) 87 | 88 | @sp_endpoint("/finances//transactions") 89 | def list_transactions(self, **kwargs) -> ApiResponse: 90 | """ 91 | list_transactions(self, **kwargs) -> ApiResponse: 92 | 93 | Args: 94 | **kwargs: 95 | 96 | Returns: ApiResponse 97 | """ 98 | 99 | return self._request(kwargs.pop("path"), params={**kwargs}) -------------------------------------------------------------------------------- /sp_api/api/fulfillment_inbound/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/fulfillment_inbound/__init__.py -------------------------------------------------------------------------------- /sp_api/api/fulfillment_outbound/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/fulfillment_outbound/__init__.py -------------------------------------------------------------------------------- /sp_api/api/inventories/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/inventories/__init__.py -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/Error.md: -------------------------------------------------------------------------------- 1 | # Error 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **code** | **str** | An error code that identifies the type of error that occurred. | 7 | **message** | **str** | A message that describes the error condition in a human-readable form. | [optional] 8 | **details** | **str** | Additional information that can help the caller understand or fix the issue. | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/ErrorList.md: -------------------------------------------------------------------------------- 1 | # ErrorList 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/GetInventorySummariesResponse.md: -------------------------------------------------------------------------------- 1 | # GetInventorySummariesResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**GetInventorySummariesResult**](GetInventorySummariesResult.md) | | [optional] 7 | **pagination** | [**Pagination**](Pagination.md) | | [optional] 8 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/GetInventorySummariesResult.md: -------------------------------------------------------------------------------- 1 | # GetInventorySummariesResult 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **granularity** | [**Granularity**](Granularity.md) | | 7 | **inventory_summaries** | [**InventorySummaries**](InventorySummaries.md) | | 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/Granularity.md: -------------------------------------------------------------------------------- 1 | # Granularity 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **granularity_type** | **str** | The granularity type for the inventory aggregation level. | [optional] 7 | **granularity_id** | **str** | The granularity ID for the specified granularity type. When granularityType is Marketplace, specify the marketplaceId. | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/InventoryDetails.md: -------------------------------------------------------------------------------- 1 | # InventoryDetails 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **fulfillable_quantity** | **int** | The item quantity that can be picked, packed, and shipped. | [optional] 7 | **inbound_working_quantity** | **int** | The number of units in an inbound shipment for which you have notified Amazon. | [optional] 8 | **inbound_shipped_quantity** | **int** | The number of units in an inbound shipment that you have notified Amazon about and have provided a tracking number. | [optional] 9 | **inbound_receiving_quantity** | **int** | The number of units that have not yet been received at an Amazon fulfillment center for processing, but are part of an inbound shipment with some units that have already been received and processed. | [optional] 10 | **reserved_quantity** | [**ReservedQuantity**](ReservedQuantity.md) | | [optional] 11 | **researching_quantity** | [**ResearchingQuantity**](ResearchingQuantity.md) | | [optional] 12 | **unfulfillable_quantity** | [**UnfulfillableQuantity**](UnfulfillableQuantity.md) | | [optional] 13 | 14 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 15 | 16 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/InventorySummaries.md: -------------------------------------------------------------------------------- 1 | # InventorySummaries 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/InventorySummary.md: -------------------------------------------------------------------------------- 1 | # InventorySummary 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **asin** | **str** | The Amazon Standard Identification Number (ASIN) of an item. | [optional] 7 | **fn_sku** | **str** | Amazon's fulfillment network SKU identifier. | [optional] 8 | **seller_sku** | **str** | The seller SKU of the item. | [optional] 9 | **condition** | **str** | The condition of the item as described by the seller (for example, New Item). | [optional] 10 | **inventory_details** | [**InventoryDetails**](InventoryDetails.md) | | [optional] 11 | **last_updated_time** | **datetime** | The date and time that any quantity was last updated. | [optional] 12 | **product_name** | **str** | The localized language product title of the item within the specific marketplace. | [optional] 13 | **total_quantity** | **int** | The total number of units in an inbound shipment or in Amazon fulfillment centers. | [optional] 14 | 15 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 16 | 17 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/Pagination.md: -------------------------------------------------------------------------------- 1 | # Pagination 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **next_token** | **str** | A generated string used to retrieve the next page of the result. If nextToken is returned, pass the value of nextToken to the next request. If nextToken is not returned, there are no more items to return. | [optional] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/ResearchingQuantity.md: -------------------------------------------------------------------------------- 1 | # ResearchingQuantity 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **total_researching_quantity** | **int** | The total number of units currently being researched in Amazon's fulfillment network. | [optional] 7 | **researching_quantity_breakdown** | [**list[ResearchingQuantityEntry]**](ResearchingQuantityEntry.md) | A list of quantity details for items currently being researched. | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/ResearchingQuantityEntry.md: -------------------------------------------------------------------------------- 1 | # ResearchingQuantityEntry 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **name** | **str** | The duration of the research. | 7 | **quantity** | **int** | The number of units. | 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/ReservedQuantity.md: -------------------------------------------------------------------------------- 1 | # ReservedQuantity 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **total_reserved_quantity** | **int** | The total number of units in Amazon's fulfillment network that are currently being picked, packed, and shipped; or are sidelined for measurement, sampling, or other internal processes. | [optional] 7 | **pending_customer_order_quantity** | **int** | The number of units reserved for customer orders. | [optional] 8 | **pending_transshipment_quantity** | **int** | The number of units being transferred from one fulfillment center to another. | [optional] 9 | **fc_processing_quantity** | **int** | The number of units that have been sidelined at the fulfillment center for additional processing. | [optional] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | -------------------------------------------------------------------------------- /sp_api/api/inventories/docs/UnfulfillableQuantity.md: -------------------------------------------------------------------------------- 1 | # UnfulfillableQuantity 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **total_unfulfillable_quantity** | **int** | The total number of units in Amazon's fulfillment network in unsellable condition. | [optional] 7 | **customer_damaged_quantity** | **int** | The number of units in customer damaged disposition. | [optional] 8 | **warehouse_damaged_quantity** | **int** | The number of units in warehouse damaged disposition. | [optional] 9 | **distributor_damaged_quantity** | **int** | The number of units in distributor damaged disposition. | [optional] 10 | **carrier_damaged_quantity** | **int** | The number of units in carrier damaged disposition. | [optional] 11 | **defective_quantity** | **int** | The number of units in defective disposition. | [optional] 12 | **expired_quantity** | **int** | The number of units in expired disposition. | [optional] 13 | 14 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 15 | 16 | -------------------------------------------------------------------------------- /sp_api/api/listings_items/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/listings_items/__init__.py -------------------------------------------------------------------------------- /sp_api/api/listings_restrictions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/listings_restrictions/__init__.py -------------------------------------------------------------------------------- /sp_api/api/listings_restrictions/listings_restrictions.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | 3 | from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse 4 | 5 | 6 | class ListingsRestrictions(Client): 7 | """ 8 | ListingsRestrictions SP-API Client 9 | 10 | The Selling Partner API for Listings Restrictions provides programmatic access to restrictions on Amazon catalog listings. 11 | 12 | For more information, see the [Listings Restrictions API Use Case Guide](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/en-US/use-case-guides/listings-restrictions-api-use-case-guide/listings-restrictions-api-use-case-guide_2021-08-01.md). 13 | """ 14 | 15 | @sp_endpoint("/listings/2021-08-01/restrictions", method="GET") 16 | def get_listings_restrictions(self, **kwargs) -> ApiResponse: 17 | """ 18 | get_listings_restrictions(self, **kwargs) -> ApiResponse 19 | 20 | Returns listing restrictions for an item in the Amazon Catalog. 21 | 22 | Args: 23 | 24 | key asin:string | * REQUIRED The Amazon Standard Identification Number (ASIN) of the item. 25 | key conditionType:string | The condition used to filter restrictions. 26 | key sellerId:string | * REQUIRED A selling partner identifier, such as a merchant account. 27 | key marketplaceIds:array | * REQUIRED A comma-delimited list of Amazon marketplace identifiers for the request. 28 | key reasonLocale:string | A locale for reason text localization. When not provided, the default language code of the first marketplace is used. Examples: "en_US", "fr_CA", "fr_FR". Localized messages default to "en_US" when a localization is not available in the specified locale. 29 | 30 | 31 | Returns: 32 | ApiResponse 33 | """ 34 | 35 | return self._request(kwargs.pop("path"), params=kwargs) 36 | -------------------------------------------------------------------------------- /sp_api/api/merchant_fulfillment/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/merchant_fulfillment/__init__.py -------------------------------------------------------------------------------- /sp_api/api/messaging/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/messaging/__init__.py -------------------------------------------------------------------------------- /sp_api/api/notifications/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/notifications/__init__.py -------------------------------------------------------------------------------- /sp_api/api/orders/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/orders/__init__.py -------------------------------------------------------------------------------- /sp_api/api/product_fees/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/product_fees/__init__.py -------------------------------------------------------------------------------- /sp_api/api/product_type_definitions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/product_type_definitions/__init__.py -------------------------------------------------------------------------------- /sp_api/api/products/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/products/__init__.py -------------------------------------------------------------------------------- /sp_api/api/replenishment/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/replenishment/__init__.py -------------------------------------------------------------------------------- /sp_api/api/reports/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/reports/__init__.py -------------------------------------------------------------------------------- /sp_api/api/reports/docs/CancelReportResponse.md: -------------------------------------------------------------------------------- 1 | # CancelReportResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/CancelReportScheduleResponse.md: -------------------------------------------------------------------------------- 1 | # CancelReportScheduleResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/CreateReportResponse.md: -------------------------------------------------------------------------------- 1 | # CreateReportResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**CreateReportResult**](CreateReportResult.md) | | [optional] 7 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/CreateReportResult.md: -------------------------------------------------------------------------------- 1 | # CreateReportResult 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **report_id** | **str** | The identifier for the report. This identifier is unique only in combination with a seller ID. | 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/CreateReportScheduleResponse.md: -------------------------------------------------------------------------------- 1 | # CreateReportScheduleResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**CreateReportScheduleResult**](CreateReportScheduleResult.md) | | [optional] 7 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/CreateReportScheduleResult.md: -------------------------------------------------------------------------------- 1 | # CreateReportScheduleResult 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **report_schedule_id** | **str** | The identifier for the report schedule. This identifier is unique only in combination with a seller ID. | 7 | 8 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 9 | 10 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/CreateReportScheduleSpecification.md: -------------------------------------------------------------------------------- 1 | # CreateReportScheduleSpecification 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **report_type** | **str** | The report type. | 7 | **marketplace_ids** | **list[str]** | A list of marketplace identifiers for the report schedule. | 8 | **report_options** | [**ReportOptions**](ReportOptions.md) | | [optional] 9 | **period** | **str** | One of a set of predefined ISO 8601 periods that specifies how often a report should be created. | 10 | **next_report_creation_time** | **datetime** | The date and time when the schedule will create its next report, in ISO 8601 date time format. | [optional] 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/CreateReportSpecification.md: -------------------------------------------------------------------------------- 1 | # CreateReportSpecification 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **report_options** | [**ReportOptions**](ReportOptions.md) | | [optional] 7 | **report_type** | **str** | The report type. | 8 | **data_start_time** | **datetime** | The start of a date and time range, in ISO 8601 date time format, used for selecting the data to report. The default is now. The value must be prior to or equal to the current date and time. Not all report types make use of this. | [optional] 9 | **data_end_time** | **datetime** | The end of a date and time range, in ISO 8601 date time format, used for selecting the data to report. The default is now. The value must be prior to or equal to the current date and time. Not all report types make use of this. | [optional] 10 | **marketplace_ids** | **list[str]** | A list of marketplace identifiers. The report document's contents will contain data for all of the specified marketplaces, unless the report type indicates otherwise. | 11 | 12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 13 | 14 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/Error.md: -------------------------------------------------------------------------------- 1 | # Error 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **code** | **str** | An error code that identifies the type of error that occurred. | 7 | **message** | **str** | A message that describes the error condition in a human-readable form. | 8 | **details** | **str** | Additional details that can help the caller understand or fix the issue. | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/ErrorList.md: -------------------------------------------------------------------------------- 1 | # ErrorList 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/GetReportDocumentResponse.md: -------------------------------------------------------------------------------- 1 | # GetReportDocumentResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**ReportDocument**](ReportDocument.md) | | [optional] 7 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/GetReportResponse.md: -------------------------------------------------------------------------------- 1 | # GetReportResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**Report**](Report.md) | | [optional] 7 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/GetReportScheduleResponse.md: -------------------------------------------------------------------------------- 1 | # GetReportScheduleResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**ReportSchedule**](ReportSchedule.md) | | [optional] 7 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/GetReportSchedulesResponse.md: -------------------------------------------------------------------------------- 1 | # GetReportSchedulesResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**ReportScheduleList**](ReportScheduleList.md) | | [optional] 7 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/GetReportsResponse.md: -------------------------------------------------------------------------------- 1 | # GetReportsResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**ReportList**](ReportList.md) | | [optional] 7 | **next_token** | **str** | Returned when the number of results exceeds pageSize. To get the next page of results, call getReports with this token as the only parameter. | [optional] 8 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/Report.md: -------------------------------------------------------------------------------- 1 | # Report 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **marketplace_ids** | **list[str]** | A list of marketplace identifiers for the report. | [optional] 7 | **report_id** | **str** | The identifier for the report. This identifier is unique only in combination with a seller ID. | 8 | **report_type** | **str** | The report type. | 9 | **data_start_time** | **datetime** | The start of a date and time range used for selecting the data to report. | [optional] 10 | **data_end_time** | **datetime** | The end of a date and time range used for selecting the data to report. | [optional] 11 | **report_schedule_id** | **str** | The identifier of the report schedule that created this report (if any). This identifier is unique only in combination with a seller ID. | [optional] 12 | **created_time** | **datetime** | The date and time when the report was created. | 13 | **processing_status** | **str** | The processing status of the report. | 14 | **processing_start_time** | **datetime** | The date and time when the report processing started, in ISO 8601 date time format. | [optional] 15 | **processing_end_time** | **datetime** | The date and time when the report processing completed, in ISO 8601 date time format. | [optional] 16 | **report_document_id** | **str** | The identifier for the report document. Pass this into the getReportDocument operation to get the information you will need to retrieve and decrypt the report document's contents. | [optional] 17 | 18 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 19 | 20 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/ReportDocument.md: -------------------------------------------------------------------------------- 1 | # ReportDocument 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **report_document_id** | **str** | The identifier for the report document. This identifier is unique only in combination with a seller ID. | 7 | **url** | **str** | A presigned URL for the report document. This URL expires after 5 minutes. | 8 | **encryption_details** | [**ReportDocumentEncryptionDetails**](ReportDocumentEncryptionDetails.md) | | 9 | **compression_algorithm** | **str** | If present, the report document contents have been compressed with the provided algorithm. | [optional] 10 | 11 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 12 | 13 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/ReportDocumentEncryptionDetails.md: -------------------------------------------------------------------------------- 1 | # ReportDocumentEncryptionDetails 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **standard** | **str** | The encryption standard required to decrypt the document contents. | 7 | **initialization_vector** | **str** | The vector to decrypt the document contents using Cipher Block Chaining (CBC). | 8 | **key** | **str** | The encryption key used to decrypt the document contents. | 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/ReportList.md: -------------------------------------------------------------------------------- 1 | # ReportList 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/ReportOptions.md: -------------------------------------------------------------------------------- 1 | # ReportOptions 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/ReportSchedule.md: -------------------------------------------------------------------------------- 1 | # ReportSchedule 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **report_schedule_id** | **str** | The identifier for the report schedule. This identifier is unique only in combination with a seller ID. | 7 | **report_type** | **str** | The report type. | 8 | **marketplace_ids** | **list[str]** | A list of marketplace identifiers. The report document's contents will contain data for all of the specified marketplaces, unless the report type indicates otherwise. | [optional] 9 | **report_options** | [**ReportOptions**](ReportOptions.md) | | [optional] 10 | **period** | **str** | An ISO 8601 period value that indicates how often a report should be created. | 11 | **next_report_creation_time** | **datetime** | The date and time when the schedule will create its next report, in ISO 8601 date time format. | [optional] 12 | 13 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 14 | 15 | -------------------------------------------------------------------------------- /sp_api/api/reports/docs/ReportScheduleList.md: -------------------------------------------------------------------------------- 1 | # ReportScheduleList 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /sp_api/api/sales/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/sales/__init__.py -------------------------------------------------------------------------------- /sp_api/api/sellers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/sellers/__init__.py -------------------------------------------------------------------------------- /sp_api/api/sellers/sellers.py: -------------------------------------------------------------------------------- 1 | from sp_api.base.helpers import sp_endpoint 2 | from sp_api.base import Client, Marketplaces, ApiResponse 3 | 4 | 5 | class Sellers(Client): 6 | """ 7 | :link: https://github.com/amzn/selling-partner-api-docs/blob/main/references/sellers-api/sellers.md 8 | 9 | """ 10 | 11 | @sp_endpoint("/sellers/v1/marketplaceParticipations") 12 | def get_marketplace_participation(self, **kwargs) -> ApiResponse: 13 | """ 14 | get_marketplace_participation(self, **kwargs) -> ApiResponse 15 | Returns a list of marketplaces that the seller submitting the request can sell in and information about the seller's participation in those marketplaces. 16 | 17 | **Usage Plan:** 18 | 19 | ====================================== ============== 20 | Rate (requests per second) Burst 21 | ====================================== ============== 22 | .016 15 23 | ====================================== ============== 24 | 25 | For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. 26 | 27 | Examples: 28 | literal blocks:: 29 | 30 | res = Sellers().get_marketplace_participation() 31 | 32 | Args: 33 | **kwargs: 34 | 35 | Returns: 36 | GetMarketplaceParticipationsResponse: 37 | 38 | """ 39 | return self._request(kwargs.pop("path"), add_marketplace=False) 40 | 41 | @sp_endpoint("/sellers/v1/account") 42 | def get_account(self, **kwargs) -> ApiResponse: 43 | """ 44 | get_account(self, **kwargs) -> ApiResponse 45 | Returns information about a seller account and its marketplaces. 46 | 47 | **Usage Plan:** 48 | 49 | ====================================== ============== 50 | Rate (requests per second) Burst 51 | ====================================== ============== 52 | .016 15 53 | ====================================== ============== 54 | 55 | For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. 56 | 57 | Examples: 58 | literal blocks:: 59 | 60 | res = Sellers().get_account() 61 | 62 | Args: 63 | **kwargs: 64 | 65 | Returns: 66 | GetAccountResponse: 67 | 68 | """ 69 | return self._request(kwargs.pop("path"), add_marketplace=False) 70 | -------------------------------------------------------------------------------- /sp_api/api/services/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/services/__init__.py -------------------------------------------------------------------------------- /sp_api/api/shipping/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/shipping/__init__.py -------------------------------------------------------------------------------- /sp_api/api/solicitations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/solicitations/__init__.py -------------------------------------------------------------------------------- /sp_api/api/solicitations/solicitations.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | 3 | from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse 4 | 5 | 6 | class Solicitations(Client): 7 | """ 8 | Solicitations SP-API Client 9 | :link: 10 | 11 | With the Solicitations API you can build applications that send non-critical solicitations to buyers. You can get a list of solicitation types that are available for an order that you specify, then call an operation that sends a solicitation to the buyer for that order. Buyers cannot respond to solicitations sent by this API, and these solicitations do not appear in the Messaging section of Seller Central or in the recipient's Message Center. The Solicitations API returns responses that are formed according to the JSON Hypertext Application Language (HAL) standard. 12 | """ 13 | 14 | @sp_endpoint("/solicitations/v1/orders/{}", method="GET") 15 | def get_solicitation_actions_for_order( 16 | self, amazonOrderId, **kwargs 17 | ) -> ApiResponse: 18 | """ 19 | get_solicitation_actions_for_order(self, amazonOrderId, **kwargs) -> ApiResponse 20 | 21 | Returns a list of solicitation types that are available for an order that you specify. A solicitation type is represented by an actions object, which contains a path and query parameter(s). You can use the path and parameter(s) to call an operation that sends a solicitation. Currently only the productReviewAndSellerFeedbackSolicitation solicitation type is available. 22 | 23 | **Usage Plan:** 24 | 25 | ====================================== ============== 26 | Rate (requests per second) Burst 27 | ====================================== ============== 28 | 1 5 29 | ====================================== ============== 30 | 31 | For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. 32 | 33 | Args: 34 | amazonOrderId:string | * REQUIRED An Amazon order identifier. This specifies the order for which you want a list of available solicitation types. 35 | key marketplaceIds:array | * REQUIRED A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 36 | 37 | Returns: 38 | ApiResponse: 39 | """ 40 | 41 | return self._request( 42 | fill_query_params(kwargs.pop("path"), amazonOrderId), params=kwargs 43 | ) 44 | 45 | @sp_endpoint( 46 | "/solicitations/v1/orders/{}/solicitations/productReviewAndSellerFeedback", 47 | method="POST", 48 | ) 49 | def create_product_review_and_seller_feedback_solicitation( 50 | self, amazonOrderId, **kwargs 51 | ) -> ApiResponse: 52 | """ 53 | create_product_review_and_seller_feedback_solicitation(self, amazonOrderId, **kwargs) -> ApiResponse 54 | 55 | Sends a solicitation to a buyer asking for seller feedback and a product review for the specified order. Send only one productReviewAndSellerFeedback or free form proactive message per order. 56 | 57 | **Usage Plan:** 58 | 59 | ====================================== ============== 60 | Rate (requests per second) Burst 61 | ====================================== ============== 62 | 1 5 63 | ====================================== ============== 64 | 65 | For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. 66 | 67 | Args: 68 | amazonOrderId:string | * REQUIRED An Amazon order identifier. This specifies the order for which a solicitation is sent. 69 | key marketplaceIds:array | * REQUIRED A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified. 70 | 71 | Returns: 72 | ApiResponse: 73 | """ 74 | 75 | return self._request( 76 | fill_query_params(kwargs.pop("path"), amazonOrderId), params=kwargs 77 | ) 78 | -------------------------------------------------------------------------------- /sp_api/api/supply_sources/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/supply_sources/__init__.py -------------------------------------------------------------------------------- /sp_api/api/tokens/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/tokens/__init__.py -------------------------------------------------------------------------------- /sp_api/api/tokens/tokens.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | 3 | from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse 4 | 5 | 6 | class Tokens(Client): 7 | """ 8 | Tokens SP-API Client 9 | :link: 10 | 11 | The Selling Partner API for Tokens provides a secure way to access a customers's PII (Personally Identifiable Information). You can call the Tokens API to get a Restricted Data Token (RDT) for one or more restricted resources that you specify. The RDT authorizes you to make subsequent requests to access these restricted resources. 12 | """ 13 | 14 | @sp_endpoint("/tokens/2021-03-01/restrictedDataToken", method="POST") 15 | def create_restricted_data_token(self, **kwargs) -> ApiResponse: 16 | """ 17 | create_restricted_data_token(self, **kwargs) -> ApiResponse 18 | 19 | Returns a Restricted Data Token (RDT) for one or more restricted resources that you specify. A restricted resource is the HTTP method and path from a restricted operation that returns Personally Identifiable Information (PII). See the Tokens API Use Case Guide for a list of restricted operations. Use the RDT returned here as the access token in subsequent calls to the corresponding restricted operations. 20 | 21 | The path of a restricted resource can be: 22 | - A specific path containing a seller's order ID, for example ```/orders/v0/orders/902-3159896-1390916/address```. The returned RDT authorizes a subsequent call to the getOrderAddress operation of the Orders API for that specific order only. For example, ```GET /orders/v0/orders/902-3159896-1390916/address```. 23 | - A generic path that does not contain a seller's order ID, for example```/orders/v0/orders/{orderId}/address```). The returned RDT authorizes subsequent calls to the getOrderAddress operation for *any* of a seller's order IDs. For example, ```GET /orders/v0/orders/902-3159896-1390916/address``` and ```GET /orders/v0/orders/483-3488972-0896720/address``` 24 | 25 | **Usage Plans:** 26 | 27 | ====================================== ============== 28 | Rate (requests per second) Burst 29 | ====================================== ============== 30 | 1 10 31 | ====================================== ============== 32 | 33 | The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation. Rate limits for some selling partners will vary from the default rate and burst shown in the table above. For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. 34 | 35 | Examples: 36 | literal blocks:: 37 | 38 | Tokens().create_restricted_data_token(restrictedResources=[ 39 | { 40 | "method": "GET", 41 | "path": "/orders/v0/orders", 42 | "dataElements": ["buyerInfo", "shippingAddress"] 43 | } 44 | ]) 45 | 46 | Args: 47 | body: { 48 | "targetApplication": "string", 49 | "restrictedResources": [ 50 | { 51 | "method": "GET", 52 | "path": "string", 53 | "dataElements": [ 54 | "string" 55 | ] 56 | } 57 | ] 58 | } 59 | 60 | Returns: 61 | ApiResponse: 62 | """ 63 | 64 | return self._request(kwargs.pop("path"), data=kwargs) 65 | -------------------------------------------------------------------------------- /sp_api/api/upload/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/upload/__init__.py -------------------------------------------------------------------------------- /sp_api/api/upload/docs/CreateUploadDestinationResponse.md: -------------------------------------------------------------------------------- 1 | # CreateUploadDestinationResponse 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **payload** | [**UploadDestination**](UploadDestination.md) | | [optional] 7 | **errors** | [**ErrorList**](ErrorList.md) | | [optional] 8 | 9 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 10 | 11 | -------------------------------------------------------------------------------- /sp_api/api/upload/docs/Error.md: -------------------------------------------------------------------------------- 1 | # Error 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **code** | **str** | An error code that identifies the type of error that occurred. | 7 | **message** | **str** | A message that describes the error condition in a human-readable form. | 8 | **details** | **str** | Additional details that can help the caller understand or fix the issue. | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sp_api/api/upload/docs/ErrorList.md: -------------------------------------------------------------------------------- 1 | # ErrorList 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | 7 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 8 | 9 | -------------------------------------------------------------------------------- /sp_api/api/upload/docs/UploadDestination.md: -------------------------------------------------------------------------------- 1 | # UploadDestination 2 | 3 | ## Properties 4 | Name | Type | Description | Notes 5 | ------------ | ------------- | ------------- | ------------- 6 | **upload_destination_id** | **str** | The unique identifier for the upload destination. | [optional] 7 | **url** | **str** | The URL for the upload destination. | [optional] 8 | **headers** | **object** | The headers to include in the upload request. | [optional] 9 | 10 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) 11 | 12 | -------------------------------------------------------------------------------- /sp_api/api/upload/upload.py: -------------------------------------------------------------------------------- 1 | from sp_api.base import Client, sp_endpoint 2 | from sp_api.base.helpers import create_md5 3 | import urllib.parse 4 | 5 | 6 | class Upload(Client): 7 | @sp_endpoint("/uploads/2020-11-01/uploadDestinations/{}", method="POST") 8 | def upload_document(self, resource, file, content_type="application/pdf", **kwargs): 9 | md5 = urllib.parse.quote(create_md5(file)) 10 | kwargs.update( 11 | { 12 | "contentMD5": md5, 13 | "contentType": kwargs.pop("contentType", content_type), 14 | "marketplaceIds": self.marketplace_id, 15 | } 16 | ) 17 | return self._request(kwargs.pop("path").format(resource), params=kwargs) 18 | -------------------------------------------------------------------------------- /sp_api/api/vendor_direct_fulfillment_inventory/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/vendor_direct_fulfillment_inventory/__init__.py -------------------------------------------------------------------------------- /sp_api/api/vendor_direct_fulfillment_inventory/vendor_direct_fulfillment_inventory.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | 3 | from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse 4 | 5 | 6 | class VendorDirectFulfillmentInventory(Client): 7 | """ 8 | VendorDirectFulfillmentInventory SP-API Client 9 | :link: 10 | 11 | The Selling Partner API for Direct Fulfillment Inventory Updates provides programmatic access to a direct fulfillment vendor's inventory updates. 12 | """ 13 | 14 | @sp_endpoint( 15 | "/vendor/directFulfillment/inventory/v1/warehouses/{}/items", method="POST" 16 | ) 17 | def submit_inventory_update(self, warehouseId, **kwargs) -> ApiResponse: 18 | """ 19 | submit_inventory_update(self, warehouseId, **kwargs) -> ApiResponse 20 | 21 | Submits inventory updates for the specified warehouse for either a partial or full feed of inventory items. 22 | 23 | **Usage Plans:** 24 | 25 | ====================================== ============== 26 | Rate (requests per second) Burst 27 | ====================================== ============== 28 | 10 10 29 | ====================================== ============== 30 | 31 | The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation. Rate limits for some selling partners will vary from the default rate and burst shown in the table above. For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. 32 | 33 | Args: 34 | warehouseId:string | * REQUIRED Identifier for the warehouse for which to update inventory. 35 | body: { 36 | "inventory": { 37 | "sellingParty": { 38 | "partyId": "string" 39 | }, 40 | "isFullUpdate": true, 41 | "items": [ 42 | { 43 | "buyerProductIdentifier": "string", 44 | "vendorProductIdentifier": "string", 45 | "availableQuantity": { 46 | "amount": 0, 47 | "unitOfMeasure": "string" 48 | }, 49 | "isObsolete": true 50 | } 51 | ] 52 | } 53 | } 54 | 55 | Returns: 56 | ApiResponse: 57 | """ 58 | 59 | return self._request( 60 | fill_query_params(kwargs.pop("path"), warehouseId), 61 | data=kwargs, 62 | add_marketplace=False, 63 | ) 64 | -------------------------------------------------------------------------------- /sp_api/api/vendor_direct_fulfillment_orders/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/vendor_direct_fulfillment_orders/__init__.py -------------------------------------------------------------------------------- /sp_api/api/vendor_direct_fulfillment_payments/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/vendor_direct_fulfillment_payments/__init__.py -------------------------------------------------------------------------------- /sp_api/api/vendor_direct_fulfillment_shipping/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/vendor_direct_fulfillment_shipping/__init__.py -------------------------------------------------------------------------------- /sp_api/api/vendor_direct_fulfillment_transactions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/vendor_direct_fulfillment_transactions/__init__.py -------------------------------------------------------------------------------- /sp_api/api/vendor_direct_fulfillment_transactions/vendor_direct_fulfillment_transactions.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | 3 | from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse 4 | 5 | 6 | class VendorDirectFulfillmentTransactions(Client): 7 | """ 8 | VendorDirectFulfillmentTransactions SP-API Client 9 | :link: 10 | 11 | The Selling Partner API for Direct Fulfillment Transaction Status provides programmatic access to a direct fulfillment vendor's transaction status. 12 | """ 13 | 14 | @sp_endpoint( 15 | "/vendor/directFulfillment/transactions/v1/transactions/{}", method="GET" 16 | ) 17 | def get_transaction_status(self, transactionId, **kwargs) -> ApiResponse: 18 | """ 19 | get_transaction_status(self, transactionId, **kwargs) -> ApiResponse 20 | 21 | Returns the status of the transaction indicated by the specified transactionId. 22 | 23 | **Usage Plans:** 24 | 25 | ====================================== ============== 26 | Rate (requests per second) Burst 27 | ====================================== ============== 28 | 10 10 29 | ====================================== ============== 30 | 31 | The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation. Rate limits for some selling partners will vary from the default rate and burst shown in the table above. For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. 32 | 33 | Args: 34 | transactionId:string | * REQUIRED Previously returned in the response to the POST request of a specific transaction. 35 | 36 | Returns: 37 | ApiResponse: 38 | """ 39 | 40 | return self._request( 41 | fill_query_params(kwargs.pop("path"), transactionId), params=kwargs 42 | ) 43 | -------------------------------------------------------------------------------- /sp_api/api/vendor_invoices/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/vendor_invoices/__init__.py -------------------------------------------------------------------------------- /sp_api/api/vendor_orders/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/vendor_orders/__init__.py -------------------------------------------------------------------------------- /sp_api/api/vendor_shipments/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/vendor_shipments/__init__.py -------------------------------------------------------------------------------- /sp_api/api/vendor_transaction_status/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/sp_api/api/vendor_transaction_status/__init__.py -------------------------------------------------------------------------------- /sp_api/api/vendor_transaction_status/vendor_transaction_status.py: -------------------------------------------------------------------------------- 1 | import urllib.parse 2 | 3 | from sp_api.base import Client, sp_endpoint, fill_query_params, ApiResponse 4 | 5 | 6 | class VendorTransactionStatus(Client): 7 | """ 8 | VendorTransactionStatus SP-API Client 9 | :link: 10 | 11 | The Selling Partner API for Retail Procurement Transaction Status provides programmatic access to status information on specific asynchronous POST transactions for vendors. 12 | """ 13 | 14 | @sp_endpoint("/vendor/transactions/v1/transactions/{}", method="GET") 15 | def get_transaction(self, transactionId, **kwargs) -> ApiResponse: 16 | """ 17 | get_transaction(self, transactionId, **kwargs) -> ApiResponse 18 | 19 | Returns the status of the transaction that you specify. 20 | 21 | **Usage Plans:** 22 | 23 | ====================================== ============== 24 | Rate (requests per second) Burst 25 | ====================================== ============== 26 | 10 10 27 | ====================================== ============== 28 | 29 | The x-amzn-RateLimit-Limit response header returns the usage plan rate limits that were applied to the requested operation. Rate limits for some selling partners will vary from the default rate and burst shown in the table above. For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. 30 | 31 | Args: 32 | transactionId:string | * REQUIRED The GUID provided by Amazon in the 'transactionId' field in response to the post request of a specific transaction. 33 | 34 | Returns: 35 | ApiResponse: 36 | """ 37 | 38 | return self._request( 39 | fill_query_params(kwargs.pop("path"), transactionId), params=kwargs 40 | ) 41 | -------------------------------------------------------------------------------- /sp_api/auth/__init__.py: -------------------------------------------------------------------------------- 1 | from .access_token_client import AccessTokenClient 2 | from .access_token_response import AccessTokenResponse 3 | from .credentials import Credentials 4 | 5 | __all__ = [ 6 | "AccessTokenResponse", 7 | "AccessTokenClient", 8 | "Credentials", 9 | ] 10 | -------------------------------------------------------------------------------- /sp_api/auth/access_token_response.py: -------------------------------------------------------------------------------- 1 | class AccessTokenResponse: 2 | def __init__(self, **kwargs): 3 | self.access_token = kwargs.get("access_token") 4 | self.refresh_token = kwargs.get("refresh_token") 5 | self.expires_in = kwargs.get("expires_in") 6 | self.token_type = kwargs.get("token_type") 7 | -------------------------------------------------------------------------------- /sp_api/auth/credentials.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | 4 | class Credentials: 5 | def __init__(self, refresh_token, credentials): 6 | self.client_id = credentials.lwa_app_id 7 | self.client_secret = credentials.lwa_client_secret 8 | self.refresh_token = refresh_token or credentials.refresh_token 9 | -------------------------------------------------------------------------------- /sp_api/auth/exceptions.py: -------------------------------------------------------------------------------- 1 | class AuthorizationError(Exception): 2 | """ 3 | Authorization Error 4 | 5 | Parameters: 6 | 7 | error_code: str Error code from amazon auth api 8 | error_msg: str Error sm 9 | status_code: integer Response status code from amazon auth api 10 | """ 11 | 12 | def __init__(self, error_code, error_msg, status_code): 13 | self.error_code = error_code 14 | self.message = error_msg 15 | self.status_code = status_code 16 | -------------------------------------------------------------------------------- /sp_api/base/ApiResponse.py: -------------------------------------------------------------------------------- 1 | import pprint 2 | 3 | 4 | class ApiResponse: 5 | """ 6 | Api Response 7 | 8 | Wrapper around all responses from the API. 9 | 10 | Examples: 11 | literal blocks:: 12 | 13 | response = Orders().get_orders(CreatedAfter='TEST_CASE_200', MarketplaceIds=["ATVPDKIKX0DER"]) 14 | 15 | print(response.payload) # original response data 16 | # Access one of `payload`s properties using `__getattr__` 17 | print(response.Orders) # Array of orders 18 | # Access one of `payload`s properties using `__call__` 19 | print(response('Orders')) # Array of orders 20 | # Shorthand for response.payload 21 | print(response()) # original response data 22 | 23 | Args: 24 | payload: dict or list | original response from Amazon 25 | errors: any | contains possible error messages 26 | pagination: any | information about an endpoints pagination 27 | headers: any | headers returned by the API 28 | rate_limit: number | The `x-amzn-RateLimit-Limit` header, if available 29 | next_token: str | The next token used to retrieve the next page, if any 30 | kwargs: any 31 | 32 | """ 33 | 34 | def __init__( 35 | self, 36 | payload=None, 37 | errors=None, 38 | pagination=None, 39 | headers=None, 40 | nextToken=None, 41 | **kwargs 42 | ): 43 | self.payload = payload or kwargs 44 | self.errors = errors 45 | self.pagination = pagination 46 | self.headers = headers 47 | self.rate_limit = headers.get("x-amzn-RateLimit-Limit") 48 | try: 49 | self.next_token = ( 50 | nextToken 51 | or self.payload.get("pagination", {}).get("nextToken", None) 52 | or self.payload.get("NextToken", None) 53 | or self.pagination.get("nextToken", None) 54 | or self.payload.get("nextPageToken", None) 55 | or self.payload.get("nextToken", None) 56 | ) 57 | 58 | except AttributeError: 59 | self.next_token = None 60 | if kwargs != self.payload: 61 | self.kwargs = kwargs 62 | 63 | def __str__(self): 64 | return pprint.pformat(vars(self)) 65 | 66 | def __call__(self, item=None, **kwargs): 67 | if not item: 68 | return self.payload 69 | return self.payload.get(item) 70 | 71 | def __getattr__(self, item): 72 | return self.payload.get(item) 73 | -------------------------------------------------------------------------------- /sp_api/base/InventoryEnums.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class InventoryGranularity(str, Enum): 5 | MARKETPLACE = "Marketplace" 6 | -------------------------------------------------------------------------------- /sp_api/base/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_client import BaseClient 2 | from .client import Client 3 | from .helpers import ( 4 | fill_query_params, 5 | sp_endpoint, 6 | create_md5, 7 | nest_dict, 8 | _nest_dict_rec, 9 | deprecated, 10 | ) 11 | from .marketplaces import Marketplaces 12 | from .exceptions import SellingApiException 13 | from .exceptions import SellingApiBadRequestException 14 | from .exceptions import SellingApiNotFoundException 15 | from .exceptions import SellingApiForbiddenException 16 | from .exceptions import SellingApiRequestThrottledException 17 | from .exceptions import SellingApiServerException 18 | from .exceptions import SellingApiTemporarilyUnavailableException 19 | from .exceptions import SellingApiTooLargeException 20 | from .exceptions import SellingApiStateConflictException 21 | from .exceptions import SellingApiUnsupportedFormatException 22 | from .schedules import Schedules 23 | from .report_status import ReportStatus 24 | from .sales_enum import FirstDayOfWeek, Granularity, BuyerType 25 | from .fulfillment_channel import FulfillmentChannel 26 | from .included_data import ( 27 | IncludedData, 28 | ListingItemsIncludedData, 29 | CatalogItemsIncludedData, 30 | ) 31 | from .notifications import NotificationType 32 | from .credential_provider import CredentialProvider, MissingCredentials 33 | from .ApiResponse import ApiResponse 34 | from .processing_status import ProcessingStatus 35 | from .reportTypes import ReportType 36 | from .feedTypes import FeedType 37 | from sp_api.auth import AccessTokenClient, Credentials 38 | from sp_api.auth.exceptions import AuthorizationError 39 | from sp_api.base.inegibility_reasons import IneligibilityReasonList 40 | from .marketplaces import AwsEnv 41 | 42 | 43 | __all__ = [ 44 | "Credentials", 45 | "AuthorizationError", 46 | "AccessTokenClient", 47 | "ReportType", 48 | "FeedType", 49 | "ProcessingStatus", 50 | "ApiResponse", 51 | "Client", 52 | "BaseClient", 53 | "Marketplaces", 54 | "fill_query_params", 55 | "sp_endpoint", 56 | "SellingApiException", 57 | "SellingApiBadRequestException", 58 | "SellingApiNotFoundException", 59 | "SellingApiServerException", 60 | "SellingApiForbiddenException", 61 | "SellingApiBadRequestException", 62 | "SellingApiRequestThrottledException", 63 | "SellingApiTemporarilyUnavailableException", 64 | "SellingApiTooLargeException", 65 | "SellingApiStateConflictException", 66 | "SellingApiUnsupportedFormatException", 67 | "Schedules", 68 | "ReportStatus", 69 | "FirstDayOfWeek", 70 | "Granularity", 71 | "BuyerType", 72 | "FulfillmentChannel", 73 | "deprecated", 74 | "NotificationType", 75 | "CredentialProvider", 76 | "MissingCredentials", 77 | "nest_dict", 78 | "_nest_dict_rec", 79 | "IneligibilityReasonList", 80 | "IncludedData", 81 | "ListingItemsIncludedData", 82 | "CatalogItemsIncludedData", 83 | "AwsEnv", 84 | ] 85 | -------------------------------------------------------------------------------- /sp_api/base/base_client.py: -------------------------------------------------------------------------------- 1 | from sp_api.__version__ import __version__ 2 | 3 | 4 | class BaseClient: 5 | scheme = "https://" 6 | method = "GET" 7 | content_type = "application/x-www-form-urlencoded;charset=UTF-8" 8 | user_agent = f"python-sp-api-{__version__}" 9 | -------------------------------------------------------------------------------- /sp_api/base/feedTypes.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class FeedType(str, Enum): 5 | JSON_LISTINGS_FEED = "JSON_LISTINGS_FEED" 6 | POST_PRODUCT_DATA = "POST_PRODUCT_DATA" 7 | POST_INVENTORY_AVAILABILITY_DATA = "POST_INVENTORY_AVAILABILITY_DATA" 8 | POST_PRODUCT_OVERRIDES_DATA = "POST_PRODUCT_OVERRIDES_DATA" 9 | POST_PRODUCT_PRICING_DATA = "POST_PRODUCT_PRICING_DATA" 10 | POST_PRODUCT_IMAGE_DATA = "POST_PRODUCT_IMAGE_DATA" 11 | POST_PRODUCT_RELATIONSHIP_DATA = "POST_PRODUCT_RELATIONSHIP_DATA" 12 | POST_FLAT_FILE_INVLOADER_DATA = "POST_FLAT_FILE_INVLOADER_DATA" 13 | POST_FLAT_FILE_LISTINGS_DATA = "POST_FLAT_FILE_LISTINGS_DATA" 14 | POST_FLAT_FILE_BOOKLOADER_DATA = "POST_FLAT_FILE_BOOKLOADER_DATA" 15 | POST_FLAT_FILE_CONVERGENCE_LISTINGS_DATA = ( 16 | "POST_FLAT_FILE_CONVERGENCE_LISTINGS_DATA" 17 | ) 18 | POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA = ( 19 | "POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA" 20 | ) 21 | POST_UIEE_BOOKLOADER_DATA = "POST_UIEE_BOOKLOADER_DATA" 22 | POST_STD_ACES_DATA = "POST_STD_ACES_DATA" 23 | POST_ORDER_ACKNOWLEDGEMENT_DATA = "POST_ORDER_ACKNOWLEDGEMENT_DATA" 24 | POST_PAYMENT_ADJUSTMENT_DATA = "POST_PAYMENT_ADJUSTMENT_DATA" 25 | POST_ORDER_FULFILLMENT_DATA = "POST_ORDER_FULFILLMENT_DATA" 26 | POST_INVOICE_CONFIRMATION_DATA = "POST_INVOICE_CONFIRMATION_DATA" 27 | POST_EXPECTED_SHIP_DATE_SOD = "POST_EXPECTED_SHIP_DATE_SOD" 28 | POST_FLAT_FILE_ORDER_ACKNOWLEDGEMENT_DATA = ( 29 | "POST_FLAT_FILE_ORDER_ACKNOWLEDGEMENT_DATA" 30 | ) 31 | POST_FLAT_FILE_PAYMENT_ADJUSTMENT_DATA = "POST_FLAT_FILE_PAYMENT_ADJUSTMENT_DATA" 32 | POST_FLAT_FILE_FULFILLMENT_DATA = "POST_FLAT_FILE_FULFILLMENT_DATA" 33 | POST_EXPECTED_SHIP_DATE_SOD_FLAT_FILE = "POST_EXPECTED_SHIP_DATE_SOD_FLAT_FILE" 34 | POST_FULFILLMENT_ORDER_REQUEST_DATA = "POST_FULFILLMENT_ORDER_REQUEST_DATA" 35 | POST_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA = ( 36 | "POST_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA" 37 | ) 38 | POST_FBA_INBOUND_CARTON_CONTENTS = "POST_FBA_INBOUND_CARTON_CONTENTS" 39 | POST_FLAT_FILE_FULFILLMENT_ORDER_REQUEST_DATA = ( 40 | "POST_FLAT_FILE_FULFILLMENT_ORDER_REQUEST_DATA" 41 | ) 42 | POST_FLAT_FILE_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA = ( 43 | "POST_FLAT_FILE_FULFILLMENT_ORDER_CANCELLATION_REQUEST_DATA" 44 | ) 45 | POST_FLAT_FILE_FBA_CREATE_INBOUND_PLAN = "POST_FLAT_FILE_FBA_CREATE_INBOUND_PLAN" 46 | POST_FLAT_FILE_FBA_CREATE_REMOVAL = "POST_FLAT_FILE_FBA_CREATE_REMOVAL" 47 | RFQ_UPLOAD_FEED = "RFQ_UPLOAD_FEED" 48 | POST_EASYSHIP_DOCUMENTS = "POST_EASYSHIP_DOCUMENTS" 49 | -------------------------------------------------------------------------------- /sp_api/base/fulfillment_channel.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class FulfillmentChannel(str, Enum): 5 | AFN = "AFN" 6 | MFN = "MFN" 7 | -------------------------------------------------------------------------------- /sp_api/base/helpers.py: -------------------------------------------------------------------------------- 1 | from io import BytesIO 2 | import hashlib 3 | import base64 4 | import warnings 5 | import functools 6 | from urllib import parse 7 | 8 | 9 | def fill_query_params(query, *args): 10 | return query.format(*[parse.quote(arg, safe="") for arg in args]) 11 | 12 | 13 | def sp_endpoint(path, method="GET"): 14 | def decorator(function): 15 | @functools.wraps(function) 16 | def wrapper(*args, **kwargs): 17 | kwargs.update({"path": path, "method": method}) 18 | return function(*args, **kwargs) 19 | 20 | return wrapper 21 | 22 | return decorator 23 | 24 | 25 | def create_md5(file): 26 | hash_md5 = hashlib.md5() 27 | if isinstance(file, BytesIO): 28 | for chunk in iter(lambda: file.read(4096), b""): 29 | hash_md5.update(chunk) 30 | file.seek(0) 31 | return base64.b64encode(hash_md5.digest()).decode() 32 | if isinstance(file, str): 33 | with open(file, "rb") as f: 34 | for chunk in iter(lambda: f.read(4096), b""): 35 | hash_md5.update(chunk) 36 | return base64.b64encode(hash_md5.digest()).decode() 37 | for chunk in iter(lambda: file.read(4096), b""): 38 | hash_md5.update(chunk) 39 | return base64.b64encode(hash_md5.digest()).decode() 40 | 41 | 42 | def nest_dict(flat: dict()): 43 | """ 44 | Convert flat dictionary to nested dictionary. 45 | 46 | Input 47 | { 48 | "AmazonOrderId":1, 49 | "ShipFromAddress.Name" : "Seller", 50 | "ShipFromAddress.AddressLine1": "Street", 51 | } 52 | 53 | Output 54 | { 55 | "AmazonOrderId":1, 56 | "ShipFromAddress.: { 57 | "Name" : "Seller", 58 | "AddressLine1": "Street", 59 | } 60 | } 61 | 62 | 63 | Args: 64 | flat:dict(): 65 | 66 | Returns: 67 | nested:dict(): 68 | """ 69 | 70 | result = {} 71 | for k, v in flat.items(): 72 | _nest_dict_rec(k, v, result) 73 | return result 74 | 75 | 76 | def _nest_dict_rec(k, v, out): 77 | k, *rest = k.split(".", 1) 78 | if rest: 79 | _nest_dict_rec(rest[0], v, out.setdefault(k, {})) 80 | else: 81 | out[k] = v 82 | 83 | 84 | def deprecated(func): 85 | """This is a decorator which can be used to mark functions 86 | as deprecated. It will result in a warning being emitted 87 | when the function is used.""" 88 | 89 | @functools.wraps(func) 90 | def new_func(*args, **kwargs): 91 | warnings.simplefilter("always", DeprecationWarning) # turn off filter 92 | warnings.warn( 93 | "Call to deprecated function {}.".format(func.__name__), 94 | category=DeprecationWarning, 95 | stacklevel=2, 96 | ) 97 | warnings.simplefilter("default", DeprecationWarning) # reset filter 98 | return func(*args, **kwargs) 99 | 100 | return new_func 101 | -------------------------------------------------------------------------------- /sp_api/base/identifiersType.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class IdentifiersType(str, Enum): 5 | ASIN = "ASIN" # doc: Amazon Standard Identification Number. 6 | EAN = "EAN" # doc: European Article Number. 7 | GTIN = "GTIN" # doc: Global Trade Item Number. 8 | ISBN = "ISBN" # doc: International Standard Book Number. 9 | JAN = "JAN" # doc: Japanese Article Number. 10 | MINSAN = "MINSAN" # doc: Minsan Code. 11 | SKU = "SKU" # doc: Stock Keeping Unit, a seller-specified identifier for an Amazon listing. Note: Must be accompanied by sellerId. 12 | UPC = "UPC" # doc: Universal Product Code. 13 | -------------------------------------------------------------------------------- /sp_api/base/included_data.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class IncludedData(str, Enum): 5 | """ 6 | Use ListingItemsIncludedData or CatalogItemsIncludedData instead. 7 | """ 8 | 9 | #: Summary details of the listing item. 10 | SUMMARIES = "summaries" 11 | 12 | #: JSON object containing structured listing item attribute data keyed by attribute name. 13 | ATTRIBUTES = "attributes" 14 | 15 | #: Issues associated with the listing item. 16 | ISSUES = "issues" 17 | 18 | #: Current offers for the listing item. 19 | OFFERS = "offers" 20 | 21 | #: Fulfillment availability details for the listing item. 22 | FULFILLMENT_AVAILABILITY = "fulfillmentAvailability" 23 | 24 | #: Vendor procurement details for the listing item. 25 | PROCUREMENT = "procurement" 26 | 27 | #: Dimensions for an item in the Amazon catalog. 28 | DIMENSIONS = "dimensions" 29 | 30 | #: Identifiers associated with the item in the Amazon catalog, such as UPC and EAN identifiers. 31 | IDENTIFIERS = "identifiers" 32 | 33 | #: Images for an item in the Amazon catalog. 34 | IMAGES = "images" 35 | 36 | #: Product types associated with the Amazon catalog item. 37 | PRODUCT_TYPES = "productTypes" 38 | 39 | #: Relationship details of an Amazon catalog item (for example, variations). 40 | RELATIONSHIPS = "relationships" 41 | 42 | #: Sales ranks of an Amazon catalog item. 43 | SALES_RANKS = "salesRanks" 44 | 45 | #: Vendor details associated with an Amazon catalog item. Vendor details are available to vendors only. 46 | VENDOR_DETAILS = "vendorDetails" 47 | 48 | 49 | class ListingItemsIncludedData(str, Enum): 50 | 51 | #: Summary details of the listing item. 52 | SUMMARIES = "summaries" 53 | 54 | #: JSON object containing structured listing item attribute data keyed by attribute name. 55 | ATTRIBUTES = "attributes" 56 | 57 | #: Issues associated with the listing item. 58 | ISSUES = "issues" 59 | 60 | #: Current offers for the listing item. 61 | OFFERS = "offers" 62 | 63 | #: Fulfillment availability details for the listing item. 64 | FULFILLMENT_AVAILABILITY = "fulfillmentAvailability" 65 | 66 | #: Vendor procurement details for the listing item. 67 | PROCUREMENT = "procurement" 68 | 69 | 70 | class CatalogItemsIncludedData(str, Enum): 71 | 72 | #: A JSON object containing structured item attribute data keyed by attribute name. 73 | ATTRIBUTES = "attributes" 74 | 75 | #: Dimensions for an item in the Amazon catalog. 76 | DIMENSIONS = "dimensions" 77 | 78 | #: Identifiers associated with the item in the Amazon catalog, such as UPC and EAN identifiers. 79 | IDENTIFIERS = "identifiers" 80 | 81 | #: Images for an item in the Amazon catalog. 82 | IMAGES = "images" 83 | 84 | #: Product types associated with the Amazon catalog item. 85 | PRODUCT_TYPES = "productTypes" 86 | 87 | #: Relationship details of an Amazon catalog item (for example, variations). 88 | RELATIONSHIPS = "relationships" 89 | 90 | #: Sales ranks of an Amazon catalog item. 91 | SALES_RANKS = "salesRanks" 92 | 93 | #: Summary details of an Amazon catalog item. 94 | SUMMARIES = "summaries" 95 | 96 | #: Vendor details associated with an Amazon catalog item. Vendor details are available to vendors only. 97 | VENDOR_DETAILS = "vendorDetails" 98 | -------------------------------------------------------------------------------- /sp_api/base/processing_status.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class ProcessingStatus(str, Enum): 5 | CANCELLED = "CANCELLED" 6 | DONE = "DONE" 7 | FATAL = "FATAL" 8 | IN_PROGRESS = "IN_PROGRESS" 9 | IN_QUEUE = "IN_QUEUE" 10 | -------------------------------------------------------------------------------- /sp_api/base/report_status.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class ReportStatus(str, Enum): 5 | CANCELLED = "CANCELLED" 6 | DONE = "DONE" 7 | FATAL = "FATAL" 8 | IN_PROGRESS = "IN_PROGRESS" 9 | IN_QUEUE = "IN_QUEUE" 10 | -------------------------------------------------------------------------------- /sp_api/base/sales_enum.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class Granularity(str, Enum): 5 | HOUR = "Hour" 6 | DAY = "Day" 7 | WEEK = "Week" 8 | MONTH = "Month" 9 | YEAR = "Year" 10 | TOTAL = "Total" 11 | 12 | 13 | class BuyerType(str, Enum): 14 | B2B = "B2B" # doc: Business to business. 15 | B2C = "B2C" # doc: Business to customer. 16 | ALL = "All" # doc: Both of above 17 | 18 | 19 | class FirstDayOfWeek(str, Enum): 20 | MO = "Monday" 21 | SU = "Sunday" 22 | -------------------------------------------------------------------------------- /sp_api/base/schedules.py: -------------------------------------------------------------------------------- 1 | from enum import Enum 2 | 3 | 4 | class Schedules(str, Enum): 5 | MINUTES_5 = "PT5M" 6 | MINUTES_15 = "PT15M" 7 | MINUTES_30 = "PT30M" 8 | HOUR_1 = "PT1H" 9 | HOURS_2 = "PT2H" 10 | HOURS_4 = "PT4H" 11 | HOURS_8 = "PT8H" 12 | HOURS_12 = "PT12H" 13 | DAY_1 = "P1D" 14 | DAYS_2 = "P2D" 15 | DAYS_3 = "P3D" 16 | HOURS_84 = "PT84H" 17 | DAYS_7 = "P7D" 18 | DAYS_14 = "P14D" 19 | DAYS_15 = "P15D" 20 | DAYS_18 = "P18D" 21 | DAYS_30 = "P30D" 22 | MONTH_1 = "P1M" 23 | -------------------------------------------------------------------------------- /sp_api/util/__init__.py: -------------------------------------------------------------------------------- 1 | from .retry import retry, sp_retry, throttle_retry 2 | from .load_all_pages import load_all_pages 3 | from .key_maker import KeyMaker 4 | from .load_date_bound import load_date_bound 5 | 6 | __all__ = [ 7 | "retry", 8 | "sp_retry", 9 | "throttle_retry", 10 | "load_all_pages", 11 | "KeyMaker", 12 | "load_date_bound", 13 | ] 14 | -------------------------------------------------------------------------------- /sp_api/util/key_maker.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | 4 | class KeyMaker: 5 | """ 6 | Map the different keys amazon uses for the same property to a single one 7 | 8 | 9 | Examples: 10 | literal blocks:: 11 | 12 | key_mapping = { 13 | 'sku': ['seller_sku', 'sellerSku'], 14 | 'title': ['product_name'] 15 | } 16 | 17 | res = KeyMaker(key_mapping, deep=True).convert_keys({ 18 | 'seller_sku': 1, 19 | 'product_name': { 20 | 'sellerSku': [ 21 | 'seller_sku', 22 | 3, 23 | { 24 | 'sellerSku': 22, 25 | 'product_name': { 26 | 'title': 'Foo', 27 | 'x': 'bar' 28 | } 29 | } 30 | ] 31 | } 32 | }) 33 | 34 | res 35 | 36 | {'sku': 1, 'title': {'sku': ['seller_sku', 3, {'sku': 22, 'title': {'title': 'Foo', 'x': 'bar'}}]}} 37 | """ 38 | 39 | def __init__(self, key_mapping=None, *, deep=True): 40 | if key_mapping is None: 41 | key_mapping = {} 42 | self.key_mapping = key_mapping 43 | self.deep = deep 44 | 45 | def convert_keys(self, data: dict or list): 46 | """ 47 | convert_keys(self, data: dict or list) 48 | 49 | Map the different keys amazon uses for the same property to a single one 50 | 51 | 52 | Args: 53 | data: [dict] or dict 54 | 55 | Returns: 56 | Transformed data 57 | """ 58 | if isinstance(data, list): 59 | return [self.convert_keys(d) for d in data] 60 | if not isinstance(data, dict): 61 | return data 62 | return { 63 | self._map_to_key_mapping(k): self.convert_keys(v) if self.deep else v 64 | for k, v in data.items() 65 | } 66 | 67 | def _map_to_key_mapping(self, key): 68 | for k, v in self.key_mapping.items(): 69 | if key in v or k == key: 70 | return k 71 | return self._replace_dash(key) 72 | 73 | @staticmethod 74 | def _replace_dash(key): 75 | return key[0].lower() + "".join( 76 | word.title() if i > 0 else word 77 | for i, word in enumerate(re.sub(r"[-\s]", "_", key[1:]).split("_")) 78 | ) 79 | -------------------------------------------------------------------------------- /sp_api/util/load_all_pages.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | def make_sleep_time(rate_limit, use_rate_limit_header, throttle_by_seconds): 5 | if use_rate_limit_header and rate_limit: 6 | return 1 / float(rate_limit) 7 | return throttle_by_seconds 8 | 9 | 10 | def load_all_pages( 11 | throttle_by_seconds: float = 2, 12 | next_token_param="NextToken", 13 | use_rate_limit_header: bool = False, 14 | extras: dict = None, 15 | next_token_only: bool = False 16 | ): 17 | """ 18 | Load all pages if a next token is returned 19 | 20 | Args: 21 | throttle_by_seconds: float 22 | next_token_param: str | The param amazon expects to hold the next token 23 | use_rate_limit_header: if the function should try to use amazon's rate limit header 24 | extras: additional data to be sent with NextToken, e.g `dict(QueryType='NEXT_TOKEN')` for `FulfillmentInbound` 25 | next_token_only: remove all other params from kwargs, required for reports API 26 | Returns: 27 | Transforms the function in a generator, returning all pages 28 | """ 29 | if not extras: 30 | extras = {} 31 | 32 | def decorator(function): 33 | def wrapper(*args, **kwargs): 34 | done = False 35 | while not done: 36 | res = function(*args, **kwargs) 37 | 38 | yield res 39 | if res.next_token: 40 | sleep_time = make_sleep_time( 41 | res.rate_limit, use_rate_limit_header, throttle_by_seconds 42 | ) 43 | if sleep_time > 0: 44 | time.sleep(sleep_time) 45 | if next_token_only: 46 | kwargs = {next_token_param: res.next_token} 47 | else: 48 | kwargs.update({next_token_param: res.next_token, **extras}) 49 | else: 50 | done = True 51 | 52 | wrapper.__doc__ = function.__doc__ 53 | return wrapper 54 | 55 | return decorator 56 | -------------------------------------------------------------------------------- /sp_api/util/load_date_bound.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | 3 | 4 | def load_date_bound(interval_days: int = 30): 5 | def make_end_date(s: datetime, e: datetime, i: int): 6 | end_date = s + datetime.timedelta(days=i) 7 | if end_date > e: 8 | return e 9 | return end_date 10 | 11 | def parse_if_needed(dt: datetime or str): 12 | if isinstance(dt, datetime.datetime): 13 | return dt 14 | return datetime.datetime.fromisoformat(dt) 15 | 16 | date_range = {} 17 | 18 | def decorator(function): 19 | def wrapper(*args, **kwargs): 20 | date_range.update( 21 | { 22 | "dataStartTime": parse_if_needed(kwargs["dataStartTime"]), 23 | "dataEndTime": parse_if_needed( 24 | kwargs.get("dataEndTime", datetime.datetime.utcnow()) 25 | ), 26 | } 27 | ) 28 | kwargs.update( 29 | { 30 | "dataEndTime": make_end_date( 31 | date_range["dataStartTime"], 32 | date_range["dataEndTime"], 33 | interval_days, 34 | ) 35 | } 36 | ) 37 | while kwargs["dataStartTime"] < kwargs["dataEndTime"]: 38 | yield function(*args, **kwargs) 39 | kwargs.update( 40 | { 41 | "dataStartTime": parse_if_needed(kwargs["dataEndTime"]), 42 | "dataEndTime": make_end_date( 43 | parse_if_needed(kwargs["dataEndTime"]), 44 | date_range["dataEndTime"], 45 | interval_days, 46 | ), 47 | } 48 | ) 49 | 50 | wrapper.__doc__ = function.__doc__ 51 | return wrapper 52 | 53 | return decorator 54 | -------------------------------------------------------------------------------- /sp_api/util/retry.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | def retry(exception_classes=None, tries=10, delay=5, rate=1.3): 5 | """ 6 | retry(exception_classes=None, tries=10, delay=5, rate=1.3) 7 | 8 | Retry a call against an endpoint time 9 | 10 | 11 | Args: 12 | exception_classes: tuple | The Exceptions to be caught 13 | tries: int | How often the call should be retried 14 | delay: float | The delay after an error was caught 15 | rate: float | The rate to increment delay by 16 | 17 | Returns: 18 | 19 | """ 20 | if exception_classes is None: 21 | exception_classes = (Exception,) 22 | 23 | tries_counter = {"count": 1, "last_delay": delay} 24 | 25 | def decorator(function): 26 | def wrapper(*args, **kwargs): 27 | try: 28 | return function(*args, **kwargs) 29 | except exception_classes as e: 30 | if tries_counter.get("count") + 1 > tries: 31 | raise e 32 | 33 | delay_now = ( 34 | delay 35 | if tries_counter.get("count") == 1 36 | else tries_counter.get("last_delay") * rate 37 | ) 38 | tries_counter.update( 39 | {"count": tries_counter.get("count") + 1, "last_delay": delay_now} 40 | ) 41 | time.sleep(delay_now) 42 | return wrapper(*args, **kwargs) 43 | finally: 44 | tries_counter.update({"count": 1, "last_delay": delay}) 45 | 46 | wrapper.__doc__ = function.__doc__ 47 | return wrapper 48 | 49 | return decorator 50 | 51 | 52 | def sp_retry(exception_classes=(), tries=10, delay=5, rate=1.3): 53 | """ 54 | This is a shorthand for retry that catches all exceptions thrown by this library 55 | 56 | Retry a call against an endpoint time 57 | Args: 58 | exception_classes: 59 | tries: 60 | delay: 61 | rate: 62 | 63 | Returns: 64 | 65 | """ 66 | from sp_api.base import SellingApiException 67 | 68 | return retry((SellingApiException,) + exception_classes, tries, delay, rate) 69 | 70 | 71 | def throttle_retry(exception_classes=(), tries=10, delay=5, rate=1.3): 72 | """ 73 | This is a shorthand for retry that catches SellingApiRequestThrottledException 74 | 75 | Retry a call against an endpoint time 76 | Args: 77 | exception_classes: 78 | tries: 79 | delay: 80 | rate: 81 | 82 | Returns: 83 | 84 | """ 85 | from sp_api.base import SellingApiRequestThrottledException 86 | 87 | return retry( 88 | (SellingApiRequestThrottledException,) + exception_classes, tries, delay, rate 89 | ) 90 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/__init__.py -------------------------------------------------------------------------------- /tests/api/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/__init__.py -------------------------------------------------------------------------------- /tests/api/authorization/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/authorization/__init__.py -------------------------------------------------------------------------------- /tests/api/authorization/test_authorization.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import Authorization 2 | 3 | 4 | def test_get_auth_code(): 5 | res = Authorization().get_authorization_code(mwsAuthToken='test', developerId='test', sellingPartnerId='test') 6 | assert res.payload['authorizationCode'] == 'ANDMxqpCmqWHJeyzdbMH' 7 | -------------------------------------------------------------------------------- /tests/api/catalog/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/catalog/__init__.py -------------------------------------------------------------------------------- /tests/api/catalog/test_catalog.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import Catalog 2 | from sp_api.base import Marketplaces, SellingApiBadRequestException, ApiResponse 3 | 4 | 5 | def test_get_catalog_item(): 6 | res = Catalog().get_item('ASIN_200', MarketplaceId='TEST_CASE_200') 7 | assert res.errors is None 8 | assert isinstance(res, ApiResponse) 9 | 10 | 11 | def test_list_catalog_items(): 12 | res = Catalog().list_items(MarketplaceId='TEST_CASE_200', SellerSKU='SKU_200') 13 | assert res.errors is None 14 | 15 | 16 | def test_list_catalog_expect_400(): 17 | try: 18 | Catalog().list_items(MarketplaceId='TEST_CASE_400', SellerSKU='SKU_400') 19 | except SellingApiBadRequestException as br: 20 | assert type(br) == SellingApiBadRequestException 21 | 22 | -------------------------------------------------------------------------------- /tests/api/catalog_items/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/catalog_items/__init__.py -------------------------------------------------------------------------------- /tests/api/catalog_items/test_catalog_items.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import CatalogItems as Catalog, CatalogItemsVersion 2 | from sp_api.base import Marketplaces, SellingApiBadRequestException, ApiResponse 3 | 4 | 5 | def test_get_catalog_item(): 6 | res = Catalog(version=CatalogItemsVersion.V_2020_12_01).get_catalog_item('B098RX87V2') 7 | assert res.errors is None 8 | assert isinstance(res, ApiResponse) 9 | 10 | # No `includedData` parameter provided - Amazon should default to 11 | # "summaries". 12 | assert 'summaries' in res.payload 13 | 14 | 15 | def test_get_catalog_item_version(): 16 | res = Catalog(version=CatalogItemsVersion.LATEST).get_catalog_item('B098RX87V2') 17 | assert res.errors is None 18 | assert isinstance(res, ApiResponse) 19 | 20 | 21 | def test_list_catalog_items(): 22 | res = Catalog().search_catalog_items(keywords='test') 23 | assert res.errors is None 24 | 25 | # No `includedData` parameter provided - Amazon should default to 26 | # "summaries" for every returned item. 27 | for item in res.items: 28 | assert 'summaries' in item 29 | 30 | 31 | def test_get_catalog_item_foo(): 32 | res = Catalog(version=CatalogItemsVersion.V_2020_12_01).get_catalog_item('B07Z95MG3S') 33 | assert res.errors is None 34 | assert isinstance(res, ApiResponse) 35 | -------------------------------------------------------------------------------- /tests/api/feeds/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/feeds/__init__.py -------------------------------------------------------------------------------- /tests/api/feeds/test_feeds.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import FeedsV2 as Feeds 2 | from sp_api.base import SellingApiBadRequestException, SellingApiServerException, SellingApiForbiddenException 3 | from sp_api.base.feedTypes import FeedType 4 | 5 | 6 | def test_create_feed(): 7 | res = Feeds().create_feed( 8 | FeedType.POST_PRODUCT_DATA, 9 | '3d4e42b5-1d6e-44e8-a89c-2abfca0625bb', 10 | marketplaceIds=["ATVPDKIKX0DER", "A1F83G8C2ARO7P"] 11 | ) 12 | assert res.payload.get('feedId') == '3485934' 13 | 14 | 15 | def test_get_feed(): 16 | feed_id = 'feedId1' 17 | res = Feeds().get_feed(feed_id) 18 | assert res.payload.get('feedId') == 'FeedId1' 19 | assert res.payload.get('processingStatus') == 'CANCELLED' 20 | 21 | 22 | def test_get_feed_expect_400(): 23 | try: 24 | Feeds().get_feed('badFeedId1') 25 | except SellingApiBadRequestException as br: 26 | assert type(br) == SellingApiBadRequestException 27 | assert br.code == 400 28 | 29 | 30 | def test_get_feed_expect_500(): 31 | try: 32 | Feeds().get_feed('giberish') 33 | except SellingApiServerException as br: 34 | assert type(br) == SellingApiServerException 35 | assert br.code == 500 36 | 37 | 38 | def test_request(): 39 | try: 40 | Feeds()._request('', data={}) 41 | except SellingApiForbiddenException: 42 | assert True 43 | 44 | 45 | def test_get_feed_document(): 46 | feed_document_id = '0356cf79-b8b0-4226-b4b9-0ee058ea5760' 47 | res = Feeds().get_feed_document(feed_document_id) 48 | assert 'TestSku102XmlParentã\x81\x8cã\x82\x93ã\x81°ã\x81£ã\x81¦' in res 49 | -------------------------------------------------------------------------------- /tests/api/finances/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/finances/__init__.py -------------------------------------------------------------------------------- /tests/api/finances/test_finances.py: -------------------------------------------------------------------------------- 1 | import json 2 | from datetime import datetime, timedelta 3 | 4 | from sp_api.api import Finances 5 | from sp_api.base import SellingApiBadRequestException 6 | 7 | 8 | def test_for_order(): 9 | res = Finances().get_financial_events_for_order('485-734-5434857', MaxResultsPerPage=10) 10 | assert res.payload.get('NextToken') == 'Next token value' 11 | 12 | 13 | def test_for_order_expect_400(): 14 | try: 15 | Finances().get_financial_events_for_order('BAD-ORDER', MaxResultsPerPage=10) 16 | except SellingApiBadRequestException as br: 17 | assert br.code == 400 18 | assert type(br) == SellingApiBadRequestException 19 | 20 | -------------------------------------------------------------------------------- /tests/api/fulfillment_inbound/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/fulfillment_inbound/__init__.py -------------------------------------------------------------------------------- /tests/api/inbound_eligibility/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/inbound_eligibility/__init__.py -------------------------------------------------------------------------------- /tests/api/inbound_eligibility/test_inbound_eligibility.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import FbaInboundEligibility 2 | 3 | 4 | def test_inbound_eligibility(): 5 | res = FbaInboundEligibility().get_item_eligibility_preview(asin='TEST_CASE_200', program="INBOUND") 6 | assert res.payload is not None 7 | -------------------------------------------------------------------------------- /tests/api/inventories/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/inventories/__init__.py -------------------------------------------------------------------------------- /tests/api/inventories/test_inventories.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import Inventories 2 | from sp_api.base import SellingApiServerException, SellingApiForbiddenException, Marketplaces 3 | 4 | 5 | def test_get_inventory_summary_marketplace(): 6 | res = Inventories().get_inventory_summary_marketplace(**{ 7 | "details": True, 8 | "marketplaceIds": ["ATVPDKIKX0DER"] 9 | }) 10 | assert res.errors is None 11 | assert res.pagination.get('nextToken') == 'seed' 12 | assert res.payload.get('granularity').get('granularityType') == 'Marketplace' 13 | 14 | 15 | def test_get_inventory_summary_marketplace_expect_500(): 16 | try: 17 | Inventories().get_inventory_summary_marketplace(**{ 18 | "marketplaceIds": ["1"], 19 | }) 20 | except SellingApiForbiddenException as se: 21 | assert se.code == 403 22 | 23 | -------------------------------------------------------------------------------- /tests/api/listings_items/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/listings_items/__init__.py -------------------------------------------------------------------------------- /tests/api/listings_items/test_listings_items.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import ListingsItems 2 | from sp_api.base import Marketplaces 3 | 4 | 5 | def test_get_listings_item(): 6 | res = ListingsItems().get_listings_item('xxx', 'xxx') 7 | assert res is not None 8 | 9 | def test_search_listings_items(): 10 | res = ListingsItems().search_listings_items('xxx') 11 | assert res is not None 12 | 13 | 14 | def test_put_listings_item(): 15 | res = ListingsItems().put_listings_item('xxx', 'xxx', body={ 16 | "productType": "string", 17 | "requirements": "LISTING", 18 | "attributes": {}, 19 | 20 | }, marketplaceIds=[Marketplaces.US.marketplace_id]) 21 | assert res('status') == 'ACCEPTED' 22 | 23 | 24 | def test_patch_listings_item(): 25 | res = ListingsItems().patch_listings_item('xxx', 'xxx', body={ 26 | "productType": "string", 27 | "patches": [ 28 | { 29 | "op": "add", 30 | "path": "string", 31 | "value": [ 32 | {} 33 | ] 34 | } 35 | ] 36 | }) 37 | assert res('status') == 'ACCEPTED' 38 | 39 | 40 | def test_delete_listings_item(): 41 | res = ListingsItems().delete_listings_item('xxx', 'xxx') 42 | assert res('status') == 'ACCEPTED' 43 | -------------------------------------------------------------------------------- /tests/api/listings_restrictions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/listings_restrictions/__init__.py -------------------------------------------------------------------------------- /tests/api/listings_restrictions/test_listings_restrictions.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import ListingsRestrictions 2 | 3 | 4 | def test_listing_restrictions(): 5 | res = ListingsRestrictions().get_listings_restrictions(sellerId='A3F26DF64ZIPJZ', asin='B07HRD6JKK') 6 | assert res('restrictions') is not None 7 | assert isinstance(res('restrictions'), list) 8 | 9 | -------------------------------------------------------------------------------- /tests/api/merchant_fullfillment/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/merchant_fullfillment/__init__.py -------------------------------------------------------------------------------- /tests/api/messaging/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/messaging/__init__.py -------------------------------------------------------------------------------- /tests/api/messaging/test_messaging.py: -------------------------------------------------------------------------------- 1 | from sp_api.api.messaging.messaging import Messaging 2 | from sp_api.base import Marketplaces 3 | 4 | -------------------------------------------------------------------------------- /tests/api/notifications/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/notifications/__init__.py -------------------------------------------------------------------------------- /tests/api/notifications/test_notifications.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import Notifications, Reports, Finances 2 | from sp_api.base import SellingApiException, NotificationType, ReportType, Marketplaces 3 | from sp_api.util import throttle_retry, load_all_pages 4 | 5 | 6 | def test_create_destination(): 7 | res = Notifications().create_destination(name='test', arn='arn:aws:sqs:us-east-2:444455556666:queue1') 8 | assert res.payload.get("destinationId") == "TEST_CASE_200_DESTINATION_ID" 9 | assert res.payload.get("resource").get('sqs').get('arn') == "arn:aws:sqs:us-east-2:444455556666:queue1" 10 | 11 | 12 | def test_create_subscription(): 13 | res = Notifications().create_subscription(NotificationType.MFN_ORDER_STATUS_CHANGE, destination_id='dest_id') 14 | assert res.payload.get('destinationId') == 'TEST_CASE_200_DESTINATION_ID' 15 | assert res.payload.get('subscriptionId') == 'TEST_CASE_200_SUBSCRIPTION_ID' 16 | 17 | 18 | def test_delete_subscription(): 19 | res = Notifications().delete_notification_subscription(NotificationType.MFN_ORDER_STATUS_CHANGE, 'subscription_id') 20 | assert res.errors is None 21 | 22 | 23 | def test_get_subscriptions(): 24 | res = Notifications().get_subscription(NotificationType.REPORT_PROCESSING_FINISHED) 25 | assert res.payload.get('destinationId') == 'TEST_CASE_200_DESTINATION_ID' 26 | assert res.payload.get('subscriptionId') == 'TEST_CASE_200_SUBSCRIPTION_ID' 27 | -------------------------------------------------------------------------------- /tests/api/orders/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/orders/__init__.py -------------------------------------------------------------------------------- /tests/api/product_fees/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/product_fees/__init__.py -------------------------------------------------------------------------------- /tests/api/product_fees/product_fees.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import ProductFees 2 | from sp_api.base import Marketplaces 3 | 4 | 5 | def test_get_fees_for_sku(): 6 | res = ProductFees().get_product_fees_estimate_for_sku("UmaS1", 10, currency='USD', shipping_price=10, is_fba=False, 7 | points={ 8 | "PointsNumber": 0, 9 | "PointsMonetaryValue": { 10 | "CurrencyCode": "USD", 11 | "Amount": 0 12 | } 13 | }) 14 | assert res.payload.get('FeesEstimateResult').get('Status') == 'Success' 15 | 16 | 17 | def test_get_fees_for_asin(): 18 | res = ProductFees().get_product_fees_estimate_for_asin("UmaS1", 10, currency='USD', shipping_price=10, is_fba=False, 19 | points={ 20 | "PointsNumber": 0, 21 | "PointsMonetaryValue": { 22 | "CurrencyCode": "USD", 23 | "Amount": 0 24 | } 25 | }) 26 | assert res.payload.get('FeesEstimateResult').get('Status') == 'Success' 27 | 28 | 29 | def test_get_product_fees_estimate(): 30 | res = ProductFees().get_product_fees_estimate([ 31 | dict(identifier='UmaS1',id_type='ASIN',id_value="asin123", price=10, currency='USD', shipping_price=10, is_fba=False, 32 | points={ 33 | "PointsNumber": 0, 34 | "PointsMonetaryValue": { 35 | "CurrencyCode": "USD", 36 | "Amount": 0 37 | }} 38 | ), 39 | dict(identifier='UmaS2', marketplace_id=Marketplaces.MX.marketplace_id, id_type='SellerSKU', id_value="sku123", price=10, currency='MXN', shipping_price=10, is_fba=True, 40 | points={ 41 | "PointsNumber": 0, 42 | "PointsMonetaryValue": { 43 | "CurrencyCode": "MXN", 44 | "Amount": 0 45 | }} 46 | ), 47 | ]) 48 | for fer in res.payload: 49 | assert fer['Status'] == 'Success' 50 | -------------------------------------------------------------------------------- /tests/api/product_type_definitions/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/product_type_definitions/__init__.py -------------------------------------------------------------------------------- /tests/api/product_type_definitions/test_product_type_definitions.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import ProductTypeDefinitions 2 | 3 | 4 | def test_get_product_type_definitions(): 5 | r = ProductTypeDefinitions().get_definitions_product_type('LEGUME') 6 | assert r is not None 7 | -------------------------------------------------------------------------------- /tests/api/products/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/products/__init__.py -------------------------------------------------------------------------------- /tests/api/reports/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/reports/__init__.py -------------------------------------------------------------------------------- /tests/api/sales/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/sales/__init__.py -------------------------------------------------------------------------------- /tests/api/sales/test_sales.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime, timedelta, timezone 2 | 3 | import pytz 4 | 5 | from sp_api.api import Sales 6 | from sp_api.base import Granularity 7 | 8 | tz = pytz.timezone('US/Central') 9 | fmt = '%Y-%m-%dT%H:%M:%S%z' 10 | 11 | interval = (datetime.now(tz) - timedelta(days=185)), (datetime.now(tz)) 12 | 13 | 14 | def test_sales_granularity_total(): 15 | res = Sales().get_order_metrics(interval, Granularity.TOTAL, granularityTimeZone='US/Central') 16 | assert res.payload[0].get('unitCount') == 2 17 | 18 | 19 | def test_sales_granularity_day(): 20 | res = Sales().get_order_metrics(interval, Granularity.DAY, granularityTimeZone='US/Central') 21 | assert res.payload[0].get('unitCount') == 1 22 | 23 | 24 | def test_sales_granularity_total_by_asin(): 25 | res = Sales().get_order_metrics(interval, Granularity.TOTAL, granularityTimeZone='US/Central', asin='B008OLKVEW') 26 | assert res.payload[0].get('unitCount') == 1 27 | 28 | 29 | def test_sales_granularity_day_by_asin(): 30 | res = Sales().get_order_metrics(interval, Granularity.DAY, granularityTimeZone='US/Central', asin='B008OLKVEW') 31 | assert res.payload[0].get('unitCount') == 1 32 | 33 | -------------------------------------------------------------------------------- /tests/api/sellers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/sellers/__init__.py -------------------------------------------------------------------------------- /tests/api/sellers/test_sellers.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/sellers/test_sellers.py -------------------------------------------------------------------------------- /tests/api/small_and_light/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/small_and_light/__init__.py -------------------------------------------------------------------------------- /tests/api/small_and_light/test_small_and_light.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import FbaSmallAndLight 2 | from sp_api.base import Marketplaces 3 | 4 | 5 | def test_get_small_and_light_eligibility_by_seller_sku(): 6 | res = FbaSmallAndLight().get_small_and_light_eligibility_by_seller_sku('TEST_CASE_200') 7 | assert res.payload is not None 8 | 9 | 10 | def test_get_small_and_light_fee_preview(): 11 | res = FbaSmallAndLight().get_small_and_light_fee_preview(**{ 12 | 'marketplaceId': Marketplaces.US.marketplace_id, 13 | "items": [ 14 | { 15 | "asin": "B076ZL9PB5", 16 | "price": { 17 | "currencyCode": "USD", 18 | "amount": 6.5 19 | } 20 | } 21 | ]}) 22 | assert res('data') is not None 23 | assert res.payload is not None 24 | 25 | 26 | def test_delete_small_and_light_enrollment_by_seller_sku(): 27 | res = FbaSmallAndLight().delete_small_and_light_enrollment_by_seller_sku('SKU_ENROLLED_FOR_SMALL_AND_LIGHT', marketplaceIds='ATVPDKIKX0DER') 28 | assert res('status_code') == 204 29 | 30 | 31 | def test_get_small_and_light_enrollment_by_seller_sku(): 32 | res = FbaSmallAndLight().get_small_and_light_enrollment_by_seller_sku('SKU_ENROLLED_IN_SMALL_AND_LIGHT') 33 | assert res('status') == 'ENROLLED' 34 | 35 | 36 | def test_put_small_and_light_enrollment_by_seller_sku(): 37 | res = FbaSmallAndLight().put_small_and_light_enrollment_by_seller_sku('SKU_ELIGIBLE_FOR_SMALL_AND_LIGHT') 38 | assert res() is not None 39 | -------------------------------------------------------------------------------- /tests/api/tokens/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/tokens/__init__.py -------------------------------------------------------------------------------- /tests/api/tokens/test_tokens.py: -------------------------------------------------------------------------------- 1 | from datetime import timedelta, datetime 2 | 3 | import pytest 4 | 5 | from sp_api.api import Tokens, Orders 6 | from sp_api.base import SellingApiBadRequestException, Marketplaces 7 | 8 | # 9 | # def test_get_token_for_bulk_orders(): 10 | # with pytest.raises(SellingApiBadRequestException) as info: 11 | # res = Tokens().create_restricted_data_token(restrictedResources=[ 12 | # { 13 | # "method": "GET", 14 | # "path": "/orders/v0/orders", 15 | # "dataElements": ["buyerInfo", "shippingAddress"] 16 | # } 17 | # ]) 18 | # print(res) 19 | # 20 | # 21 | # def test_get_order_with_token(): 22 | # res = Orders(restricted_data_token='foo').get_orders(CreatedAfter=(datetime.now() - timedelta(days=10)).isoformat()) 23 | # print(res) 24 | -------------------------------------------------------------------------------- /tests/api/upload/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/api/upload/__init__.py -------------------------------------------------------------------------------- /tests/api/upload/test_upload.py: -------------------------------------------------------------------------------- 1 | from sp_api.api import Upload 2 | from sp_api.base import Marketplaces 3 | 4 | -------------------------------------------------------------------------------- /tests/client/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/tests/client/__init__.py -------------------------------------------------------------------------------- /tests/client/test_auth.py: -------------------------------------------------------------------------------- 1 | from sp_api.base import AccessTokenClient 2 | from sp_api.base import Credentials, CredentialProvider 3 | from sp_api.base import AuthorizationError 4 | from sp_api.base.credential_provider import BaseCredentialProvider, FromCodeCredentialProvider 5 | 6 | 7 | refresh_token = '' 8 | lwa_app_id = '' 9 | lwa_client_secret = '' 10 | 11 | 12 | def test_auth_exception(): 13 | e = AuthorizationError(200, 'Foo', 999) 14 | assert e.status_code == 999 15 | assert e.error_code == 200 16 | assert e.message == 'Foo' 17 | 18 | 19 | def test_credentials(): 20 | x = CredentialProvider() 21 | assert x.credentials is not None 22 | assert x.credentials.lwa_app_id is not None 23 | assert x.credentials.lwa_client_secret is not None 24 | 25 | 26 | def test_credentials_with_custom_provider(): 27 | class CustomCredentialProvider(BaseCredentialProvider): 28 | def load_credentials(self): 29 | self.credentials = { 30 | "refresh_token": refresh_token, 31 | "lwa_app_id": lwa_app_id, 32 | "lwa_client_secret": lwa_client_secret, 33 | } 34 | 35 | cp = CredentialProvider(credential_providers=(CustomCredentialProvider,)) 36 | assert cp.credentials is not None 37 | assert cp.credentials.refresh_token == "" 38 | assert cp.credentials.lwa_app_id == "" 39 | assert cp.credentials.lwa_client_secret == "" 40 | 41 | 42 | def test_auth_client(): 43 | client = AccessTokenClient(credentials=CredentialProvider(credentials=dict( 44 | refresh_token=refresh_token, 45 | lwa_app_id=lwa_app_id, 46 | lwa_client_secret=lwa_client_secret, 47 | )).credentials) 48 | x = client._auth_code_request_body('foo') 49 | assert x.get('grant_type') == 'authorization_code' 50 | 51 | try: 52 | client.authorize_auth_code('foo') 53 | except AuthorizationError as e: 54 | assert isinstance(e, AuthorizationError) 55 | 56 | try: 57 | client._request('https://jsonplaceholder.typicode.com/posts/1', {}, {}) 58 | except AuthorizationError as e: 59 | assert isinstance(e, AuthorizationError) 60 | -------------------------------------------------------------------------------- /tests/client/test_credential_provider.py: -------------------------------------------------------------------------------- 1 | import os 2 | from unittest import mock 3 | 4 | from sp_api.base.credential_provider import FromCachedSecretsCredentialProvider 5 | 6 | 7 | REFRESH_TOKEN = '' 8 | LWA_APP_ID = '' 9 | LWA_CLIENT_SECRET = '' 10 | 11 | 12 | def test_from_cached_secrets_cp_without_secret_id_set(): 13 | with mock.patch.dict(os.environ, {"SP_API_AWS_SECRET_ID": ""}): 14 | cp = FromCachedSecretsCredentialProvider() 15 | cp.load_credentials() 16 | 17 | assert cp.credentials is None 18 | 19 | 20 | def test_from_cached_secrets_cp_without_cache_available(): 21 | with mock.patch.dict(os.environ, {"SP_API_AWS_SECRET_ID": "test"}), \ 22 | mock.patch.object(FromCachedSecretsCredentialProvider, "_get_secret_cache", return_value=None): 23 | cp = FromCachedSecretsCredentialProvider() 24 | cp.load_credentials() 25 | 26 | assert cp.credentials is None 27 | 28 | 29 | def test_from_cached_secrets_cp_with_cache_available(): 30 | secret_content = { 31 | "SP_API_REFRESH_TOKEN": REFRESH_TOKEN, 32 | "LWA_APP_ID": LWA_APP_ID, 33 | "LWA_CLIENT_SECRET": LWA_CLIENT_SECRET, 34 | } 35 | 36 | with mock.patch.dict(os.environ, {"SP_API_AWS_SECRET_ID": "test"}), \ 37 | mock.patch.object(FromCachedSecretsCredentialProvider, "get_secret_content", return_value=secret_content): 38 | cp = FromCachedSecretsCredentialProvider() 39 | cp.load_credentials() 40 | 41 | assert cp.credentials == { 42 | "refresh_token": REFRESH_TOKEN, 43 | "lwa_app_id": LWA_APP_ID, 44 | "lwa_client_secret": LWA_CLIENT_SECRET, 45 | } 46 | -------------------------------------------------------------------------------- /votes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saleweaver/python-amazon-sp-api/b11f9a52ad0ce366ffc114ca6591362148d41ef5/votes.png --------------------------------------------------------------------------------