Prerequisite

To use Boink™ web API, you need a Boink™ developer account.

Create your application

You can create server or client type applications based on your requirements.

  • Server Type Application

    Creating a Server Type application is the recommended way to use Boink™ API. Your application needs to provide app_id and api_secret to communicate with API.

  • Client Type Application

    Client Type application is based on Boink™ licensing management system. Your application needs to provide app_id, api_secret and a valid license to communicate with API.

Authentication

Once you have created your application. You can get a unique token from Authentication API. Depending on the type of your application, the authentication API requires different credentials.

Server Type

To get an authentication token for server type application, you need to submit a POST HTTP request to api/v1/auth/client with your application id and api secret.

Example:

curl "https://boinkhub.co.nz/api/v1/auth/server" \
		-H "Accept: application/json" \
		    -d "app_id"="YOUR_APP_ID" \
		    -d "api_secret"="YOUR_API_SECRET" \

$url = 'https://boinkhub.co.nz/api/v1/auth/server';
$curl = curl_init();

$headers = [
    'Accept: application/json',
];

$data = [
    'app_id' => 'YOUR_APP_ID',
    'api_secret' => 'YOU_API_SECRET',
];

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

$result = curl_exec($curl);

curl_close($curl);

print_r($result);
								
var request = {
    "async": true,
    "crossDomain": true,
    "url": "https://boinkhub.co.nz/api/v1/auth/server",
    "method": "POST",
    "data": {
        "app_id": "YOUR_APP_ID",
        "api_secret": "YOUR_API_SECRET",
	},
    "headers": {
        "accept": "application/json"
    }
};

$.ajax(request).done(function (response) {
    console.log(response);
});

Once you successfully verified your application credentials, you will get a token which looks like below:

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcHBfaWQiOiJia19hcHBfdGVzdF9hcHBsaWNhdGlvbl8xNDc1OTUxMjkzMCIsImFwaV9zZWNyZXQiOiIzNTc0cHE0NXE1MzJzNzQ0NzY1OTc2czlyODlwMHM3biIsInNjaGVtZV9pZCI6MywiaXNzIjoiaHR0cDpcL1wvaG9tZXN0ZWFkLmFwcFwvYXBpXC92MVwvYXV0aFwvc2VydmVyIiwiaWF0IjoxNDgzNDE1OTE1LCJleHAiOjE0ODM0MjU5OTUsIm5iZiI6MTQ4MzQxNTkxNSwianRpIjoiNTdkN2M0MGM4YzgyMjRkOGY0MWYzNWMxYmQ5MmI3MzUifQ.ZB0rdPSBZuRPTiw1BNV9MpE6lcGDontZ8OTSFp7c_OY

You will need this token to request all the other API resources by adding Authorisation header to each of your request as Authorization: Bearer {YOUR_TOKEN}

First Request

Now you can send your first request with the token above. Let’s get a list of your cards. To get a list of card, you need to send a GET HTTP request to api/v1/card. The maximum of number of cards is 1,000. By default the API returns 1,000 cards.

Example:

curl "https://boinkhub.co.nz/api/v1/scheme/card" \
		-X GET \
		-H "Accept: application/json" \
		-H "Authorization: Bearer YOUR_TOKEN" \

$url = 'https://boinkhub.co.nz/api/v1/scheme/card';

$token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhcHBfaWQiOiJia19hcHBfdGVzdF9hcHBsaWNhdGlvbl8xNDc1OTUxMjkzMCIsImFwaV9zZWNyZXQiOiIzNTc0cHE0NXE1MzJzNzQ0NzY1OTc2czlyODlwMHM3biIsInNjaGVtZV9pZCI6MywiaXNzIjoiaHR0cDpcL1wvaG9tZXN0ZWFkLmFwcFwvYXBpXC92MVwvYXV0aFwvc2VydmVyIiwiaWF0IjoxNDgzNTcwNjkxLCJleHAiOjE0ODM1ODA3NzEsIm5iZiI6MTQ4MzU3MDY5MSwianRpIjoiZmE4NDkzMWU4NWI3YTczNjE0NjYxNjRjNTQ3ODRiNGYifQ.QbnoU6AqeXbwTG8Cv2lMt96gcKSvU2jy7W2XNePQKB4';
$curl = curl_init();

$headers = [
    'Accept: application/json',
    'Authorization: Bearer ' . $token,
];

curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);

curl_close($curl);

var_dump($result);
								
var request = {
    "async": true,
    "crossDomain": true,
    "url": "https://boinkhub.co.nz/api/v1/scheme/card",
    "method": "POST",
    "headers": {
        "accept": "application/json",
        "Authorization": "Bearer YOUR_TOKEN""
    }
};

$.ajax(request).done(function (response) {
    console.log(response);
});

Below is an example of successful response:


[
	{
        "card_number": "1234567800000001",
        "balance": "2101",
        "status": "ACTIVE",
        "expiry_date": "1117",
        "datetime_last_add": "2016-12-20 00:17:56",
        "datetime_last_redeem": "2016-07-14 04:19:36",
        "datetime_last_expire": null,
        "datetime_first_used": "2016-08-31 00:23:21",
        "datetime_last_used": "2016-12-20 00:17:56",
        "add_count": "284",
        "red_count": "130",
        "add_total": "2301078",
        "red_total": "-530469",
        "updated_reason": "Test DescData "
    },
    // ...more data
]
						

Explore more

Congratulations. You have successfully get your first response from Boink™ API. To explore more, please view the API references.