Amazon Product Advertising API V5.0 (Without Amazon SDK). This repository contains a lightweight PHP (~200 KB) wrapper library,
Easily access the Amazon Product Advertising API V5.0 from your app.
-- Become an Amazon Affiliate With PHP --
composer require jakiboy/apaapi
- 1 - Download repository ZIP (Latest version).
- 2 - Extract ZIP (apaapi-main).
- 3 - Include this lines beelow (apaapi self-autoloader).
include('apaapi-main/src/Autoloader.php');
\apaapi\Autoloader::init();
- 4 - You can now use the Quickstart examples.
- Request Builder (Easier way to fetch data).
- Response Normalizer (Normalize response items).
- Search Filters (Using builder).
- Geotargeting (Automatically redirect links based on the visitor's region).
- Rating Stars (Lagacy).
- Keyword Converter (ASIN, ISBN, EAN, Node, Root).
- Caching System (Basic built-in cache to reduce API calls).
Tip
For PHP < 8.2, please use previous version.
- "_KEY_" : From your Amazon Associates (your locale), More.
- "_SECRET_" : From your Amazon Associates (your locale), More.
- "_TAG_" : From your Amazon Associates (your locale), More.
- "_LOCALE_" : TLD of the target marketplace to which you are sending requests (com/fr/co.jp), Get TLD.
- "_KEYWORDS_" : What you are looking for (Products), More.
- "_ASIN_" : Accepts (ISBN), Amazon Standard Identification Number (your locale), More.
- "_NODE_" : Browse Node ID (your locale), More.
Recommended: Using Apaapi builder.
/**
* @see Use Composer,
* Or include Apaapi Autoloader Here.
*/
use Apaapi\includes\Builder;
// (1) Init request builder
$builder = new Builder('_KEY_', '_SECRET_', '_TAG_', '_LOCALE_');
// (2) Get response (Search)
$data = $builder->searchOne('Sony Xperia Pro-I'); // Normalized array
Note
See full builder usage at /wiki/Builder
Extensible search method.
use Apaapi\operations\SearchItems;
use Apaapi\lib\Request;
use Apaapi\lib\Response;
// (1) Set operation
$operation = new SearchItems();
$operation->setPartnerTag('_TAG_')->setKeywords('_KEYWORDS_');
// (2) Prapere request
$request = new Request('_KEY_', '_SECRET_');
$request->setLocale('_LOCALE_')->setPayload($operation);
// (3) Get response
$response = new Response($request);
$data = $response->get(); // Array
Note
See all available TLDs used by setLocale() at /wiki/TLDs
Extensible get method.
use Apaapi\operations\GetItems;
use Apaapi\lib\Request;
use Apaapi\lib\Response;
// Set operation
$operation = new GetItems();
$operation->setPartnerTag('_TAG_')->setItemIds(['_ASIN_']);
// Prapere request
$request = new Request('_KEY_', '_SECRET_');
$request->setLocale('_LOCALE_')->setPayload($operation);
// Get response
$response = new Response($request);
$data = $response->get(); // Array
All available operations.
use Apaapi\operations\GetItems;
use Apaapi\operations\SearchItems;
use Apaapi\operations\GetVariations;
use Apaapi\operations\GetBrowseNodes;
// (1) GetItems
$operation = new GetItems();
$operation->setPartnerTag('_TAG_');
$operation->setItemIds(['_ASIN_']); // Array
// (2) SearchItems
$operation = new SearchItems();
$operation->setPartnerTag('_TAG_');
$operation->setKeywords('_KEYWORDS_'); // String
// (3) GetVariations
$operation = new GetVariations();
$operation->setPartnerTag('_TAG_');
$operation->setASIN('_ASIN_'); // String
// (4) GetBrowseNodes
$operation = new GetBrowseNodes();
$operation->setPartnerTag('_TAG_');
$operation->setBrowseNodeIds(['_NODE_']); // Array
Optimize response time by setting only the needed resources.
use Apaapi\operations\SearchItems;
// Set Operation
$operation = new SearchItems();
$operation->setPartnerTag('_TAG_')->setKeywords('_KEYWORDS_');
// Set Resources (3)
$operation->setResources(['Images.Primary.Small', 'ItemInfo.Title', 'Offers.Listings.Price']);
Note
See all available resources used by setResources() at /wiki/Resources
Get affiliate cart URL.
use Apaapi\lib\Cart;
// Init Cart
$cart = new Cart();
$cart->setLocale('_LOCALE_')->setPartnerTag('_TAG_');
// Get Response
$data = $cart->set(['_ASIN_' => 3]); // String
Get product average rating and count (Legacy).
use Apaapi\includes\Rating;
// Init Rating
$rating = new Rating('_ASIN_', '_LOCALE_');
// Get Response
$data = $rating->get(); // Array
Note
All available use case examples are located in /examples.
- Credentials-free : Amazon affiliation without credentials to unlock API access.
- Integrated design (HTML/CSS) for both React.js & PHP
- apaapi.js React.js component
- Jakiboy (Initial work)
- Contributors
- Any PR is welcome!
Don't buy me a coffee! Just star the project if you like it.
Important
The Amazon logo included in top of this page refers only to the Amazon Product Advertising API V5.
The Official Amazon SDK (PAAPI5)