To simplify the integration process, we ask you to provide a JSON API to get your data.

Summary

We want you to implement the following 4 methods. The details are explained below.

GET http://adsbroker.example/api/list?api_key=abc123list of zones

GET http://adsbroker.example/api/details/303?api_key=abc123details for the given zone

GET http://adsbroker.example/api/countries/303?api_key=abc123&from=2015-10-28&to=2015-12-01statistics grouped by countries

GET http://adsbroker.example/api/dates/303?api_key=abc123&from=2015-10-28&to=2015-12-01statistics grouped by dates

Authentication

We pass the user’s API key in each request in “api_key” query parameter. If there is no user with such API key or he/she is not authorized to access the requested resource, we expect a response with 401 status code. It may contain additional data about the error.

Getting list of zones

To get the list of zones, we send a GET request to ‘/list’. For example:

```

GET http://adsbroker.example/api/list?api_key=abc123

```

We expect a response with status code 200 containing a JSON array of objects with the following keys:

id – zone id which is unique for every zone

name – a human-readable zone name

domain – zone domain (site name)

type – type of the zone (banner, popover, im)

An example of expected answer:

```

[ { id: 303, name: ‘ntv_1 mysite.com’, type: ‘banner’ }, { id: 3561, name: ‘pu’, type: ‘popunder’ }

]

```

Getting zone details

To get zone details, we send a GET request to ‘/details/:zone_id’. zone_id is zone’s id for which the information is require. For example:

```

GET http://adsbroker.example/api/details/303?api_key=abc123

```

We expect a response with status code 200, containing a JSON-object with information about the requested zone with the following keys:

```

id – zone id which is unique for every zone

code – js or php code for embedding the ad on the user’s website

link – direct link for showing the ad

```

If you do not provide code/direct links, you may omit the corresponding keys or leave their values blank.

If zone_id in the request does not correspond to any zone, we expect a 404 response.

An example of expected answer:

``` {

id: 303,

code: ‘GET request to ‘/countries/:zone_id’ where zone_id is zone’s id for which statistics is required. We also pass dates in the format of ‘YYYY-mm-dd’ in `from` and `to` GET parameters. For example:

```

GET http://adsbroker.example/api/countries/303?api_key=abc123&from=2015-10-28&to=2015-12-01

```

We expect a response with status code 200 containing a JSON array of objects, each of which represents statics for the given dates for a single country. Each JSON object should contain the following keys:

name – name of the country (it may be an abbreviated code)

hits – number of hits

bounces – number of bounces

income – how much money earned on this country

cpm – CPM value for the country

If you do not provide bounces and/or cpm data, you may omit the corresponding keys or leave their values blank.

If zone_id in the request does not correspond to any zone, we expect a 404 response.

An example of expected answer:

```

[ {

name: ‘GB’,

hits: 2465,

bounces: 2,

income: 0.04,

cpm: 0.00445

}, {

name: ‘UK’,

hits: 5642,

bounces: 22,

income: 1.48,

cpm: 0.503

}

]

```

Getting statistics by dates

To get statistics by dates, we send a GET request to ‘/dates/:zone_id’ where zone_id is zone’s id for which statistics is required. We also pass dates in the format of ‘YYYY-mm-dd’ in `from` and `to` GET parameters. For example:

```

GET http://adsbroker.example/api/dates/303?api_key=abc123&from=2015-10-10&to=2015-12-01

```

We expect a response with status code 200 containing a JSON array of objects, each of which represents statics for the given dates grouped by date. Each JSON object should contain the following keys:

date – date in the format of YYYY-mm-dd

hits – number of hits

bounces – number of bounces

income – how much money earned on this country

cpm – CPM value for the country

If you do not provide bounces and/or cpm data, you may omit the corresponding keys or leave their values blank.

If zone_id in the request does not correspond to any zone, we expect a 404 response.

An example of expected answer:

```

[ {

date: ’2015-12-03’,

hits: 2465,

bounces: 2,

income: 0.04,

cpm: 0.00445

}, {

name: ’2015-12-02’,

hits: 5642,

bounces: 22,

income: 1.48,

cpm: 0.503

}

]

```

Did this answer your question?