Welcome to the Walmart Open API PHP Client, a Composer package for interacting with the Walmart Open API.
This library is powered by Guzzle 6 thus requires PHP >= 5.5.0 to work.
Extensive PHPUnit tests are provided, the builds are handled by Travis-CI and test code coverage is calculated by Coveralls.io.
If you notice any bugs or have an idea for improvements, feel free to submit a ticket to the project Issue Tracker.
Pull requests are welcome, just remember to submit them to the develop branch. Any PRs to the master branch will be rejected.
If you don't have Composer already available on your local system, install it first:
curl -sS https://getcomposer.org/installer | php
Create a composer.json file and add an entry in the "require" section:
{
"require": {
"gadoma/walmart-api-php-client": "^1.0"
}
}
Run the below command afterwards:
php composer.phar install
Alternatively to the above method you can just run the following:
php composer.phar require gadoma/walmart-api-php-client:^1.0
In order to use the Walmart Open API you need to obtain an API key. You can get it by registering a Walmart developer account.
// composer autoload
require 'vendor/autoload.php';
//API credentials
$apiKey = 'yourWalmartApiKey';
//Basic components used by the Services
$httpClient = new \GuzzleHttp\Client();
$errorHandler = new \WalmartApiClient\Exception\Handler\ApiExceptionHandler();
$transportService = new \WalmartApiClient\Http\TransportService($httpClient, $errorHandler, $apiUrl);
$entityFactory = new \WalmartApiClient\Factory\EntityFactory();
$collectionFactory = new \WalmartApiClient\Factory\CollectionFactory();
//Actual Services you will use for interacting with the API
$productService = new \WalmartApiClient\Service\ProductService($transportService, $entityFactory, $collectionFactory);
$offerService = new \WalmartApiClient\Service\OfferService($transportService, $entityFactory, $collectionFactory);
$reviewService = new \WalmartApiClient\Service\ReviewService($transportService, $entityFactory, $collectionFactory);
$taxonomyService = new \WalmartApiClient\Service\TaxonomyService($transportService, $entityFactory, $collectionFactory);
It is possible to provide your LinkShare Publisher Id for URL tracking/attribution purposes. It is optional and you can read more about this subject on Walmart Affiliates website. To use your LinkShare Publisher Id with this library, just pass it to TransportService constructor in the process of creating the basic components, like shown below:
$apiKey = 'yourWalmartApiKey';
$linkSharePublisherId = 'yourId';
$httpClient = new \GuzzleHttp\Client();
$errorHandler = new \WalmartApiClient\Exception\Handler\ApiExceptionHandler();
$transportService = new \WalmartApiClient\Http\TransportService($httpClient, $errorHandler, $apiUrl, $linkSharePublisherId);
Each of the available Services is a wrapper for one or more Walmart Open API services. The available methods' declarations and descriptions can be found in the Service interfaces. Each of the methods returns either a single specific Entity (e.g. Product) or a Collection of Entities (e.g. Categories Collection).
- getById
- getByUpc
- getByIds
- getBySearch
- getAllBySearch
- getPostbrowsedById
- getRecommendedById
- getTrending
- getVod
- getPreorder
- getBestsellers
- getRollback
- getClearance
- getSpecialbuy
- getReviews
- getStoresByCoordinates
- getStoresByCity
- getStoresByZip
- getCategories