API setting

From Service Manual Kadam.net
Revision as of 13:24, 21 January 2019 by Admin (Talk | contribs) (Statistics on sites in the advertiser's office)

Jump to: navigation, search

API authorization

To access the API, you will need a user ID (app_id) and a signature (signature). Calling different methods is carried out using queries on this template:

        api.kadam.net?%action%.%method%?%params%
        % action% - what are we turning to
        % method% - type of treatment
get - get
put - write
post - update
delete - delete
        % params% - request parameters

        required parameters% params%

        app_id - user id
        signature - signature

Example:

       [GET] http://api.kadam.net/campaigns.get?app_id=%app_id%&signature=%signature%

or

       [GET] http://api.kadam.net/campaigns?app_id=%app_id%&signature=%signature%
       [GET] - http access method

Signature (signature) is created using a temporary token (access_token), which can be obtained using the app_id and secret key parameters.
Parameters app_id (user ID) and the key "secret key" are available on request to support.
Getting a token:

       [GET] http://api.kadam.net/auth.token?app_id=%app_id%&secret_key=%key%
       -> {“access_token”: “...”}

Generating signature for the [GET] method:

       md5 ( %sort_params% . %access_token% )
       %sort_params% - all parameters passed (except signature) are sorted by name

Example:

       app_id=1&campaign_id=3…
       [PUT] http://api.kadam.net/campaigns?signature=%signature%
       +post fields -> %params%

Example for php. Getting a list of campaigns:

       <?
        $your_secret_key = "jqhwekq8734quo37o498q3p498qp34";
       $your_app_id = 1;
       $auth_url = "http://api.kadam.net/auth.token?app_id={$your_app_id}&secret_key={$your_secret_key}";
       $auth = file_get_contents($auth_url);
       $auth = json_decode($auth, true);

       if ( !is_array( $auth ) || !isset( $auth['access_token'] ) ) {
           die( 'something wrong! ' . print_r( $res, true ) );
       }

       $token    = $auth['access_token'];
       $params = array(
	    'client_id' => $your_app_id,
        'app_id' => $your_app_id,
       );

       ksort( $params );

       $result = array ();
       foreach( $params as $key => $value ) {
           $result[] = $key . '=' . urlencode( $value );
       }
       $params = implode( '&', $result );
       $signature = md5( $params . $token );

       $campaign_url = 'http://api.kadam.net/ads.campaigns.get?' . $params . '&signature=' . $signature;

       $campaigns = file_get_contents($campaign_url);
       $campaigns = json_decode($campaigns, true);

       if ( !is_array( $campaigns ) || !isset( $campaigns['response'] ) ) {
           die( 'something wrong! ' . print_r( $campaigns, true ) );
       }
       
       print_r($campaigns);
       

Campaign Statistics

To get campaign statistics, use the method ads.analytic.campaign.get

Parameters Values Optional attributes
campaign_id campaign's id int (numeric value), required parameter
region_id region's id: data.geo.regions.get int (numeric value), required parameter
period The way data is grouped by date:

day — daily statistics;

month - monthly statistics

Temporary restrictions are set by parameters date_from and date_to

required parameter, string
date_from The starting date of the statistics to display. Different date format is used for different parameter period values:

day: YYYY-MM-DD, example: 2011-09-27;

month: YYYY-MM, example: 2011-09

required parameter, string
date_to The final date of the displayed statistics. Different date format is used for different parameter period values:

day: YYYY-MM-DD, example: 2011-09-27;

month: YYYY-MM, example: 2011-09

required parameter, string

Result:
Returns an object with data

{
	response: {
		count: %total items%
		items: {
			shows
			clicks
			ctr
			cpm
			money
                       }
                  }
}

Statistics on sites in the advertiser's office

Under the statistics on the sites in the office of the advertiser means statistics on impressions and clicks on the site in the context of each campaign.
To get statistics on sites, use the ads.campaigns.statblock.get method (GET request)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
Parameters Value Additional attributes
date_from Start date of the statistics output. string, format YYYY-MM-DD (example: 2017-05-15), filter parameter
date_to The end date of the statistics output. string, format YYYY-MM-DD (example: 2017-05-15), filter parameter
campaign_id campaign id required parameter, int (numeric value), filter parameter
signature Signature (generated using a time token, see above) required parameter, string
app_id user id required parameter, int (numeric value)
macros site id int (numeric value), write parameter, filter option
leads Lida int (numeric value), write parameter, filter option
views Impressions int (numeric value), write parameter, filter option
clicks Clicks int (numeric value), write parameter, filter option
conversions Confirmed Conversions int (numeric value), write parameter, filter option
rejections Failed Conversions int (numeric value), write parameter, filter option
ctr CTR int (numeric value), write parameter, filter option
cpm CPM int (numeric value), write parameter, filter option
cpc CPC int (numeric value), write parameter, filter option
prelandvisit Prelend Visits int (numeric value), write parameter, filter option
prelanduseful Useful visits Prelend int (numeric value), write parameter, filter option
prelandscroll Prelend Scroll int (numeric value), write parameter, filter option

Result:
Returns an object with data, example:

{
  "response": {
    "count": 1,
    "items": [
      {
        "macros": "12345678901234",
        "block": "1234",
        "domain": "123456789",
        "leads": "0",
        "views": "123",
        "clicks": "0",
        "conversions": "0",
        "rejections": "0",
        "ctr": "0.0000",
        "cpm": "0.00",
        "cpc": null,
        "moneyOut": "0.000000",
        "moneyIn": null,
        "prelandvisit": "0",
        "prelanduseful": "0",
        "prelandscroll": "0",
        "landvisit": "0",
        "landuseful": "0",
        "landscroll": "0",
        "multiplier": null,
        "blackList": "0"
      }
    ],
    "request": {
      "campaignId": 123456,
      "limit": 10,
      "offset": 0
    }
  }
}

Sorting

Sort Ascending

sort = {parameter}
Example: api.kadam.net?sort=views

Sort descending

sort = - {parameter}
Example: api.kadam.net?sort=-views

Sort by several parameters

sort = {parameter1}, - {parameter2}, {parameter3}
Example: api.kadam.net?sort=views,-clicks,leads

Filtration

{parameter} = {value}
Examples:
api.kadam.net?attr=10
api.kadam.net?attr=string
api.kadam.net?attr=string&date_from=01.05.2016&date_to=01.07.2016