PHPackages                             highsidelabs/laravel-spapi - 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/laravel-spapi

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

highsidelabs/laravel-spapi
==========================

A Laravel wrapper for Amazon's Selling Partner API (via jlevers/selling-partner-api)

v2.1.2(1y ago)2133.4k↓15%12[1 PRs](https://github.com/highsidelabs/laravel-spapi/pulls)BSD-3-ClausePHPPHP &gt;=8.2

Since Dec 9Pushed 1mo ago2 watchersCompare

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

READMEChangelog (10)Dependencies (7)Versions (20)Used By (0)

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

 [![Total downloads](https://camo.githubusercontent.com/81c66b4ca292dfd29fa9b8a352df576bd0343f28147eb068c968ff938a6e9da3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68696768736964656c6162732f6c61726176656c2d73706170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/highsidelabs/laravel-spapi) [![Latest stable version](https://camo.githubusercontent.com/972fff365be6ec02d75cbc5ef1c6682058dd1e190574d0580d8072cba93f473e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68696768736964656c6162732f6c61726176656c2d73706170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/highsidelabs/laravel-spapi) [![License](https://camo.githubusercontent.com/2574024453dfcdcf108b7379779169ff21579af88ad59164e1f0c285bb75b0c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f68696768736964656c6162732f6c61726176656c2d73706170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/highsidelabs/laravel-spapi)

Selling Partner API wrapper for Laravel
---------------------------------------

[](#selling-partner-api-wrapper-for-laravel)

Simplify connecting to the Selling Partner API with Laravel. Uses [jlevers/selling-partner-api](https://github.com/jlevers/selling-partner-api) under the hood.

Note

There is a lot of boilerplate involved in building a Selling Partner API application: setting up credential management, OAuth, infrastructure for handling feeds and reports, and more. I built an [SP API Laravel starter kit](https://tools.highsidelabs.co) that comes with all that functionality baked in, so you can focus on writing business logic. The starter kit uses this package, along with `jlevers/selling-partner-api`, to make developing SP API applications easier. Read the full documentation [here](https://docs.highsidelabs.co/sp-api-starter-kit).

### 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). `highsidelabs/laravel-spapi` is a Laravel wrapper around `jlevers/selling-partner-api`.
- [`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.
- [`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), with a near-identical interface to `jlevers/selling-partner-api`.

---

**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](https://highsidelabs.co/blog/laravel-selling-partner-api).*

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

[](#installation)

```
$ composer require highsidelabs/laravel-spapi
```

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

[](#table-of-contents)

- [Overview](#overview)
- [Single-seller mode](#single-seller-mode)
    - [Setup](#setup)
    - [Usage](#usage)
- [Multi-seller mode](#multi-seller-mode)
    - [Setup](#setup-1)
    - [Usage](#usage-1)
- [Troubleshooting](#troubleshooting)

---

Overview
--------

[](#overview)

This library has two modes:

1. **Single-seller mode**, which you should use if you only plan to make requests to the Selling Partner API with a single set of credentials (most people fall into this category, so if you're not sure, this is probably you).
2. **Multi-seller mode**, which makes it easy to make requests to the Selling Partner API from within Laravel when you have multiple sets of SP API credentials (for instance, if you operate multiple seller accounts, or operate one seller account in multiple regions).

Single-seller mode
------------------

[](#single-seller-mode)

### Setup

[](#setup)

1. Publish the config file:

```
$ php artisan vendor:publish --tag="spapi-config"
```

2. Add these environment variables to your `.env`:

```
SPAPI_LWA_CLIENT_ID=
SPAPI_LWA_CLIENT_SECRET=
SPAPI_LWA_REFRESH_TOKEN=

# Optional
# SPAPI_ENDPOINT_REGION=
```

Set `SPAPI_ENDPOINT_REGION` to the region code for the endpoint you want to use (EU for Europe, FE for Far East, or NA for North America). The default is North America.

### Usage

[](#usage)

`SellerConnector` and `VendorConnector` can be type-hinted, and the connector classes can be used to create instances of all APIs supported by [jlevers/selling-partner-api](https://github.com/jlevers/selling-partner-api#supported-api-segments). This example assumes you have access to the `Selling Partner Insights` role in your SP API app configuration (so that you can call `SellingPartnerApi\Seller\SellersV1\Api::getMarketplaceParticipations()`), *but the same principle applies to calling any other Selling Partner API endpoint.*

```
use Illuminate\Http\JsonResponse;
use Saloon\Exceptions\Request\RequestException;
use SellingPartnerApi\Seller\SellerConnector;

class SpApiController extends Controller
{
    public function index(SellerConnector $connector): JsonResponse
    {
        try {
            $api = $connector->sellersV1();
            $result = $api->getMarketplaceParticipations();
            return response()->json($result->json());
        } catch (RequestException $e) {
            $response = $e->getResponse();
            return response()->json($response->json(), $e->getStatus());
        }
    }
}
```

Multi-seller mode
-----------------

[](#multi-seller-mode)

### Setup

[](#setup-1)

1. Publish the config file:

```
# Publish config/spapi.php file
$ php artisan vendor:publish --provider="HighsideLabs\LaravelSpApi\SellingPartnerApiServiceProvider"
```

2. Change the `installation_type` in `config/spapi.php` to `multi`.
3. Publish the multi-seller migrations:

```
# Publish migrations to database/migrations/
$ php artisan vendor:publish --tag="spapi-multi-seller"
```

4. Run the database migrations to set up the `spapi_sellers` and `spapi_credentials` tables (corresponding to the `HighsideLabs\LaravelSpApi\Models\Seller` and `HighsideLabs\LaravelSpApi\Models\Credentials` models, respectively):

```
$ php artisan migrate
```

### Usage

[](#usage-1)

First you'll need to create a `Seller`, and some `Credentials` for that seller. The `Seller` and `Credentials` models work just like any other Laravel model.

```
use HighsideLabs\LaravelSpApi\Models\Credentials;
use HighsideLabs\LaravelSpApi\Models\Seller;

$seller = Seller::create(['name' => 'My Seller']);
$credentials = Credentials::create([
    'seller_id' => $seller->id,
    // You can find your selling partner ID/merchant ID by going to
    // https:///sw/AccountInfo/MerchantToken/step/MerchantToken
    'selling_partner_id' => '',
    // Can be NA, EU, or FE
    'region' => 'NA',
    // The LWA client ID and client secret for the SP API application these credentials were created with
    'client_id' => 'amzn....',
    'client_secret' => 'fec9/aw....',
    // The LWA refresh token for this seller
    'refresh_token' => 'IWeB|....',
]);
```

Note

`client_id` and `client_secret` are nullable. If you are authorizing multiple sellers on a single SP API application, they will all use the same client ID and client secret. If you leave `client_id` and `client_secret` empty, the library will try to load those values from the `SPAPI_LWA_CLIENT_ID` and `SPAPI_LWA_CLIENT_SECRET` environment variables that are used in [single-seller mode](#single-seller-mode). That means that the single-seller credentials can effectively be used as master credentials in multi-seller mode.

Once you have credentials in the database, you can use them to retrieve a `SellerConnector` instance, from which you can get an instance of any seller API:

```
use HighsideLabs\LaravelSpApi\Models\Credentials;
use Illuminate\Http\JsonResponse;
use Saloon\Exceptions\Request\RequestException;

$creds = Credentials::first();
/** @var SellingPartnerApi\Seller\SellersV1\Api $api */
$api = $creds->sellerConnector()->sellersV1();

try {
    $result = $api->getMarketplaceParticipations();
    $dto = $result->dto();
} catch (RequestException $e) {
    $responseBody = $e->getResponse()->json();
}
```

The same goes for a `VendorConnector` instance:

```
use HighsideLabs\LaravelSpApi\Models\Credentials;
use Illuminate\Http\JsonResponse;
use Saloon\Exceptions\Request\RequestException;

$creds = Credentials::first();
/** @var SellingPartnerApi\Vendor\DirectFulfillmentShippingV1\Api $api */
$api = $creds->vendorConnector()->directFulfillmentShippingV1();
```

Troubleshooting
---------------

[](#troubleshooting)

If you encounter an error like `String data, right truncated: 7 ERROR:  value too long for type character varying(255)`, it's probably because you're using Laravel's database cache, which by default has a 255-character limit on cache keys and values. This library has a migration available to fix this:

```
$ php artisan vendor:publish --tag="spapi-database-cache"
$ php artisan migrate
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance70

Regular maintenance activity

Popularity40

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 86.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~45 days

Total

19

Last Release

443d ago

Major Versions

0.2.2 → 1.0.02023-02-15

1.2.2 → v2.0.02024-08-06

PHP version history (3 changes)0.1.0PHP &gt;=7.4

1.0.0PHP ^8.0.2|&gt;=8.1

v2.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/03f3b43533bd18c337ac4402910d4977dd0a327927d0a994cec096d8d3269205?d=identicon)[jlevers](/maintainers/jlevers)

---

Top Contributors

[![jlevers](https://avatars.githubusercontent.com/u/4974856?v=4)](https://github.com/jlevers "jlevers (69 commits)")[![MannikJ](https://avatars.githubusercontent.com/u/1841856?v=4)](https://github.com/MannikJ "MannikJ (10 commits)")[![victorbordo](https://avatars.githubusercontent.com/u/21317928?v=4)](https://github.com/victorbordo "victorbordo (1 commits)")

---

Tags

amazonlaravelselling-partner-apilaravelamazonsdkrestwrapperecommercesp-apiselling-partner-api

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/highsidelabs-laravel-spapi/health.svg)

```
[![Health](https://phpackages.com/badges/highsidelabs-laravel-spapi/health.svg)](https://phpackages.com/packages/highsidelabs-laravel-spapi)
```

###  Alternatives

[jlevers/selling-partner-api

PHP client for Amazon's Selling Partner API

4295.2M1](/packages/jlevers-selling-partner-api)[amazon-php/sp-api-sdk

Amazon Selling Partner API - PHP SDK

133374.1k1](/packages/amazon-php-sp-api-sdk)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
