REST API
Native Ads
Learn how to request native ads using the REST API.
GET
/
request
Native Ads
curl --request GET \
--url https://api-v2.adrop.io/request \
--header 'Authorization: <authorization>'import requests
url = "https://api-v2.adrop.io/request"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api-v2.adrop.io/request', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-v2.adrop.io/request",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-v2.adrop.io/request"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-v2.adrop.io/request")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-v2.adrop.io/request")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"code": 0,
"msg": "OK",
"result": {
"id": "ad_123456",
"format": "nativeAd",
"unit": "YOUR_UNIT_ID",
"w": 320,
"h": 250,
"ad": "<div>...</div>",
"headline": "Ad Title",
"body": "Ad body content goes here.",
"callToAction": "Learn More",
"destinationURL": "https://example.com/landing",
"target": "external",
"profile": {
"displayLogo": "https://cdn.adrop.io/logo.png",
"displayName": "Advertiser Name",
"link": "https://advertiser.com"
}
}
}
{
"code": 0,
"msg": "OK",
"result": {
"id": "ad_123456",
"format": "nativeAd",
"unit": "YOUR_UNIT_ID",
"w": 320,
"h": 250,
"headline": "Ad Title",
"body": "Ad body content goes here.",
"callToAction": "Learn More",
"destinationURL": "https://example.com/landing",
"asset": "https://cdn.adrop.io/creative.jpg",
"pixelTracker": "<img src='...' />",
"imprTracker": "https://api-v2.adrop.io/impression/...",
"clickTracker": "https://api-v2.adrop.io/click/...",
"profile": {
"displayLogo": "https://cdn.adrop.io/logo.png",
"displayName": "Advertiser Name",
"link": "https://advertiser.com"
}
}
}
Native ads are returned as structured data, allowing you to implement custom UI that matches your app or website design.
Request Parameters
Headers
Query Parameters
Context ID for context targeting (optional). Must exactly match a value entered in a context targeting option in the console. See Targeting Settings.
Set to
1 to receive asset URLs and tracking pixels. You must implement impression and click tracking manually in this case.Response
Ad data
Show result properties
Show result properties
{
"code": 0,
"msg": "OK",
"result": {
"id": "ad_123456",
"format": "nativeAd",
"unit": "YOUR_UNIT_ID",
"w": 320,
"h": 250,
"ad": "<div>...</div>",
"headline": "Ad Title",
"body": "Ad body content goes here.",
"callToAction": "Learn More",
"destinationURL": "https://example.com/landing",
"target": "external",
"profile": {
"displayLogo": "https://cdn.adrop.io/logo.png",
"displayName": "Advertiser Name",
"link": "https://advertiser.com"
}
}
}
{
"code": 0,
"msg": "OK",
"result": {
"id": "ad_123456",
"format": "nativeAd",
"unit": "YOUR_UNIT_ID",
"w": 320,
"h": 250,
"headline": "Ad Title",
"body": "Ad body content goes here.",
"callToAction": "Learn More",
"destinationURL": "https://example.com/landing",
"asset": "https://cdn.adrop.io/creative.jpg",
"pixelTracker": "<img src='...' />",
"imprTracker": "https://api-v2.adrop.io/impression/...",
"clickTracker": "https://api-v2.adrop.io/click/...",
"profile": {
"displayLogo": "https://cdn.adrop.io/logo.png",
"displayName": "Advertiser Name",
"link": "https://advertiser.com"
}
}
}
Tracking Implementation
When usingtrackMode=1, you must track impression and click events manually.
Impression Tracking
Call theimprTracker URL when the ad is displayed on screen:
// When ad enters viewport
fetch(response.result.imprTracker);
Click Tracking
Call theclickTracker URL first when the user clicks the ad, then navigate to destinationURL:
function handleAdClick(adData) {
// Track click
fetch(adData.clickTracker).then(() => {
// Navigate to landing page
window.open(adData.destinationURL, '_blank');
});
}
Custom Rendering Example
<div class="native-ad" id="native-ad-container">
<div class="ad-profile">
<img class="ad-logo" />
<span class="ad-advertiser"></span>
</div>
<img class="ad-image" />
<h3 class="ad-headline"></h3>
<p class="ad-body"></p>
<button class="ad-cta"></button>
</div>
<script>
fetch('https://api-v2.adrop.io/request?unit=YOUR_UNIT_ID&trackMode=1', {
headers: { 'Authorization': 'YOUR_APP_KEY' }
})
.then(res => res.json())
.then(data => {
if (data.code === 0) {
const ad = data.result;
// Render ad content
document.querySelector('.ad-logo').src = ad.profile.displayLogo;
document.querySelector('.ad-advertiser').textContent = ad.profile.displayName;
document.querySelector('.ad-image').src = ad.asset;
document.querySelector('.ad-headline').textContent = ad.headline;
document.querySelector('.ad-body').textContent = ad.body;
document.querySelector('.ad-cta').textContent = ad.callToAction;
// Track impression
fetch(ad.imprTracker);
// Click event
document.getElementById('native-ad-container').onclick = () => {
fetch(ad.clickTracker).then(() => {
window.open(ad.destinationURL, '_blank');
});
};
}
});
</script>
Related Documentation
Banner Ads
HTML banner ad implementation
Targeting Settings
User properties and targeting configuration
Was this page helpful?
⌘I
Native Ads
curl --request GET \
--url https://api-v2.adrop.io/request \
--header 'Authorization: <authorization>'import requests
url = "https://api-v2.adrop.io/request"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api-v2.adrop.io/request', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-v2.adrop.io/request",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-v2.adrop.io/request"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api-v2.adrop.io/request")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-v2.adrop.io/request")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"code": 0,
"msg": "OK",
"result": {
"id": "ad_123456",
"format": "nativeAd",
"unit": "YOUR_UNIT_ID",
"w": 320,
"h": 250,
"ad": "<div>...</div>",
"headline": "Ad Title",
"body": "Ad body content goes here.",
"callToAction": "Learn More",
"destinationURL": "https://example.com/landing",
"target": "external",
"profile": {
"displayLogo": "https://cdn.adrop.io/logo.png",
"displayName": "Advertiser Name",
"link": "https://advertiser.com"
}
}
}
{
"code": 0,
"msg": "OK",
"result": {
"id": "ad_123456",
"format": "nativeAd",
"unit": "YOUR_UNIT_ID",
"w": 320,
"h": 250,
"headline": "Ad Title",
"body": "Ad body content goes here.",
"callToAction": "Learn More",
"destinationURL": "https://example.com/landing",
"asset": "https://cdn.adrop.io/creative.jpg",
"pixelTracker": "<img src='...' />",
"imprTracker": "https://api-v2.adrop.io/impression/...",
"clickTracker": "https://api-v2.adrop.io/click/...",
"profile": {
"displayLogo": "https://cdn.adrop.io/logo.png",
"displayName": "Advertiser Name",
"link": "https://advertiser.com"
}
}
}