Quickstart

5min

Installation

First, install the klevu/php-sdk library in your application. We recommend using composer to ensure dependencies are managed appropriately, and to hook into autoloading automatically. You can also install directly from source [Github], and handle autoloading yourself.

Shell


Retrieve Your Access Tokens

Next, you will need to locate your JS API Key and REST AUTH Key for the account you are integrating. These can be found under Store Settings > Store Info > Shop Info > Integration when logged into Klevu Merchant Center.

Document image


Note: in our examples we will hardcode these credentials. When building your application, you should save and retrieve them from our existing configuration storage.

Create an Account Credentials Object

Whenever you need to interact with Klevu via one of the public services, you will need to provide the credentials above in a standard format - in this case, the AccountCredentials object.

Create a new PHP script

PHP


Instatiate a Service Class

Finally, choose which service you need to interact with; instatiate its service class; and execute your request.

There are simple code examples for all main services in the How-To, some popular ones are listed below