Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Getting started with the Adzerk API

averyj edited this page · 9 revisions

In this article we are going to cover how to get started with the Adzerk API.

The first step to using the Adzerk API is to generate an API Key. Navigate to the Settings section of your Adzerk account and choose the API Keys tab. Click *Add a new API Key' and then copy the generated key to use in your code.

To authenticate with the Adzerk API the API Key must be passed as a header with the name "X-Adzerk-ApiKey" on every request. Your API Key is the same as a username/password so be sure to treat it the same way.

You may also have to specify content-type header as "application/x-www-form-urlencoded" depending on what platform you're using. Also note that you may be required to url-encode special characters.

All of your API requests need to use SSL to protect your key

The next step is to decide what action you want to perform - in this example let's get a report for the month of May.

First we need to craft the URL:

All API requests should use the domain. (this can be CNAMEd if needed)

Then the version of the API (v1) and the resource we want to access:

Using this resource we can create a new report by using POST to send in a criteria object. Currently the API only support JSON, but XML will soon be supported as well.

The name of the object should be "critiera" and the following is the JSON format:

{'StartDate': '5/1/2011', 'EndDate': '5/30/2011', 'GroupBy': ['day']}

These are just some of the available settings for full details see the Reporting API documentation.

You can now execute the request and the results will be returned as a JSON object.

Here is a full example of using the API with RestSharp

var client = new RestClient();
client.BaseUrl = "";
client.AddDefaultHeader("X-Adzerk-ApiKey", "0223F375AE09CA4E55A82FFA241A23282485");

var request = new RestRequest();
request.Method = Method.POST;
request.Resource = "report";
request.AddParameter("criteria", "{'StartDate': '1/1/2011', 'EndDate': '5/16/2011', 'GroupBy': ['day']}");
RestResponse response = client.Execute(request);

Or, with curl

curl -X POST -H "X-Adzerk-ApiKey:0223F375AE09CA4E55A82FFA241A23282485" -H "Content-Type=application/x-www-form-urlencoded" -d 'criteria={"StartDate": "1/1/2011", "EndDate": "5/16/2011", "GroupBy": ["day"], "Parameters":[]}'

When calling the API directly, it is important to note that although the data is formatted as JSON, the request itself is of content-type "application/x-www-form-urlencoded". Thus we must take the serialized data and pass it as form encoded where the key is the type of the data (in this case, "criteria").

Something went wrong with that request. Please try again.