The Kwanko API allows you to access your information and data.
It can be used with any programming language to create scripts, bots or integrate data into your own system of information.
API Reference
The Kwanko API is organized around REST. Our API has predictable resource-oriented URLs, returns JSON-encoded responses, and uses standard HTTP response codes, authentication and verbs.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.
API Access for advertisers
To access the Kwanko API, a Kwanko account is mandatory.
For new user, contact our sales teams on our website
Otherwise, log into the platform, and go to the
API Access for publishers
To access the Kwanko API, a Kwanko account is mandatory.
For new user, a registration can be processed on our website
Otherwise, log into the platform, and go to the
The Kwanko API uses a token to authenticate requests.
Important
You only need a token to log to the API.
Each token is unique and associated with a user account, so the entity may have as many tokens as active users who have generated one. If the user is deactivated, the associated token will no longer be valid.
To avoid this, you can create a specific user for the API, and generate the token.
Generate a token
Log into the platform and go to view and manage your token on the or on the
Then, generate a token as follows:
Once generated, the token will not be displayed anymore after leaving or refreshing the API page. For security reasons, we do not keep clear text tokens. If you lose it, you must revoke it and generate a new one.
Token generation is conditioned to an access right. If the generate button appears as disabled (greyed out), please contact your account administrator.
Your API token carries the same privileges you have on the platform, so be sure to keep it secured! Do not share your API token and do not save it in publicly accessible areas such as GitHub, client-side code (like Javascript), and so forth.
If you suspect your token to have been stolen by somebody, you can revoke it on the API page and generate a new one.
Use a token
Tokens are used as HTTP bearer tokens. They are sent alongside every query in the request's Authorization HTTP header (see the lateral panel beside).
Revoke a token
API access tokens can be revoked in the or in the . In that case, the API is no longer available.
Please note that the revocation can only be done by the token's owner.
Restrict by IP address
By providing an IP address allow list, the API will only accept requests to Web API methods if originating from a listed IP addresses.
If the request originates from an IP address not listed in your allow list, it will be rejected and the response will be seen in the lateral panel (Unauthorized IP address).
Navigate to your or your to manage IP restriction.
The IP address restriction section allows you to specify a list of acceptable public IP addresses.
Each entry specifies either a single IP address, or a range of IP addresses or a CIDR range.
For example:
Entering 101.101.101.106 will allow only this specific IP address, and our system will consider it as 101.101.101.106/32.
Writing a range such as 101.101.101.1-101.101.101.10 will allow all 10 IP addresses between 101.101.101.1 and 101.101.101.10 (included).
Presenting a submask like 101.101.101.0/24 will allow all 256 IP addresses between 101.101.101.0 and 101.101.101.255 (included).
"Local" (RFC-1918) IP addresses cannot be whitelisted and IPv6 is not supported.
Request
Requests are composed by the main URL of our API and the endpoint you wanted to reach (e.g: api.kwanko.com/advertisers/statistics or api.kwanko.com/publishers/campaigns).
Requests can be customized by adding a query parameter. Every available parameter is detailed in the corresponding endpoint documentation.
Only parameters marked Mandatory are required.
List of values
Multiple values can be given in a query parameter by using a comma separator.
https://api.kwanko.com/publishers/campaigns/?
campaign_states=
active
https://api.kwanko.com/publishers/campaigns/?
campaign_states=
active,suspended
Response
Kwanko API uses conventional HTTP response codes to indicate the success or failure of an API request.
Codes in the 2xx range indicate success.
Codes in the 4xx range indicate an error due to the request (e.g., a required parameter was omitted, a charge failed, etc.).
Codes in the 5xx range indicate a server error.
Success - HTTP 200
In case of success a JSON object is returned.
Warnings - HTTP 200
In some cases, you can get warnings.
Depending on the type of warning, you may or may not get the result of your request.
Ex: you make a request in which you ask for several columns and one of them doesn't exist. You'll get in return a 200 HTTP code containing the results of your request and a "warnings" entry indicating the missing column.
Ex2: you make a request whose return is too large, you'll only get a 200 HTTP code with only a "warnings" entry telling you to refine your request.
This response includes the following attributes :
type
string
A short string (in English) indicating the error reported.
message
string
A human-readable message (in English) providing more details about the error.
data
array
Data related to the error.
Please notice that several warnings could be returned for the same request.
Errors - HTTP 4xx, 5xx
In case of request failure, an error response is returned as a JSON object.
This response includes the following attributes:
type
string
A short string (in English) indicating the error reported.
message
string
A human-readable message (in English) providing more details about the error.
data
array
Data related to the error.
Please notice that several errors could be returned for the same request.
How to request the Kwanko API:
In this section you will find examples in various languages to request the Kwanko API.
PHP
In PHP you can use the curl library to launch an HTTP request to the Kwanko API.
This example will show you how to use our API to fetch your conversion since the 01/01/2018 with PHP.
For each conversion, it displays its type, its state and its completion date.
// Create a date in ISO format from a date in 'Y-m-d' format.
$dateTime = \DateTime::createFromFormat('Y-m-d', '2018-01-01', new \DateTimeZone('UTC'));
$isoDateFrom = $dateTime->format(\DateTimeInterface::ATOM);
// Create the API url, you can use this page to check the syntax: https://developers.kwanko.com/#syntax.
$url = 'https://api.kwanko.com/publishers/conversions?completion_date_from=' . urlencode($isoDateFrom);
// Initializing and setting up curl library.
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_ACCESS_TOKEN', // Replace YOUR_ACCESS_TOKEN by your API token,
'Content-Type: application/json' // you can check this page to generate one: https://developers.kwanko.com/#authentication
]);
// Launching and storing the result of the request.
$response = curl_exec($curl);
// Handling errors.
$info = curl_getinfo($curl);
$httpCode = $info['http_code'] ?? 0;
if ($httpCode !== 200) {
die('Error status code='.$httpCode.PHP_EOL);
}
// Don't forget to close the connection.
curl_close($curl);
// Decoding the json response.
$data = json_decode($response, true);
// Looping through the conversions.
foreach($data['conversions'] as $conversion) {
// Create a date in 'Y-m-d' format and UTC timezone from a date in ISO format.
$conversionDateTime = \DateTime::createFromFormat(\DateTimeInterface::ATOM, $conversion['completed_at']);
$conversionDateTime->setTimeZone(new \DateTimeZone('UTC'));
$conversionDate = $conversionDateTime->format('Y-m-d');
// Displaying the type, state and the date of the conversion.
echo 'Type: '.$conversion['type'].', State: '.$conversion['state'].', Date: '.$conversionDate.PHP_EOL;
}
Node.js
With Node.js you can require the https library and use the request method.
This example will show you how to use our API to fetch your conversion since the 01/01/2018 with Node.js.
For each conversion, it displays its type, its state and its completion date.
// Create a date in ISO format from a date in 'Y-m-d' format.
// We use toISOString but we remove the milliseconds part,
// and we use +00:00 for the timezone as only this format is supported by the api.
const dateTime = new Date('2018-01-01');
const isoDateFrom = dateTime.toISOString().replace('.000Z', '+00:00');
// Importing the the https library.
const https = require('https');
// Sending the request to the api.
let req = https.request(
{
method: 'GET',
hostname: 'api.kwanko.com',
// You can use this page to check the path syntax: https://developers.kwanko.com/#syntax
path: '/publishers/conversions?completion_date_from=' + encodeURIComponent(isoDateFrom),
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN' // Replace YOUR_ACCESS_TOKEN by your API token,
} // you can check this page to generate one: https://developers.kwanko.com/#authentication
},
(res) => {
// Handling the response.
if (res.statusCode !== 200) {
console.log('Error ' + res.statusCode);
return;
}
let resp = '';
res.on('data', (chunk) => {
resp += chunk;
});
res.on('end', () => {
const data = JSON.parse(resp);
// Looping through the conversions.
for (const conversion of data.conversions) {
// Create a date in 'Y-m-d' format and UTC timezone from a date in ISO format.
// It works because toISOString displays the date in the UTC timezone.
const conversionDateTime = new Date(conversion.completed_at);
const conversionDate = conversionDateTime.toISOString().slice(0, 10);
// Displaying the type, state and the date of the conversion.
console.log('Type: ' + conversion.type + ', State: ' + conversion.state + ', Date: ' + conversionDate);
}
});
}
);
req.on('error', (e) => {
console.error(e.message);
});
req.end();
I can’t generate an API key (token):
You may not have access rights to this feature, ask an administrator of your account to give them to you in the or in the .
I used to have access to the API but now I’m unauthorized:
Check that your token hasn’t been revoked on your or on your .
Check that you still have access rights to the API feature on your or on your .
I would like to get a unique technical access to the API for my company:
You just need to add a new user on your or on your (you need to be an administrator of your account), then use the token from this login.
Some of my websites or campaigns are missing:
You may not have the access rights, check in your user management page on the platform and if you don’t have all the rights, ask an administrator of your account.
The API is not responding:
Do the healthcheck .
I want a unique ID per conversion in GET Conversions:
To do so, you can use the unique_conversion_ID or you can use the kwanko_id by concatenating it with the campaign_id.
The lists below represent the possible values for request parameters and the description of the values returned by the API.