Tutorial: Automate your SP-API Calls using prebuilt PHP SDK
Automate your SP-API calls using prebuilt PHP SDK.
This tutorial shows you how to install and integrate prebuilt PHP SDK. You will learn the prerequisites required to install the prebuilt PHP SDK and also view an example using the Selling Partner API for Sellers.
Tutorial
The PHP SDK is published on Packagist and supports PHP 8.3 or higher. The following steps help you install and integrate prebuilt PHP SDK.
Step 1. Add the PHP SDK dependency to your application
Run the following command to add the PHP SDK dependency to your application using composer.
composer require amzn-spapi/sdk
Step 2. Connect the PHP SDK to SP-API
To connect the PHP SDK to the SP-API, you must:
- Configure your LWA credentials
- Create an instance for a specific API
- Call an operation
For an example, refer to the following sample code:
// Configure LWA credentials
$lwaAuthorizationCredentials = new LWAAuthorizationCredentials([
"clientId" => "amzn1.application-*********************",
"clientSecret" => "***********************************",
"refreshToken" => "Atzr|******************************",
"endpoint" => "https://api.amazon.com/auth/o2/token"
]);
$config = new Configuration([], $lwaAuthorizationCredentials);
$config->setHost("https://sellingpartnerapi-na.amazon.com");
// Create a new HTTP client
$client = new GuzzleHttp\Client();
// Create an instance of Orders API
$api = new OrdersApi($config, null, $client);
// Call an operation from Orders API
$result = $api->getOrders($marketplace_ids = ['ATVPDKIKX0DER'],$created_after = '2024-01-01');
Report Issues
You can report issues on GitHub.
Updated 7 days ago
Did this page help you?