Advertiser Reporting API allows any Adcash advertiser to get campaign statistics programmatically. Data received includes impressions, clicks, conversions and spendings, which can be grouped and filtered by multiple parameters.

Resource URL - https://api.myadcash.com/api/v1

Authentication

The first step to using Adcash API services is to generate a token with your username and password.

Token URL - https://api.myadcash.com/api/v1/auth/

Example request

POST /api/v1/auth HTTP/1.1
Host: api.myadcash.com

username=yourusername&password=yourpassword

Example response

{
"token": "eyJ0eXAiOiJKV1QiLCJhbGci...4kTuHxocgxzP3-EHuUqtq2dnkoUwL8as-tjQtoM"
}

cURL Request

curl -X POST \
https://api.myadcash.com/api/v1/auth \
-H 'Cache-Control: no-cache' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'username=yourusername&password=yourpassword'

PHP request

<?php

$request = new HttpRequest();
$request->setUrl('https://api.myadcash.com/api/v1/auth');
$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(
'Cache-Control' => 'no-cache',
'Content-Type' => 'application/x-www-form-urlencoded'
));

$request->setContentType('application/x-www-form-urlencoded');
$request->setPostFields(array(
'username' => 'yourusername',
'password' => 'yourpassword'
));

try {
$response = $request->send();

echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}

NB! Token will be active for a 15min session, after which you will need to re-request the token, using the method above.

Token usage:

Pass token in header with key: "Authorization" and value: "Bearer " <token key>

ex. Key: Authorization, Value: Bearer eyJ0eXAiOiJKV1QiLCJhbGci...4kTuHxocgxzP3-EHuUqtq2dnkoUwL8as-tjQtoM

Methods

GET /advertiser-report

Parameters:

  • start_date*
  • end_date*
  • advertiser_id*
  • group_by*:
    • date
    • country
    • campaignid
    • campaignname
    • devicetype
    • packid
    • packname
    • platformname
    • browser
    • zoneid
  • granularity
    • daily
    • weekly
    • monthly
    • all
  • country
  • campaignid
  • devicetype
  • packid
  • platformname

Required paremeters are marked with *.

Use ',' to separate filter values.

Example request:

GET /api/v1/advertiser-report??start_date=2018-02-09&end_date=2018-02-10&advertiser_id=1&group_by=date,country&country=US,CA,AU&device=SmartPhone,Mobile HTTP/1.1
Host: api.myadcash.com
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGci...4kTuHxocgxzP3-EHuUqtq2dnkoUwL8as-tjQtoM
Accept: application/json

Example response:

[
{
"date": "2018-02-09",
"country": "AU",
"conversions": 15,
"spending": 7.50,
"clicks": 69,
"impressions": 888
},
{
"date": "2018-02-09",
"country": "CA",
"conversions": 9,
"spending": 8.88,
"clicks": 47,
"impressions": 4258
},
...
{
"date": "2018-02-10",
"country": "US",
"conversions": 20,
"spending": 10.80,
"clicks": 120,
"impressions": 4655
}
]

cURL Request

curl -X GET \
'https://api.myadcash.com/api/v1/advertiser-report??start_date=2018-02-09&end_date=2018-02-10&advertiser_id=1&group_by=date,country&country=US,CA,AU&device=SmartPhone,Mobile' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGci...4kTuHxocgxzP3-EHuUqtq2dnkoUwL8as-tjQtoM' \
-H 'Cache-Control: no-cache' \

PHP request

<?php

$request = new HttpRequest();
$request->setUrl('https://api.myadcash.com/api/v1/advertiser-report');
$request->setMethod(HTTP_METH_GET);

$request->setQueryData(array(
'start_date' => '2018-02-09',
'end_date' => '2018-02-10',
'advertiser_id' => '1',
'group_by' => 'date,country',
'country' => 'US,CA,AU',
'device' => 'SmartPhone,Mobile'
));

$request->setHeaders(array(
'Cache-Control' => 'no-cache',
'Accept' => 'application/json',
'Authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGci...4kTuHxocgxzP3-EHuUqtq2dnkoUwL8as-tjQtoM'
));

try {
$response = $request->send();

echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}

Response Formatting

It is possible to specify the output format by passing it in header key Accept.

  • JSON
  • XML
  • CSV

HTTP Status Codes

  • 200 OK - Success!
  • 400 Bad Request - The request was invalid or cannot be served.
  • 401 Unauthorized - Missing or incorrect authentication credentials.
  • 403 Forbidden - The request has been refused or access is not allowed.
  • 404 Not Found - The URI requested is invalid or the resource requested does not exist.
  • 405 Method Not Allowed - The method received in the request is known by the server but not supported by the target resource.
  • 415 Unsupported Media Type - The server refuses to accept the request because the format is not supported.
  • 416 Range Not Satisfiable - The server cannot serve the requested ranges.
  • 500 Internal Server Error - Something is broken in the server, but the exact problem cannot be specified.
  • 502 Bad Gateway - The server is down or being upgraded.
  • 503 Service Unavailable - The server cannot serve the request. Try again later or reduce the request entity.
  • 504 Gateway Timeout - One server did not receive a timely response from another server. Try again later or reduce the request entity.

Error Codes

  • 8 Invalid parameters - Corresponds with HTTP 400. The parameter names or values were not valid for the request. An accompanying error message will explain further.
  • 9 Invalid date range - Corresponds with HTTP 416. Querying before 31 days is not allowed, please contact your account manager
  • 10 Unable to verify credentials - Corresponds with HTTP 401. There was an issue with the authentication data for the request.
  • 11 Invalid or expired token - Corresponds with HTTP 401. The access token used in the request is incorrect or has expired.
  • 13 Maintenance mode - Corresponds with HTTP 502. System is in maintenance mode. Please try again after some time.
  • 14 Over capacity - Corresponds with HTTP 503. The server is temporarily over capacity.

Output Metrics

  • impressions - Impressions
  • clicks - Clicks
  • convs - Conversions
  • spending - Income in Native Currency

Limitations

  • Fetching data older than 31 days is not allowed via API.