This post is now outdated, please view the updated one about the newly released major version 1.0.
On behalf of the PHP team, I ‘m happy to announce the initial release of the Tradenity PHP SDK. The SDK Ruby API was carefully designed to make accessing the Tradenity REST API a seamless experience to PHP programmers. It was designed to provide object oriented interface hiding all the HTTP request/response details of the REST API.
To use the Tradenity SDK, you must have:
For web development, We provide a framework extensions library for both Laravel and Symfony:
You can install the PHP SDK using the standard
composer install tradenity/php-sdk
Now install your framework specific extension library:
composer install tradenity/laravel-ext
composer install tradenity/symfony-ext
First of all, you have to get API keys for your store, you can find it in your store
To get there navigate to the stores list page, click on the
Edit button next to your store name, scroll down till you find the
API Keys section.
With the API key in hand, you can initialize the Tradenity client. Tradenity client needs the API key and an instance of AuthTokenHolder which is an object that makes Tradenity session integrates with the web framework’s session mechanism. The SDK provide implementation for Flask and Django. It’s easy to implement your own for other frameworks, It is a simple 3 method interface.
<?php require 'tradenity' // Initialise the library with your store api key and your framework 's SessionIdAccessor: TradenityClient::$key = 'sk_1234567'; //Add the framework dependent `SessionIdAccessor` (check documentation for details): TradenityClient::$sessionIdAccessor = .... ;
Make sure to replace the api keys with the ones for your store, otherwise you will get authentication error
The Tradenity SDK is organized into a group of model entitiy classes that corresponds to the REST API’s resources, each encapsulate the operation for a specific entity model,
for example to perform operations related to the
Brand resource you can use the corresponding
Now, just call any method in your code.
<?php $brand = Brand::findById("1243-9786786-jhgjtu-789s6i");
We provide 2 sample applications, actually it is the same application implemented using 2 frameworks:
You can find the code at Github:
We also provide a detailed explanation of the code of these sample applications in the form of a step by step tutorials: