Download the PHP package highsidelabs/laravel-spapi without Composer
On this page you can find all versions of the php package highsidelabs/laravel-spapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download highsidelabs/laravel-spapi
More information about highsidelabs/laravel-spapi
Files in highsidelabs/laravel-spapi
Package laravel-spapi
Short Description A Laravel wrapper for Amazon's Selling Partner API (via jlevers/selling-partner-api)
License BSD-3-Clause
Informations about the package laravel-spapi
Selling Partner API wrapper for Laravel
Simplify connecting to the Selling Partner API with Laravel. Uses 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 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.
Related packages
jlevers/selling-partner-api
: A PHP library for Amazon's Selling Partner API.highsidelabs/laravel-spapi
is a Laravel wrapper aroundjlevers/selling-partner-api
.highsidelabs/walmart-api
: A PHP library for Walmart's seller and supplier APIs, including the Marketplace, Drop Ship Vendor, Content Provider, and Warehouse Supplier APIs.highsidelabs/amazon-business-api
: A PHP library for Amazon's Business API, with a near-identical interface tojlevers/selling-partner-api
.
This package is developed and maintained by Highside Labs. 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 [email protected]. We'd love to hear from you :)
If you've found any of our packages useful, please consider becoming a Sponsor, or making a donation via the button below. We appreciate any and all support you can provide!
There is a more in-depth guide to using this package on our blog.
Installation
Table of Contents
- Overview
- Single-seller mode
- Setup
- Usage
- Multi-seller mode
- Setup
- Usage
- Troubleshooting
Overview
This library has two modes:
- 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).
- 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
Setup
-
Publish the config file:
- Add these environment variables to your
.env
:
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
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. 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.
Multi-seller mode
Setup
-
Publish the config file:
-
Change the
installation_type
inconfig/spapi.php
tomulti
. -
Publish the multi-seller migrations:
- Run the database migrations to set up the
spapi_sellers
andspapi_credentials
tables (corresponding to theHighsideLabs\LaravelSpApi\Models\Seller
andHighsideLabs\LaravelSpApi\Models\Credentials
models, respectively):
Usage
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.
[!NOTE]
client_id
andclient_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 leaveclient_id
andclient_secret
empty, the library will try to load those values from theSPAPI_LWA_CLIENT_ID
andSPAPI_LWA_CLIENT_SECRET
environment variables that are used in 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:
The same goes for a VendorConnector
instance:
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:
All versions of laravel-spapi with dependencies
illuminate/support Version ^11.0|^12.0
illuminate/database Version ^11.0|^12.0
illuminate/cache Version ^11.0|^12.0
jlevers/selling-partner-api Version ^7.1