PHPackages                             highsidelabs/amazon-business-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. highsidelabs/amazon-business-api

ActiveLibrary[HTTP &amp; Networking](/categories/http)

highsidelabs/amazon-business-api
================================

PHP client for Amazon's Business API

1.3.0(2y ago)817.3k↓42.1%3[3 issues](https://github.com/highsidelabs/amazon-business-api/issues)BSD-3-ClausePHPPHP &gt;=7.3

Since Nov 14Pushed 2y agoCompare

[ Source](https://github.com/highsidelabs/amazon-business-api)[ Packagist](https://packagist.org/packages/highsidelabs/amazon-business-api)[ RSS](/packages/highsidelabs-amazon-business-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (7)Used By (0)

 [ ![](https://github.com/highsidelabs/.github/raw/main/images/logo.png?raw=true) ](https://highsidelabs.co)

 [![Total downloads](https://camo.githubusercontent.com/4a7fefa75638b12afe68fd63cb137bae80b64155c21f08801cdd9bfe1eb86793/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68696768736964656c6162732f616d617a6f6e2d627573696e6573732d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/highsidelabs/amazon-business-api) [![Latest stable version](https://camo.githubusercontent.com/9b6fa9ad13783da26ed39e7d56652089452cfe765e48d6df085033451cda9ff6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68696768736964656c6162732f616d617a6f6e2d627573696e6573732d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/highsidelabs/amazon-business-api) [![License](https://camo.githubusercontent.com/38c29c03d46b3a21393ad2a06031e01d68bf5ba3edbf02702c46ce501bc3a3b9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f68696768736964656c6162732f616d617a6f6e2d627573696e6573732d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/highsidelabs/amazon-business-api)

Amazon Business API for PHP
---------------------------

[](#amazon-business-api-for-php)

A PHP library for connecting to Amazon's [Business API](https://developer-docs.amazon.com/amazon-business/).

### Related packages

[](#related-packages)

- [`jlevers/selling-partner-api`](https://github.com/jlevers/selling-partner-api): A PHP library for Amazon's [Selling Partner API](https://developer-docs.amazon.com/sp-api/docs), with a near-identical interface to this package. Our most popular package.
- [`highsidelabs/laravel-spapi`](https://github.com/highsidelabs/laravel-spapi): A [Laravel](https://laravel.com) wrapper for the package above, making SP API integration in Laravel projects quick and easy.
- [`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.

---

**This package is developed and maintained by [Highside Labs](https://highsidelabs.co). If you need support integrating with Amazon's (or any other e-commerce platform's) APIs, we're happy to help! Shoot us an email at . We'd love to hear from you :)**

If you've found any of our packages useful, please consider [becoming a Sponsor](https://github.com/sponsors/highsidelabs), or making a donation via the button below. We appreciate any and all support you can provide!

 [![Donate to Highside Labs](https://camo.githubusercontent.com/e1ff554a09e8e92bef25abc553ff05b88f45afd695877cf12f3a46558ef65b2e/68747470733a2f2f7777772e70617970616c6f626a656374732e636f6d2f656e5f55532f692f62746e2f62746e5f646f6e61746543435f4c472e676966)](https://www.paypal.com/donate/?hosted_button_id=FG8Q6MNB4HJCC)

---

*(There is a more in-depth guide to using this package on our blog, [here](https://www.highsidelabs.co/blog/amazon-business-api).)*

Features
--------

[](#features)

- Supports all Amazon Business API operations as of 11/13/2022 ([see here](#supported-api-segments) for links to documentation for all calls)
- Supports applications made with both IAM user and IAM role ARNs ([docs](#setup))

Installation
------------

[](#installation)

`composer require highsidelabs/amazon-business-api`

Table of Contents
-----------------

[](#table-of-contents)

Check out the [Getting Started](#getting-started) section below for a quick overview.

This README is divided into several sections:

- [Setup](#setup)
    - [Configuration options](#configuration-options)
- [Examples](#examples)
- [Debug mode](#debug-mode)
- [Supported API segments](#supported-api-segments)
- [Working with model classes](#working-with-model-classes)
- [Response headers](#response-headers)
- [Custom request authorization](#custom-authorization-signer)
- [Custom request signing](#custom-request-signer)

Getting Started
---------------

[](#getting-started)

We wrote a blog post with more detailed instructions on connecting to the Amazon Business API [here](https://www.highsidelabs.co/blog/amazon-business-api). Check it out if you need more help getting set up.

### Prerequisites

[](#prerequisites)

You need a few things to get started:

- A Amazon Business API developer account
- An AWS IAM user or role configured for use with the Amazon Business API
- An Amazon Business API application

If you're looking for more information on how to set those things up, check out [this blog post](https://jesseevers.com/selling-partner-api-access/). It provides a detailed walkthrough of the whole setup process. That guide refers to the Selling Partner API, but all the setup steps are the same for the Amazon Business API.

### Setup

[](#setup)

The [`Configuration`](https://github.com/highsidelabs/amazon-business-api/blob/main/lib/Configuration.php) constructor takes a single argument: an associative array with all the configuration information that's needed to connect to the Amazon Business API:

```
$config = new AmazonBusinessApi\Configuration([
    'lwaClientId' => '',
    'lwaClientSecret' => '',
    'lwaRefreshToken' => '',
    'awsAccessKeyId' => '',
    'awsSecretAccessKey' => '',
    // If you're not working in the North American marketplace, change
    // this to another endpoint from lib/Endpoint.php
    'endpoint' => AmazonBusinessApi\Endpoint::NA,
]);
```

If you created your Amazon Business API application using an IAM role ARN instead of a user ARN, pass that role ARN in the configuration array:

```
$config = new AmazonBusinessApi\Configuration([
    'lwaClientId' => '',
    'lwaClientSecret' => '',
    'lwaRefreshToken' => '',
    'awsAccessKeyId' => '',
    'awsSecretAccessKey' => '',
    // If you're not working in the North American marketplace, change
    // this to another endpoint from lib/Endpoint.php
    'endpoint' => AmazonBusinessApi\Endpoint::NA,
    'roleArn' => '',
]);
```

Getter and setter methods exist for the `Configuration` class's `lwaClientId`, `lwaClientSecret`, `lwaRefreshToken`, `awsAccessKeyId`, `awsSecretAccessKey`, and `endpoint` properties. The methods are named in accordance with the name of the property they interact with: `getLwaClientId`, `setLwaClientId`, `getLwaClientSecret`, etc.

`$config` can then be passed into the constructor of any `AmazonBusinessApi\Api\*Api` class. See the `Example` section for a complete example.

##### Configuration options

[](#configuration-options)

The array passed to the `Configuration` constructor accepts the following keys:

- `lwaClientId (string)`: Required. The LWA client ID of the SP API application to use to execute API requests.
- `lwaClientSecret (string)`: Required. The LWA client secret of the SP API application to use to execute API requests.
- `lwaRefreshToken (string)`: Required. The LWA refresh token of the SP API application to use to execute API requests.
- `awsAccessKeyId (string)`: Required. AWS IAM user Access Key ID with SP API ExecuteAPI permissions.
- `awsSecretAccessKey (string)`: Required. AWS IAM user Secret Access Key with SP API ExecuteAPI permissions.
- `endpoint (array)`: Required. An array containing a `url` key (the endpoint URL) and a `region` key (the AWS region). There are predefined constants for these arrays in [`lib/Endpoint.php`](https://github.com/highsidelabs/amazon-business-api/blob/main/lib/Endpoint.php): (`NA`, `EU`, and `FE`. See [here](https://developer-docs.amazon.com/amazon-business/docs/ab-api-endpoints) for more details.
- `accessToken (string)`: An access token generated from the refresh token.
- `accessTokenExpiration (int)`: A Unix timestamp corresponding to the time when the `accessToken` expires. If `accessToken` is given, `accessTokenExpiration` is required (and vice versa).
- `onUpdateCredentials (callable|Closure)`: A callback function to call when a new access token is generated. The function should accept a single argument of type [`AmazonBusinessApi\Credentials`](https://github.com/highsidelabs/amazon-business-api/blob/main/lib/Credentials.php).
- `roleArn (string)`: If you set up your Amazon Business API application with an AWS IAM role ARN instead of a user ARN, pass that ARN here.
- `authenticationClient (GuzzleHttp\ClientInterface)`: Optional `GuzzleHttp\ClientInterface` object that will be used to generate the access token from the refresh token
- `authorizationSigner (AmazonBusinessApi\Contract\AuthorizationSignerContract)`: Optional `AmazonBusinessApi\Contract\AuthorizationSignerContract` implementation. See [Custom Authorization Signer](#custom-authorization-signer) section
- `requestSigner (AmazonBusinessApi\Contract\RequestSignerContract)`: Optional `AmazonBusinessApi\Contract\RequestSignerContract` implementation. See [Custom Request Signer](#custom-request-signer) section.

### Examples

[](#examples)

This example assumes you have access to the `Product Search` Amazon Business API role, but the general format applies to any Amazon Business API request.

```
