Executable Code Samples

Run a quick spike of our API with our pre-created ads. Just copy our examples below - no API key needed!

Post here: https://e-23.adzerk.net/api/v2

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <title>Adzerk Decision API - JavaScript Request</title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script type="text/javascript">
      nativeAdRequest = function() {
        var data = JSON.stringify({
          "placements": [{
            "divName": "div1",
            "networkId": 23,
            "siteId": 667480,
            "adTypes": [5],
            "properties": {"foo": "bar"}
          "keywords": ["adzerk", "demo"]
          url: "https://e-23.adzerk.net/api/v2",
          method: "POST",    
          dataType: 'json',
          data: data,
          success: function(data, status, xhr) {
            console.log("SUCCESS!!!", data);
            // record the impression; REQUIRED
            console.log("Impression URL: ", data.decisions.div1.impressionUrl, "\n");
            $.ajax({url: data.decisions.div1.impressionUrl, method: "GET"});

            // log & display the response
            console.log("Adzerk response:", data.decisions.div1);
            console.log("Click URL: ", data.decisions.div1.clickUrl);         
          error: function(data, status, xhr) {
            console.log("ERROR!!!", data, status)
    <h1>Adzerk Decision API - JavaScript Request</h1>
    <p>Press the button to make a Decision ad request, record the impression, and display both the internal JSON and HTML payload of the response.  Also, check the console for logs!</p>

    <button type="button" onclick="nativeAdRequest()">Request an Ad</button>

    <code id="response">(Nothing yet; please click the button!)</code>

    <div id="div1"><code>(Nothing yet; please click the button!)</code></div>

curl -H 'Content-Type:application/json' \
  -X POST \
  -d '{"placements":[{
  "user":{"key":"abc"}}' \
require 'net/http'
require 'uri'
require 'json'

uri = URI.parse("https://e-23.adzerk.net/api/v2")
header = {'Content-Type': 'application/json'}

data = {
  placements: [
      divName:   'div1',
      networkId: 23,
      siteId:    667480,
      adTypes:   [5]
  user: {"key":"abc"}

# Create the HTTP objects
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri, header)
request.body = data.to_json

# Send the request
response = http.request(request)
puts response.body
package com.adzerk.examples;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

import javax.net.ssl.HttpsURLConnection;

class AdzerkNativeAdExample {

  public static void main(String[] args) throws Exception {
    System.out.println("\nTesting - Sending HTTP POST request...");

    URL url = new URL("https://e-23.adzerk.net/api/v2");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();

    // Add request headers
    conn.setRequestProperty("Content-Type", "application/json");
    // Normally you'd use JSON here, but we've compressed it into a String for ease of instruction
    String params = "{\"placements\":[{\"divName\":\"div1\",\"networkId\":23,\"siteId\":667480,\"adTypes\":[5]}],\"user\":{\"key\":\"abc\"}}";

    // Send post request
    DataOutputStream wr = new DataOutputStream(conn.getOutputStream());

    int responseCode = conn.getResponseCode();
    System.out.println("\nSending 'POST' request to URL : " + url);
    System.out.println("Post parameters : " + params);
    System.out.println("Response Code : " + responseCode);

    BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String inputLine;
    StringBuffer response = new StringBuffer();

    while ((inputLine = in.readLine()) != null) {

Or, Test With JSFiddle

Click on 'Request Ad' in the Result tab to see the Response data.

Adzerk is scalable, fast, and always picks the right promotion to show. They are easily the leading solution in the market.
David Han, VP of Product, Ticketmaster

Learn how Adzerk can help you build your own ad server in weeks, not years

Sign-up and start building