curl --request POST \
--url https://ads.hakumedia.ai/adserve \
--header 'Content-Type: application/json' \
--data '
{
"ID": 11111,
"setID": 123456,
"type": "json"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ID: 11111, setID: 123456, type: 'json'})
};
fetch('https://ads.hakumedia.ai/adserve', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://ads.hakumedia.ai/adserve"
payload = {
"ID": 11111,
"setID": 123456,
"type": "json"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://ads.hakumedia.ai/adserve",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ID' => 11111,
'setID' => 123456,
'type' => 'json'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"status": "SUCCESS",
"placements": [
{
"placement_1": [
{
"banner_id": 123456,
"width": 300,
"height": 200,
"alt_text": 0,
"accompanied_html": "",
"target": "_blank",
"tracking_pixel": "",
"body": "",
"redirect_url": "https://ads.domain.com/redirect.spark?MID=...",
"refresh_url": "",
"refresh_time": 10,
"image_url": "https://ads.domain.com/getad.img/;libID=...",
"accupixel_url": "https://ads.domain.com/adserve/;ID=...",
"is_redirectable": false,
"eligible_url": "https://ads.domain.com/adserve/;MID=XXXX;type=eligibleimpression;...",
"viewable_url": "https://ads.domain.com/adserve/;MID=XXXX;type=viewableimpression;..."
}
]
}
]
}Retrieve an ad (POST)
Developers can use this API to retrieve ads in JSON format.
curl --request POST \
--url https://ads.hakumedia.ai/adserve \
--header 'Content-Type: application/json' \
--data '
{
"ID": 11111,
"setID": 123456,
"type": "json"
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ID: 11111, setID: 123456, type: 'json'})
};
fetch('https://ads.hakumedia.ai/adserve', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://ads.hakumedia.ai/adserve"
payload = {
"ID": 11111,
"setID": 123456,
"type": "json"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://ads.hakumedia.ai/adserve",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'ID' => 11111,
'setID' => 123456,
'type' => 'json'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"status": "SUCCESS",
"placements": [
{
"placement_1": [
{
"banner_id": 123456,
"width": 300,
"height": 200,
"alt_text": 0,
"accompanied_html": "",
"target": "_blank",
"tracking_pixel": "",
"body": "",
"redirect_url": "https://ads.domain.com/redirect.spark?MID=...",
"refresh_url": "",
"refresh_time": 10,
"image_url": "https://ads.domain.com/getad.img/;libID=...",
"accupixel_url": "https://ads.domain.com/adserve/;ID=...",
"is_redirectable": false,
"eligible_url": "https://ads.domain.com/adserve/;MID=XXXX;type=eligibleimpression;...",
"viewable_url": "https://ads.domain.com/adserve/;MID=XXXX;type=viewableimpression;..."
}
]
}
]
}Body
Your Haku account ID.
11111
The zone ID being requested.
123456
Has two possible values: "json" returns the most eligible ad, while "jsonr" returns a list of all eligible ads ordered from most to least eligible.
For more information, read How to request for all eligible ads via API.
"json"
The ad size you expect to receive.
"300x200"
Pass the parameter ;rf=1 if you want to determine whether the ad has a destination URL to which the user will be redirected. If this parameter is present in the request, the response will contain the extra field is_redirectable.
1
Required for Keyword Targeting. Allows you to pass keywords to Haku, for use with keyword targeting. Pass an array of keyword strings.
Required for URL Targeting. Our URL Targeting feature traditionally relies on the HTTP referrer header to know which page our ad requests were made on. However, if you're making server-side requests you can pass it to us directly in the ad request using the ;referrer= parameter.
"https://example.com"
Required for Geographic Targeting. If you're doing server side ad requests, and you want to geographically target your campaigns, you can simply add the ip= query parameter into the request and provide the IPv4 address used for targeting.
"192.169.0.1"
Required for Platform Targeting. The user's User Agent string.
"Roku4640X/DVP-7.70 (297.70E04154A)"
Required for Platform Targeting. The user's device's screen width.
1920
Required for Platform Targeting. The user's device's screen height.
1080
Required for Platform Targeting. The user's device's screen pixel ratio.
3
Required for Unique Delivery or Roadblocks. The pid stands for 'pageID' and is a random number that must be the same for any ad requested from the current page instance.
123456
Required for Unique Delivery. Place represents the number of times a particular zone has been requested on a single page instance, this should be incremented each time the zone is re-requested. Starts from 0, 1, 2, and so on.
1
Required for User Frquency Capping. An array of placement data representing how many times a given placement has been displayed to the user, and it's expiry information.
Show child attributes
Show child attributes
When using Data Keys, use this parameter to pass all the key-value pairs as an object.
{ "bird": "duck", "bug": "ant" }
When using Beacon Signing Keys, use this parameter to defer generating hashes and timestamps such that they can be signed later with a shared key.
false