PHPackages                             vismutx/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. [API Development](/categories/api)
4. /
5. vismutx/laravel-spapi

ActiveLibrary[API Development](/categories/api)

vismutx/laravel-spapi
=====================

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

04PHP

Since Jul 6Pushed 2y agoCompare

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

READMEChangelog (3)DependenciesVersions (1)Used By (0)

 [ ![](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.

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

---

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 --provider="HighsideLabs\LaravelSpApi\SellingPartnerApiServiceProvider" --tag="config"
```

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

```
SPAPI_AWS_ACCESS_KEY_ID=
SPAPI_AWS_SECRET_ACCESS_KEY=
SPAPI_LWA_CLIENT_ID=
SPAPI_LWA_CLIENT_SECRET=
SPAPI_LWA_REFRESH_TOKEN=

# Optional
# SPAPI_AWS_ROLE_ARN=
# SPAPI_ENDPOINT_REGION=
```

If in Seller Central, you configured your SP API app with an IAM role ARN rather than an IAM user ARN, you'll need to put that ARN in the `SPAPI_AWS_ROLE_ARN` environment variable. Otherwise, you can leave it blank. 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).

You're ready to go!

### Usage

[](#usage)

All of the API classes supported by [jlevers/selling-partner-api](https://github.com/jlevers/selling-partner-api#supported-api-segments) can be type-hinted. This example assumes you have access to the `Selling Partner Insights` role in your SP API app configuration (so that you can call `SellersV1Api::getMarketplaceParticipations()`), but the same principle applies to type-hinting any other Selling Partner API class.

```
use Illuminate\Http\JsonResponse;
use SellingPartnerApi\Api\SellersV1Api as SellersApi;
use SellingPartnerApi\ApiException;

class SpApiController extends Controller
{
    public function index(SellersApi $api): JsonResponse
    {
        try {
            $result = $api->getMarketplaceParticipations();
            return response()->json($result);
        } catch (ApiException $e) {
            $jsonBody = json_decode($e->getResponseBody());
            return response()->json($jsonBody, $e->getCode());
        }
    }
}
```

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" --tag="config"
```

2. Update the configuration to support multi-seller usage.

    - Change the `installation_type` in `config/spapi.php` to `multi`.
    - If the different sets of seller credentials you plan to use aren't all associated with the same set of AWS credentials (access key ID, secret access key, and optionally role ARN), make sure to change the `aws.dynamic` key to true. If you don't make that change before running migrations (the next step), the fields for AWS credentials won't be added to the database. (If you're not sure if this change applies to you, it probably doesn't.)
3. Publish the multi-seller migrations:

```
# Publish migrations to database/migrations/
$ php artisan vendor:publish --provider="HighsideLabs\LaravelSpApi\SellingPartnerApiServiceProvider" --tag="multi"
```

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
```

5. Add these environment variables to your `.env` (unless you changed the `aws.dynamic` configuration flag to `true` in step 2):

```
SPAPI_AWS_ACCESS_KEY_ID=
SPAPI_AWS_SECRET_ACCESS_KEY=
```

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

$seller = Models\Seller::create(['name' => 'MySeller']);
$credentials = Models\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|....',

    // If you have the `aws.dynamic` config flag set to true, you'll also need these attributes:
    // 'access_key_id' => 'AKIA....',
    // 'secret_access_key' => '23pasdf....',
    // // Only necessary if you configured your SP API setup with an IAM role ARN, otherwise can be omitted
    // // 'role_arn' => 'arn:aws:iam::....',
]);
```

Once you have credentials in the database, you can use them like this:

```
use HighsideLabs\LaravelSpApi\Models\Credentials;
use Illuminate\Http\JsonResponse;
use SellingPartnerApi\Api\SellersV1Api as SellersApi;
use SellingPartnerApi\ApiException;

class SpApiController extends Controller
{
    public function __construct(SellersApi $api)
    {
        // Retrieve the credentials we just created
        $creds = Credentials::first();
        $this->api = $creds->useOn($api);
        // You can now make calls to the SP API with $creds using $this->api!
    }

    public function index(): JsonResponse
    {
        try {
            $result = $this->api->getMarketplaceParticipations();
            return response()->json($result);
        } catch (ApiException $e) {
            $jsonBody = json_decode($e->getResponseBody());
            return response()->json($jsonBody, $e->getCode());
        }
    }
}
```

Or, if you want to use a Selling Partner API class without auto-injecting it, you can quickly create one like this:

```
use HighsideLabs\LaravelSpApi\SellingPartnerApi;
use SellingPartnerApi\Api\SellersV1Api as SellersApi;

$creds = Credentials::first();
$api = SellingPartnerApi::makeApi(SellersApi::class, $creds);
```

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 89.5% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f17d5028e77838cc4a006e046c9e59da9939eacf028f610b56b7d43e218012fa?d=identicon)[vismut](/maintainers/vismut)

---

Top Contributors

[![jlevers](https://avatars.githubusercontent.com/u/4974856?v=4)](https://github.com/jlevers "jlevers (34 commits)")[![vismutx](https://avatars.githubusercontent.com/u/4721671?v=4)](https://github.com/vismutx "vismutx (3 commits)")[![victorbordo](https://avatars.githubusercontent.com/u/21317928?v=4)](https://github.com/victorbordo "victorbordo (1 commits)")

### Embed Badge

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

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)

PHPackages © 2026

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