Kevel API Quickstart

1. Post

Post an ad request to Kevel when you need a decision made (no JavaScript tags needed).
curl -H 'Content-Type:application/json' \
  -X POST \
  -d '{"placements":[{
  "divName":"div1",
  "networkId":23,
  "siteId":667480,
  "adTypes":[5]}],
  "user":{"key":"abc"}}' \
  \
  https://e-23.adzerk.net/api/v2

2. Parse

Parse the JSON response from Kevel that contains info and tracking links for the winning ad.
{ "user": { "key": "abc" },
  "decisions": {
    "div1": {
      "adID": 1234567,
      "creativeID": 7654321,
      "flightID": 9876543,
      "campaignID": 3456789,
      "clickURL": "https://e-123.kevel.com...",
      "imageURL": "https://e-123.kevel.com...",
      "height": 250,
      "width": 300,
      ...

3. Place

Place the content wherever you want, such as your site, app, OOH digital property, etc.
Quickstart Place
EXECUTABLE CODE SAMPLES

Test out our APIs today

No API key needed!
Test in JSFiddle
import adzerk_decision_sdk

# Demo network, site, and ad type IDs; find your own via the Kevel UI!
client = adzerk_decision_sdk.Client(23, site_id=667480)

request = {
  "placements": [{"adTypes": [5]}],
  "user": {"key": "abc"},
  "keywords": ["keyword1", "keyword2"],
}

response = client.decisions.get(request)
print(response)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>Kevel Decision API - JavaScript Request</title>
    <script type="text/javascript" src="https://unpkg.com/@adzerk/decision-sdk/dist/adzerk-decision-sdk.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script type="text/javascript">
      requestNativeAd = function() {
        // Demo network, site, and ad type IDs; find your own via the Kevel UI!
        let client = new AdzerkDecisionSdk.Client({
          networkId: 23,
          siteId: 667480
        });

        let request = {
          placements: [{
            adTypes: [5]
          }]
        };

        client.decisions.get(request).then(response => {
          let decision = response.decisions.div0[0];

          // Inject ad contents into page
          $("#div0").replaceWith(decision.contents[0].body);
          $("#response").text(JSON.stringify(response));
          $("#clickUrl").text(decision.clickUrl);

          // Record the impression
          client.pixels.fire({
            url: decision.impressionUrl
          });

        }).catch(error => {
          console.log("ERROR!", error.toString());
        });
      };
    </script>
  </head>

  <body>
    <h1>Kevel Native Ad Request</h1>

    <p>Press the button to make an ad request, record the impression, and display both the internal JSON and HTML payload of the response. The response includes data like Impression URL, Click URL, Campaign ID, Metadata, and more. (Note: May not work if you're using an ad blocker).</p>

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

    <hr />

    <h4>Image:</h4>
    <div id="div0">
      <code>(Nothing yet; please click the button!)</code>
    </div>

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

    <h4>Click URL:</h4>
    <code id="clickUrl">(Nothing yet; please click the button!)</code>
  </body>
</html>
package com.adzerk.examples;

import java.util.*;
import com.adzerk.sdk.*;
import com.adzerk.sdk.generated.ApiException;
import com.adzerk.sdk.generated.model.*;
import com.adzerk.sdk.model.DecisionResponse;

public class FetchAds {
  public static void main(String[] args) throws ApiException {
    // Demo network, site, and ad type IDs; find your own via the Kevel UI!
    Client client = new Client(new ClientOptions(23).siteId(667480));
    Placement placement = new Placement().adTypes(Arrays.asList(5));
    User user = new User().key("abc");

    DecisionRequest request = new DecisionRequest()
      .placements(Arrays.asList(placement))
      .keywords(Arrays.asList("keyword1", "keyword2"))
      .user(user);

    DecisionResponse response = client.decisions().get(request);
    System.out.println(response.toString());
  }
}
import { Client } from "@adzerk/decision-sdk";

// Demo network, site, and ad type IDs; find your own via the Kevel UI!
let client = new Client({ networkId: 23, siteId: 667480 });

let request = {
  placements: [{ adTypes: [5] }],
  user: { key: "abc" },
  keywords: ["keyword1", "keyword2"]
};

client.decisions.get(request).then(response => {
  console.dir(response, { depth: null });
});
require "adzerk_decision_sdk"

# Demo network, site, and ad type IDs; find your own via the Kevel UI!
client = AdzerkDecisionSdk::Client.new(network_id: 23, site_id: 667480)

request = {
  placements: [{ adTypes: [5] }],
  user: { key: "abc" },
  keywords: ["keyword1", "keyword2"],
}

pp client.decisions.get(request)
(ns example-ad-request
  (:import (com.adzerk.sdk Client ClientOptions)
           (com.adzerk.sdk.generated.model DecisionRequest Placement User)))

(defn -main []
  ; Demo network, site, and ad type IDs; find your own via the Kevel UI!
  (let [client (Client. (doto (ClientOptions. (int 23)) (.siteId (int 667480))))
        request (doto (DecisionRequest.)
                      (.placements [(doto (Placement.) (.adTypes [5]))])
                      (.keywords ["keyword1" "keyword2"])
                      (.user (doto (User.) (.key "abc"))))
        response (-> client (.decisions) (.get request))]

    (println response)))
curl -H 'Content-Type:application/json' \
  -X POST \
  -d '{"placements":[{
  "divName":"div1",
  "networkId":23,
  "siteId":667480,
  "adTypes":[5]}],
  "user":{"key":"abc"}}' \
  \
  https://e-23.adzerk.net/api/v2

Get started now

Automate campaign management. Automate growth.