curl "https://ads.hakumedia.ai/adserve/;ID=11111;setID=123456;type=json;size=300x250"const options = {method: 'GET'};
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"
response = requests.get(url)
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 => "GET",
]);
$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 (GET)
Developers can use this API to retrieve ads in JSON format.
Los parámetros van en la ruta, separados por punto y coma: /adserve/;ID=11111;setID=123456;type=json.
curl "https://ads.hakumedia.ai/adserve/;ID=11111;setID=123456;type=json;size=300x250"const options = {method: 'GET'};
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"
response = requests.get(url)
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 => "GET",
]);
$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;..."
}
]
}
]
}Query Parameters
Your Haku account ID.
The Zone ID being requested.
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.
The ad size you expect to receive.
Pass this parameter ;rf=1 if you want to determine whether the ad has a destination URL to which the user will be redirected when the ad is clicked. If this parameter is present in the request, the response will contain the extra field is_redirectable.
Required for Keyword Targeting. Allows you to pass keywords to Haku, for use with keyword targeting. Pass a comma delimited string of keywords. For example ;kw=apples,pears.
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. The URL must be encoded when passing it in this way.
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.
Required for Platform Targeting. The user's User Agent string (URL encoded)
Required for Platform Targeting. The user's device's screen width.
Required for Platform Targeting. The user's device's screen height.
Required for Platform Targeting. The user's device's screen pixel ratio.
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.
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.
When using Data Keys, use this parameter to pass in the key-value pairs.
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.