{"id":13748851,"url":"https://github.com/jlevers/selling-partner-api","last_synced_at":"2026-01-11T16:30:45.134Z","repository":{"id":36988996,"uuid":"325103082","full_name":"jlevers/selling-partner-api","owner":"jlevers","description":"A PHP client library for Amazon's Selling Partner API","archived":false,"fork":false,"pushed_at":"2025-04-03T02:09:33.000Z","size":17631,"stargazers_count":419,"open_issues_count":29,"forks_count":216,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-05-03T12:03:17.957Z","etag":null,"topics":["amazon","php","saloon","sdk","selling-partner-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jlevers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":"FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"jlevers"}},"created_at":"2020-12-28T19:49:36.000Z","updated_at":"2025-04-22T03:48:53.000Z","dependencies_parsed_at":"2023-02-13T23:30:53.627Z","dependency_job_id":"99d748f1-1ca9-44cb-8911-f86a00f839da","html_url":"https://github.com/jlevers/selling-partner-api","commit_stats":{"total_commits":518,"total_committers":30,"mean_commits":"17.266666666666666","dds":0.1853281853281853,"last_synced_commit":"b60e4dcc006f1e663ac4ba3a6e68ebd3ccf3e12d"},"previous_names":[],"tags_count":133,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlevers%2Fselling-partner-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlevers%2Fselling-partner-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlevers%2Fselling-partner-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlevers%2Fselling-partner-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jlevers","download_url":"https://codeload.github.com/jlevers/selling-partner-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253240350,"owners_count":21876593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon","php","saloon","sdk","selling-partner-api"],"created_at":"2024-08-03T07:00:50.867Z","updated_at":"2026-01-11T16:30:45.121Z","avatar_url":"https://github.com/jlevers.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://highsidelabs.co\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://github.com/highsidelabs/.github/blob/main/images/logo.png?raw=true\" width=\"125\" alt=\"Highside Labs logo\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/jlevers/selling-partner-api\"\u003e\u003cimg alt=\"Total downloads\" src=\"https://img.shields.io/packagist/dt/jlevers/selling-partner-api.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/jlevers/selling-partner-api\"\u003e\u003cimg alt=\"Latest stable version\" src=\"https://img.shields.io/packagist/v/jlevers/selling-partner-api.svg?style=flat-square\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/jlevers/selling-partner-api\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/packagist/l/jlevers/selling-partner-api.svg?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Selling Partner API for PHP\nA PHP library for connecting to Amazon's [Selling Partner API](https://github.com/amzn/selling-partner-api-docs/).\n\n\u003e [!WARNING]\n\u003e Amazon has deprecated [most listings-related XML and flat-file feeds](https://developer-docs.amazon.com/sp-api/docs/sp-api-release-notes#feeds). I built an [**Amazon feed converter**](https://tools.highsidelabs.co) tool for easily converting the deprecated feeds to the newer `JSON_LISTINGS_FEED` format with a few lines of code. Read the full documentation [here](https://docs.highsidelabs.co/feed-transformer).\n\n### Related packages\n\n* [`highsidelabs/laravel-spapi`](https://github.com/highsidelabs/laravel-spapi): A [Laravel](https://laravel.com) wrapper for this package that makes SP API integration in Laravel projects quick and easy. I also developed a [Laravel SP API starter project](https://tools.highsidelabs.co/starter-kit) to make developing SP API apps on Laravel as easy as possible.\n* [`highsidelabs/amazon-business-api`](https://github.com/highsidelabs/amazon-business-api): A PHP library for Amazon's [Business API](https://developer-docs.amazon.com/amazon-business/docs).\n* [`highsidelabs/walmart-api`](https://github.com/highsidelabs/walmart-api-php): A PHP library for [Walmart's seller and supplier APIs](https://developer.walmart.com), including the Marketplace, Drop Ship Vendor, Content Provider, and Warehouse Supplier APIs.\n* [`shipstream/fedex-rest-sdk`](https://github.com/shipstream/fedex-rest-php-sdk): A PHP library for interacting with FedEx's REST APIs, built by me on behalf of [ShipStream](https://shipstream.io).\n\n---\n\nIf you've found any of my packages useful, please consider [becoming a Sponsor](https://github.com/sponsors/jlevers), or making a one-time donation via the button below. I appreciate any and all support! Keeping open source projects alive is a community effort.\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://www.paypal.com/donate?business=EL4PRLAEMGXNQ\u0026currency_code=USD\"\u003e\u003cimg alt=\"Donate to Jesse Evers\" src=\"https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n### Sponsored by **[Tesmo](https://tesmollc.com)**.\n\n### Sponsored by **[Highside Labs](https://tools.highsidelabs.co/starter-kit)**. Get started with SP API development on Laravel in minutes.\n\n---\n\n\u003e [!NOTE]\n\u003e If you're looking for the documentation for v5 of this package, you can find it [here](https://github.com/jlevers/selling-partner-api/tree/v5.0).\n\n## Features\n\n* Supports all Selling Partner API operations (for Sellers and Vendors) as of 12/6/2025\n* Automatically generates Restricted Data Tokens for all calls that require them -- no extra calls to the Tokens API needed\n* Includes a [`Document` helper class](#uploading-and-downloading-documents) for uploading and downloading feed/report documents\n* Can handle the end-to-end OAuth flow, from building authorization URLs to converting authorization codes into refresh tokens\n\n\n## Installation\n\n`composer require jlevers/selling-partner-api`\n\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n\n\n## Table of Contents\n\nCheck out the [Getting Started](#getting-started) section below for a quick overview.\n\nThis README is divided into several sections:\n* [Setup](#setup)\n    * [Configuration options](#configuration-options)\n* [Debugging](#debugging)\n* [Working with responses](#working-with-responses)\n* [Working with DTOs](#working-with-dtos)\n* [Supported API segments](#supported-api-segments)\n    * [Seller APIs](#seller-apis)\n    * [Vendor APIs](#vendor-apis)\n* [Restricted operations](#restricted-operations)\n* [Uploading and downloading documents](#uploading-and-downloading-documents)\n    * [Downloading a report document](#downloading-a-report-document)\n    * [Uploading a feed document](#uploading-a-feed-document)\n    * [Downloading a feed result document](#downloading-a-feed-result-document)\n* [OAuth](#oauth)\n    * [Building authorization URIs](#building-authorization-uris)\n    * [Generating a refresh token from an authorization code](#generating-a-refresh-token-from-an-authorization-code)\n* [Naming conventions](#naming-conventions)\n\n## Getting Started\n\n### Prerequisites\n\nTo get started, you need an approved Selling Partner API developer account, and SP API application credentials, which you can get by creating a new SP API application in Seller Central.\n\n\n### Setup\n\nThe [`SellingPartnerApi`](https://github.com/jlevers/selling-partner-api/blob/main/src/SellingPartnerApi.php) class acts as a factory to generate Seller and Vendor API connector instances. Its `seller()` and `vendor()` methods each take a set of identical (and optionally, named) parameters. Its basic usage looks like this:\n\n```php\nuse SellingPartnerApi\\SellingPartnerApi;\nuse SellingPartnerApi\\Enums\\Endpoint;\n\n$connector = SellingPartnerApi::seller(\n    clientId: 'amzn1.application-oa2-client.asdfqwertyuiop...',\n    clientSecret: 'amzn1.oa2-cs.v1.1234567890asdfghjkl...',\n    refreshToken: 'Atzr|IwEBIA...',\n    endpoint: Endpoint::NA,  // Or Endpoint::EU, Endpoint::FE, Endpoint::NA_SANDBOX, etc.\n);\n```\n\n\u003e [!NOTE]\n\u003e Older versions of the Selling Partner API used AWS IAM credentials to authenticate, and so this library had additional AWS configuration options. If you're upgrading from an older version of this library and are confused about what to do with your AWS creds, you can just ignore them. The SP API no longer authenticates via AWS IAM roles or users.\n\nNow you have a Selling Partner API connector instance, and you can start making calls to the API. The connector instance has methods for each of the API segments (e.g., `sellers`, `orders`, `fba-inbound`), and you can access them like so:\n\n```php\n$ordersApi = $connector-\u003eordersV0();\n$response = $ordersApi-\u003egetOrders(\n    createdAfter: new DateTime('2024-01-01'),\n    marketplaceIds: ['ATVPDKIKX0DER'],\n);\n```\n\nOnce you have a response, you can either access the raw JSON response via `$response-\u003ejson()`, or you can automatically parse the response into a DTO by calling `$response-\u003edto()`. Once the response is turned into a DTO, you can access the data via the DTO's properties. For instance, you can get the first order's purchase date like so:\n\n```php\n$dto = $response-\u003edto();\n$purchaseDate = $dto-\u003epayload-\u003eorders[0]-\u003epurchaseDate;\n```\n\nSee the [Working with responses](#working-with-responses) section for more details on how to work with responses, and [Working with DTOs](#working-with-dtos) for more details on how to use DTOs.\n\n\n##### Configuration options\n\nThe `SellingPartnerApi::seller()` and `SellingPartnerApi::vendor()` builder methods accept the following arguments:\n\n* `clientId (string)`: Required. The LWA client ID of the SP API application to use to execute API requests.\n* `clientSecret (string)`: Required. The LWA client secret of the SP API application to use to execute API requests.\n* `refreshToken (string)`: The LWA refresh token of the SP API application to use to execute API requests. Required, unless you're only using [grantless operations](https://developer-docs.amazon.com/sp-api/docs/grantless-operations), in which case you can pass a dummy string like `'grantless'`.\n* `endpoint`: Required. An instance of the [`SellingPartnerApi\\Enums\\Endpoint` enum](https://github.com/jlevers/selling-partner-api/blob/main/src/Enums/Endpoint.php). Primary endpoints are `Endpoint::NA`, `Endpoint::EU`, and `Endpoint::FE`. Sandbox endpoints are `Endpoint::NA_SANDBOX`, `Endpoint::EU_SANDBOX`, and `Endpoint::FE_SANDBOX`.\n* `dataElements (array)`: Optional. An array of data elements to pass to restricted operations. See the [Restricted operations](#restricted-operations) section for more details.\n* `delegatee (string)`: Optional. The application ID of a delegatee application to generate RDTs on behalf of.\n* `authenticationClient (GuzzleHttp\\Client)`: Guzzle client instance that will be used to generate the access token from the refresh token. If not provided, the default Saloon Guzzle client will be used.\n* `cache (SellingPartnerApi\\Contracts\\TokenCache)`: A cache interface instance that will be used to cache access tokens. If not provided, a basic in-memory cache will be used. If set to `null`, caching will be disabled.\n\n\n### Debugging\n\nTo get detailed debugging output, you can take advantage of [Saloon's debugging hooks](https://docs.saloon.dev/digging-deeper/debugging). This package is built on top of Saloon, so anything that works in Saloon will work here. For instance, to debug requests:\n\n```php\nuse Psr\\Http\\Message\\RequestInterface;\nuse Saloon\\Http\\PendingRequest;\nuse SellingPartnerApi\\SellingPartnerApi;\n\n$connector = SellingPartnerApi::seller(\n    clientId: 'amzn1.application-oa2-client.asdfqwertyuiop...',\n    clientSecret: 'amzn1.oa2-cs.v1.1234567890asdfghjkl...',\n    refreshToken: 'Atzr|IwEBIA...',\n    endpoint: Endpoint::NA,\n);\n\n$connector-\u003edebugRequest(\n    function (PendingRequest $pendingRequest, RequestInterface $psrRequest) {\n        var_dump($pendingRequest-\u003eheaders()-\u003eall(), $psrRequest);\n    }\n);\n```\n\nThen make requests with the connector as usual, and you'll hit the closure above every time a request is fired. You can also debug responses in a similar fashion – check out the [Saloon docs](https://docs.saloon.dev/digging-deeper/debugging#debugging-responses) for more details.\n\nIf you want to output your debug data to a file, you can do so with the `SellingPartnerApi::debugRequestToFile()`, `SellingPartnerApi::debugResponseToFile()`, and `SellingPartnerApi::debugToFile()` methods. These methods all take an `$outputPath` argument and an optional `$die` argument.\n\n## Working with responses\n\nAs mentioned earlier, all endpoint methods return an instance of `Saloon\\Response`. You can access the raw JSON response via `$response-\u003ejson()`, or you can automatically parse the response into a DTO by calling `$response-\u003edto()`. Once the response is turned into a DTO, you can access the data via the DTO's properties (described below). Saloon's [response documentation](https://docs.saloon.dev/the-basics/responses) gives a comprehensive guide to working with Saloon responses, including retrieving headers, status, and more.\n\n## Working with DTOs\n\nSome methods take DTOs as parameters. For instance, the `confirmShipment` method in the Orders API takes a `ConfirmShipmentRequest` DTO as a parameter. You can call `confirmShipment` like so:\n\n```php\n\u003c?php\n\nuse SellingPartnerApi\\Seller\\OrdersV0\\Dto;\nuse SellingPartnerApi\\SellingPartnerApi;\n\n$confirmShipmentRequest = new Dto\\ConfirmShipmentRequest(\n    packageDetail: new Dto\\PackageDetail(\n        packageReferenceId: 'PKG123',\n        carrierCode: 'USPS',\n        trackingNumber: 'ASDF1234567890',\n        shipDate: new DateTime('2024-01-01 12:00:00'),\n        orderItems: [\n            new Dto\\ConfirmShipmentOrderItem(\n                orderItemId: '1234567890',\n                quantity: 1,\n            ),\n            new Dto\\ConfirmShipmentOrderItem(\n                orderItemId: '0987654321',\n                quantity: 2,\n            )\n        ],\n    ),\n    marketplaceId: 'ATVPDKIKX0DER',\n);\n\n$response = $ordersApi-\u003econfirmShipment(\n    orderId: '123-4567890-1234567',\n    confirmShipmentRequest: $confirmShipmentRequest,\n);\n```\n\n## Supported API segments\n\nEach API accessor method contains the API's version. This allows for multiple versions of the same API to be accessible in a single version of this package. It makes the method names a little uglier, but allows for simultaneously using new and old versions of the same API segment, which is often useful. It also means that if a new version of an existing API is introduced, the library can be updated to include that new version without introducing breaking changes.\n\n### Seller APIs\n\nSeller APIs are accessed via the `SellingPartnerApi::seller()` class:\n\n```php\n\u003c?php\nuse SellingPartnerApi\\SellingPartnerApi;\n\n$sellerConnector = SellingPartnerApi::seller(/* ... */);\n```\n\n* **Amazon Warehousing and Distribution API (v2024-05-09)** ([docs](https://developer-docs.amazon.com/sp-api/docs/awd_2024-05-09-reference))\n    ```php\n    $amazonWarehousingAndDistributionApi = $sellerConnector-\u003eamazonWarehousingAndDistributionV20240509();\n    ```\n* **App Integrations API (v2024-04-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/app-integrations-api-v2024-04-01-reference))\n    ```php\n    $appIntegrationsApi = $sellerConnector-\u003eappIntegrationsV20240401();\n    ```\n* **Application Management API (v2023-11-30)** ([docs](https://developer-docs.amazon.com/sp-api/docs/application-management-api-v2023-11-30-reference))\n    ```php\n    $applicationManagementApi = $sellerConnector-\u003eapplicationManagementV20231130();\n    ```\n* **A+ Content API (v2020-11-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/selling-partner-api-for-a-content-management))\n    ```php\n    $aPlusContentApi = $sellerConnector-\u003eaPlusContentV20201101();\n    ```\n* **Catalog Items API (v2022-04-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/catalog-items-api-v2022-04-01-reference))\n    ```php\n    $catalogItemsApi = $sellerConnector-\u003ecatalogItemsV20220401();\n    ```\n* **Catalog Items API (v2021-12-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/catalog-items-api-v2020-12-01-reference))\n    ```php\n    $catalogItemsApi = $sellerConnector-\u003ecatalogItemsV20211201();\n    ```\n* **Catalog Items API (v0)** ([docs](https://developer-docs.amazon.com/sp-api/docs/catalog-items-api-v0-reference))\n    ```php\n    $catalogItemsApi = $sellerConnector-\u003ecatalogItemsV0();\n    ```\n* **Customer Feedback API (v2024-06-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/customer-feedback-api-v2024-06-01-reference))\n    ```php\n    $customerFeedbackApi = $sellerConnector-\u003ecustomerFeedbackV20240601();\n    ```\n* **Data Kiosk API (v2023-11-15)** ([docs](https://developer-docs.amazon.com/sp-api/v0/docs/data-kiosk-api-v2023-11-15-reference))\n    ```php\n    $dataKioskApi = $sellerConnector-\u003edataKioskV20231115();\n    ```\n* **Delivery by Amazon API (v2022-07-01)** ([docs](https://developer-docs.amazon.com/sp-api/reference/delivery-by-amazon-v2022-07-01))\n    ```php\n    $deliveryByAmazonApi = $sellerConnector-\u003edeliveryByAmazonV20220701();\n    ```\n* **EasyShip API (v2022-03-23)** ([docs](https://developer-docs.amazon.com/sp-api/docs/easy-ship-api-v2022-03-23-reference))\n    ```php\n    $easyShipApi = $sellerConnector-\u003eeasyShipV20220323();\n    ```\n* **FBA Inbound API (v2024-03-20)** ([docs](https://developer-docs.amazon.com/sp-api/docs/fulfillment-inbound-api-v2024-03-20-reference))\n    ```php\n    $fbaInboundApi = $sellerConnector-\u003efbaInboundV20240320();\n    ```\n* **FBA Inbound API (v0)** ([docs](https://developer-docs.amazon.com/sp-api/docs/fulfillment-inbound-api-v0-reference))\n    ```php\n    $fbaInboundApi = $sellerConnector-\u003efbaInboundV0();\n    ```\n* **FBA Inbound Eligibility API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/fbainboundeligibility-api-v1-reference))\n    ```php\n    $fbaInboundEligibility = $sellerConnector-\u003efbaInboundEligibilityV1();\n    ```\n* **FBA Inventory API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/fbainventory-api-v1-reference))\n    ```php\n    $fbaInventoryApi = $sellerConnector-\u003efbaInventoryV1();\n    ```\n* **FBA Outbound API (v2020-07-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/fulfillment-outbound-api-v2020-07-01-reference))\n    ```php\n    $fbaOutboundApi = $sellerConnector-\u003efbaOutboundV20200701();\n    ```\n* **Feeds API (v2021-06-30)** ([docs](https://developer-docs.amazon.com/sp-api/docs/feeds-api-v2021-06-30-reference))\n    ```php\n    $feedsApi = $sellerConnector-\u003efeedsV20210630();\n    ```\n* **Finances API (v2024-06-19)** ([docs](https://developer-docs.amazon.com/sp-api/docs/finances-api-v2024-06-19-reference))\n    ```php\n    $financesApi = $sellerConnector-\u003efinancesV20240619();\n    ```\n* **Finances API (v0)** ([docs](https://developer-docs.amazon.com/sp-api/docs/finances-api-reference))\n    ```php\n    $financesApi = $sellerConnector-\u003efinancesV0();\n    ```\n* **Invoices API (v2024-06-19)** ([docs](https://developer-docs.amazon.com/sp-api/docs/invoices-api-v2024-06-19-reference))\n    ```php\n    $invoicesApi = $sellerConnector-\u003einvoicesV20240619();\n    ```\n* **Listings Items API (v2021-08-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2021-08-01-reference))\n    ```php\n    $listingsItemsApi = $sellerConnector-\u003elistingsItemsV20210801();\n    ```\n* **Listings Items API (v2020-09-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/listings-items-api-v2020-09-01-reference))\n    ```php\n    $listingsItemsApi = $sellerConnector-\u003elistingsItemsV20200901();\n    ```\n* **Listings Restrictions API (v2021-08-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/listings-restrictions-api-v2021-08-01-reference))\n    ```php\n    $listingsRestrictionsApi = $sellerConnector-\u003elistingsRestrictionsV20210801();\n    ```\n* **Merchant Fulfillment API (v0)** ([docs](https://developer-docs.amazon.com/sp-api/docs/merchant-fulfillment-api-v0-reference))\n    ```php\n    $merchantFulfillmentApi = $sellerConnector-\u003emerchantFulfillmentV0();\n    ```\n* **Messaging API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/merchant-fulfillment-api-v0-reference))\n    ```php\n    $messagingApi = $sellerConnector-\u003emessagingV1();\n    ```\n* **Notifications API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/notifications-api-v1-reference))\n    ```php\n    $notificationsApi = $sellerConnector-\u003enotificationsV1();\n    ```\n* **Orders API (v0)** ([docs](https://developer-docs.amazon.com/sp-api/docs/orders-api-v0-reference))\n    ```php\n    $ordersApi = $sellerConnector-\u003eordersV0();\n    ```\n* **Product Fees API (v0)** ([docs](https://developer-docs.amazon.com/sp-api/docs/product-fees-api-v0-reference))\n    ```php\n    $productFeesApi = $sellerConnector-\u003eproductFeesV0();\n    ```\n* **Product Pricing API (v2022-05-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/product-pricing-api-v2022-05-01-reference))\n    ```php\n    $productPricingApi = $sellerConnector-\u003eproductPricingV20220501();\n    ```\n* **Product Pricing API (v0)** ([docs](https://developer-docs.amazon.com/sp-api/docs/product-pricing-api-v0-reference))\n    ```php\n    $productPricingApi = $sellerConnector-\u003eproductPricingV0();\n    ```\n* **Product Type Definitions API (v2020-09-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/product-type-definitions-api-v2020-09-01-reference))\n    ```php\n    $productTypeDefinitionsApi = $sellerConnector-\u003eproductTypeDefinitionsV20200901();\n    ```\n* **Replenishment API (v2022-11-07)** ([docs](https://developer-docs.amazon.com/sp-api/docs/replenishment-api-v2022-11-07-use-case-guide))\n    ```php\n    $replenishmentApi = $sellerConnector-\u003ereplenishmentV20221107();\n    ```\n* **Reports API (v2021-06-30)** ([docs](https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference))\n    ```php\n    $reportsApi = $sellerConnector-\u003ereportsV20210630();\n    ```\n* **Sales API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/sales-api-v1-reference))\n    ```php\n    $salesApi = $sellerConnector-\u003esalesV1();\n    ```\n* **Sellers API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/sellers-api-v1-reference))\n    ```php\n    $sellersApi = $sellerConnector-\u003esellersV1();\n    ```\n* **Seller Wallet API (v2024-03-01)** ([docs](https://developer-docs.amazon.com/sp-api/reference/seller-wallet-v2024-03-01))\n    ```php\n    $sellerWalletApi = $sellerConnector-\u003esellerWalletV20240301();\n    ```\n* **Services API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/services-api-v1-reference))\n    ```php\n    $servicesApi = $sellerConnector-\u003eservicesV1();\n    ```\n* **Shipment Invoicing API (v0)** ([docs](https://developer-docs.amazon.com/sp-api/docs/shipment-invoicing-api-v0-reference))\n    ```php\n    $shipmentInvoicingApi = $sellerConnector-\u003eshipmentInvoicingV0();\n    ```\n* **Shipping API (v2)** ([docs](https://developer-docs.amazon.com/amazon-shipping/docs/shipping-api-v2-reference))\n    ```php\n    $shippingApi = $sellerConnector-\u003eshippingV2();\n    ```\n* **Shipping API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/shipping-api-v1-reference))\n    ```php\n    $shippingApi = $sellerConnector-\u003eshippingV1();\n    ```\n* **Solicitations API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/solicitations-api-v1-reference))\n    ```php\n    $solicitationsApi = $sellerConnector-\u003esolicitationsV1();\n    ```\n* **Supply Sources API (v2020-07-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/supply-sources-api-v2020-07-01-reference))\n    ```php\n    $supplySourcesApi = $sellerConnector-\u003esupplySourcesV20200701();\n    ```\n* **Tokens API (v2021-03-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/tokens-api-v2021-03-01-reference))\n    ```php\n    $tokensApi = $sellerConnector-\u003etokensV20210301();\n    ```\n* **Transfers API (v2024-06-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/transfers-api-v2024-06-01-reference))\n    ```php\n    $transfersApi = $sellerConnector-\u003etransfersV20240601();\n    ```\n* **Uploads API (v2020-11-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/uploads-api-reference))\n    ```php\n    $uploadsApi = $sellerConnector-\u003euploadsV20201101();\n    ```\n* **Vehicles API (v2024-11-01)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vehicles-api-v2024-11-01-reference))\n    ```php\n    $vehiclesApi = $sellerConnector-\u003evehiclesV20241101();\n    ```\n\n### Vendor APIs\n\nVendor APIs are accessed via the `SellingPartnerApi::vendor()` method:\n\n```php\n\u003c?php\nuse SellingPartnerApi\\SellingPartnerApi;\n\n$vendorConnector = SellingPartnerApi::vendor(/* ... */);\n```\n\n* **Direct Fulfillment Inventory API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-direct-fulfillment-inventory-api-v1-reference))\n    ```php\n    $directFulfillmentInventoryApi = $vendorConnector-\u003edirectFulfillmentInventoryV1();\n    ```\n* **Direct Fulfillment Orders API (v2021-12-28)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-direct-fulfillment-orders-api-2021-12-28-reference))\n    ```php\n    $directFulfillmentOrdersApi = $vendorConnector-\u003edirectFulfillmentOrdersV20211228();\n    ```\n* **Direct Fulfillment Orders API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-direct-fulfillment-orders-api-v1-reference))\n    ```php\n    $directFulfillmentOrdersApi = $vendorConnector-\u003edirectFulfillmentOrdersV1();\n    ```\n* **Direct Fulfillment Payments API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-direct-fulfillment-payments-api-v1-reference))\n    ```php\n    $directFulfillmentPaymentsApi = $vendorConnector-\u003edirectFulfillmentPaymentsV1();\n    ```\n* **Direct Fulfillment Sandbox API (v2021-10-28)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-direct-fulfillment-sandbox-test-data-api-2021-10-28-reference))\n    ```php\n    $directFulfillmentSandboxApi = $vendorConnector-\u003edirectFulfillmentSandboxV20211028();\n    ```\n* **Direct Fulfillment Shipping API (v2021-12-28)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-direct-fulfillment-shipping-api-2021-12-28-reference))\n    ```php\n    $directFulfillmentShippingApi = $vendorConnector-\u003edirectFulfillmentShippingV20211228();\n    ```\n* **Direct Fulfillment Shipping API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-direct-fulfillment-shipping-api-v1-reference))\n    ```php\n    $directFulfillmentShippingApi = $vendorConnector-\u003edirectFulfillmentShippingV1();\n    ```\n* **Direct Fulfillment Transactions API (v2021-12-28)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-direct-fulfillment-transactions-api-2021-12-28-reference))\n    ```php\n    $directFulfillmentTransactionsApi = $vendorConnector-\u003edirectFulfillmentTransactionsV20211228();\n    ```\n* **Direct Fulfillment Transactions API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-direct-fulfillment-transactions-api-v1-reference))\n    ```php\n    $directFulfillmentTransactionsApi = $vendorConnector-\u003edirectFulfillmentTransactionsV1();\n    ```\n* **Invoices API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-invoices-api-v1-reference))\n    ```php\n    $invoicesApi = $vendorConnector-\u003einvoicesV1();\n    ```\n* **Orders API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-orders-api-v1-reference))\n    ```php\n    $ordersApi = $vendorConnector-\u003eordersV1();\n    ```\n* **Shipments API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-shipments-api-v1-reference))\n    ```php\n    $shipmentsApi = $vendorConnector-\u003eshipmentsV1();\n    ```\n* **Transaction Status API (v1)** ([docs](https://developer-docs.amazon.com/sp-api/docs/vendor-transaction-status-api-v1-reference))\n    ```php\n    $transactionStatusApi = $vendorConnector-\u003etransactionStatusV1();\n    ```\n\n\n## Restricted operations\n\nWhen you call a [restricted operation](https://developer-docs.amazon.com/sp-api/docs/tokens-api-use-case-guide), a Restricted Data Token (RDT) is automatically generated. If you're calling restricted operations that accept a [`dataElements`](https://developer-docs.amazon.com/sp-api/docs/tokens-api-use-case-guide#restricted-operations) parameter, specify the restricted data elements you want to retrieve in the `dataElements` parameter of `SellingPartnerApi::make()`. Currently, `getOrder`, `getOrders`, and `getOrderItems` are the only restricted operations that take a `dataElements` parameter.\n\nNote that if you want to call a restricted operation on a sandbox endpoint (e.g., `Endpoint::NA_SANDBOX`), you *should not* specify any `dataElements`. RDTs are not necessary for restricted operations in the sandbox.\n\nIf you would like to make calls on behalf of a delegatee application, you can specify the `delegatee` parameter in `SellingPartnerApi::make()`. This will cause the connector to generate a token for the delegatee application instead of the main application.\n\n\n## Uploading and downloading documents\n\nThe Feeds and Reports APIs include operations that involve uploading and downloading documents to and from Amazon. This library has integrated supports for uploading and downloading documents on the relevant DTOs: `ReportDocument`, `CreateFeedDocumentResponse`, and `FeedDocument`, which are the result of calling [`getReportDocument`](https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-reference#getreportdocument), [`createFeedDocument`](https://developer-docs.amazon.com/sp-api/docs/feeds-api-v2021-06-30-reference#createfeeddocument), and [`getFeedDocument`](https://developer-docs.amazon.com/sp-api/docs/feeds-api-v2021-06-30-reference#getfeeddocument), respectively.\n\n### Downloading a report document\n\n```php\nuse SellingPartnerApi\\SellingPartnerApi;\n\n$reportType = 'GET_MERCHANT_LISTINGS_DATA';\n// Assume we already got a report document ID from a previous getReport call\n$documentId = '1234567890.asdf';\n\n$connector = SellingPartnerApi::seller(/* ... */);\n$response = $connector-\u003ereportsV20210630()-\u003egetReportDocument($documentId, $reportType);\n\n$reportDocument = $response-\u003edto();\n\n/*\n * - Array of arrays, where each sub array corresponds to a row of the report, if this is a TSV, CSV, or XLSX report\n * - A nested associative array (from json_decode) if this is a JSON report\n * - The raw report data if this is a TXT or PDF report\n * - A SimpleXMLElement object if this is an XML report\n */\n$contents = $reportDocument-\u003edownload($reportType);\n```\n\nThe `download` method has four parameters:\n* `documentType` (string): The report type (or feed type of the feed result document being fetched). This is required if you want the document data parsed for you.\n* `postProcess` (bool): Whether to postprocess the document data. If `true`, the document data will be parsed and formatted into a more usable format. If `false`, the raw document text will be returned. Defaults to `true`.\n* `encoding` (string): The encoding of the document data. Defaults to `UTF-8`.\n* `client` (`GuzzleHttp\\Client`): An optional custom Guzzle client to use to download the document.\n\nIf you are working with huge documents you can use `downloadStream()` to minimize the memory consumption. `downloadStream()` returns a `Psr\\Http\\Message\\StreamInterface`. `downloadStream()` also has an optional `$client` parameter.\n\n```php\n$streamContents = $reportDocument-\u003edownloadStream();  // The raw report stream\n```\n\n### Uploading a feed document\n\n```php\nuse SellingPartnerApi\\Seller\\FeedsV20210630\\Dto\\CreateFeedDocumentSpecification;\nuse SellingPartnerApi\\Seller\\FeedsV20210630\\Dto\\CreateFeedSpecification;\nuse SellingPartnerApi\\Seller\\FeedsV20210630\\Responses\\CreateFeedDocumentResponse;\n\n$feedType = 'POST_PRODUCT_PRICING_DATA';\n\n$connector = SellingPartnerApi::seller(/* ... */);\n$feedsApi = $connector-\u003efeedsV20210630();\n\n// Create feed document\n$contentType = CreateFeedDocumentResponse::getContentType($feedType);\n$createFeedDoc = new CreateFeedDocumentSpecification($contentType);\n$createDocumentResponse = $feedsApi-\u003ecreateFeedDocument($createFeedDoc);\n$feedDocument = $createDocumentResponse-\u003edto();\n\n// Upload feed contents to document\n$feedContents = file_get_contents('your/feed/file.xml');\n$feedDocument-\u003eupload($feedType, $feedContents);\n\n$createFeedSpec = new CreateFeedSpecification(\n    marketplaceIds: ['ATVPDKIKX0DER'],\n    inputFeedDocumentId: $feedDocument-\u003efeedDocumentId,\n    feedType: $feedType,\n);\n\n// Create feed with the feed document we just uploaded\n$createFeedResponse = $feedsApi-\u003ecreateFeed($createFeedSpec);\n$feedId = $createFeedResponse-\u003edto()-\u003efeedId;\n```\n\nIf you are working with feed documents that are too large to fit in memory, you can pass anything that Guzzle can turn into a stream into `FeedDocument::upload()` instead of a string. `FeedDocument::upload()` also has an optional `$client` parameter, for passing custom Guzzle clients.\n\n\n## Downloading a feed result document\n\nThis process is very similar to downloading a report document:\n\n```php\nuse SellingPartnerApi\\SellingPartnerApi;\n\n$feedType = 'POST_PRODUCT_PRICING_DATA';\n// Assume we already got a feed result document ID from a previous getFeed call\n$documentId = '1234567890.asdf';\n\n$connector = SellingPartnerApi::seller(/* ... */);\n$response = $connector-\u003efeedsV20210630()-\u003egetFeedDocument($documentId);\n$feedDocument = $response-\u003edto();\n\n$contents = $feedResultDocument-\u003edownload($feedType);\n```\n\n## OAuth\n\nThe Selling Partner API OAuth flow is fully documented [here](https://developer-docs.amazon.com/sp-api/docs/website-authorization-workflow). I highly recommend reading that page in its entirety before trying to implement the OAuth flow.\n\nOnce your SP API application is configured for OAuth by specifying login and redirect URIs, you can use this library's [`OAuth`](https://github.com/jlevers/selling-partner-api/tree/main/src/OAuth.php) connector to generate the authorization URIs you need, and to convert incoming OAuth requests into working client credentials.\n\n### Building authorization URIs\n\nTo create a seller-specific authorization URI, you'll need:\n* Your app's ID, LWA client ID and secret\n* A redirect URI that matches one you specified in your application config in Seller Central\n* A base64-encoded state string, which is used to verify that the authorization request was not altered\n\nThen, all you need to do is:\n\n```php\nuse SellingPartnerApi\\Enums\\Marketplace;\nuse SellingPartnerApi\\OAuth;\n\n$oauth = new OAuth(\n    clientId: 'amzn1.application-oa2-client.asdfqwertyuiop...',\n    clientSecret: 'amzn1.oa2-cs.v1.1234567890asdfghjkl...',\n    redirectUri: 'https://example.com/redirect',\n);\n\n$authUrl = $oauth-\u003egetAuthorizationUri(\n    appId: 'amzn1.sp.solution...',\n    state: 'unique-base64-encoded-string',\n    // The marketplace that you want to authorize the seller in\n    marketplace: Marketplace::US,\n    // If your app is published on the Marketplace Appstore, pass this parameter:\n    // draftApp: false,\n);\n\n// Redirect your user to $authUrl...\n```\n\n### Generating a refresh token from an authorization code\n\nThe other half of the OAuth equation is receiving the inbound request from Amazon when the user finishes the authorization flow, and converting the authorization code from that request into working SP API credentials. Amazon sends that authorization code to the redirect URI you specified in the authorization URI, in the `spapi_oauth_code` query parameter. Once you've verified that the incoming `state` parameter matches the `state` value passed to `OAuth::getAuthorizationUri()`, you can generate a refresh token like so:\n\n```php\nuse SellingPartnerApi\\OAuth;\n\n// Parse query parameters from inbound Amazon request...\n$authCode = $query['spapi_oauth_code'];\n\n$oauth = new OAuth(\n    clientId: 'amzn1.application-oa2-client.asdfqwertyuiop...',\n    clientSecret: 'amzn1.oa2-cs.v1.1234567890asdfghjkl...',\n    redirectUri: 'https://example.com/redirect',\n);\n\n$refreshToken = $oauth-\u003egetRefreshToken($authCode);\n```\n\nNow you can pass `$refreshToken` to `SellingPartnerApi::seller()` in order to make calls to the SP API as the seller that you authorized!\n\n\n## Naming conventions\n\nWherever possible, the names of the classes, methods, and properties in this package are identical to the names used in the Selling Partner API documentation. There are limited cases where this is not true, such as where the SP API documentation itself is inconsistent: for instance, there are some cases the SP API docs name properties in `UpperCamelCase` instead of `camelCase`, and in those cases the properties are named in `camelCase` in this package. Methods are named in `camelCase`, and DTOs are named in `UpperCamelCase`.\n\nInstead of maintaining a redundant set of documentation, we link to the official SP API documentation whenever possible. If it's unclear how to use a particular method or DTO, check out the corresponding section of the [official SP API documentation](https://developer-docs.amazon.com/sp-api/docs/welcome).\n","funding_links":["https://github.com/sponsors/jlevers","https://www.paypal.com/donate?business=EL4PRLAEMGXNQ\u0026currency_code=USD"],"categories":["Docs"],"sub_categories":["Library"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlevers%2Fselling-partner-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjlevers%2Fselling-partner-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlevers%2Fselling-partner-api/lists"}