Admin API

This feature is available only for Business edition

Sorry, this page is not finished yet. You can see all entry points by using cli.php:

$ php bin/cli.php admin_api:routes                                                                                                        
+--------+-----------------------------------------------+------------------------------------------+
| Method | Route                                         | Description                              |
+--------+-----------------------------------------------+------------------------------------------+
| GET    | /admin_api/v1/affiliate_networks              | Get list of affiliate networks           |
| GET    | /admin_api/v1/affiliate_networks/{id}         | Get affiliate network details            |
| POST   | /admin_api/v1/affiliate_networks/{id}/clone   | Clone affiliate network                  |
| POST   | /admin_api/v1/affiliate_networks              | Create affiliate Network                 |
| PUT    | /admin_api/v1/affiliate_networks/{id}         | Update affiliate network                 |
| DELETE | /admin_api/v1/affiliate_networks/{id}         | Archive affiliate network                |
| GET    | /admin_api/v1/botlist                         | Retrieve the additional bot list         |
| PUT    | /admin_api/v1/botlist                         | Update the additional bot list           |
| POST   | /admin_api/v1/botlist/add                     | Add IPs to the additional bot list       |
| POST   | /admin_api/v1/botlist/exclude                 | Exclude IPs from the additional bot list |
| DELETE | /admin_api/v1/botlist                         | Clear the bot list                       |
| GET    | /admin_api/v1/campaigns                       | Retrieve all campaigns                   |
| GET    | /admin_api/v1/campaigns/{id}                  | Retrieve the specific campaign           |
| POST   | /admin_api/v1/campaigns                       | Create a campaign                        |
| PUT    | /admin_api/v1/campaigns/{id}                  | Update a campaign                        |
| DELETE | /admin_api/v1/campaigns/{id}                  | Move a campaign to archive               |
| GET    | /admin_api/v1/campaigns/deleted               | Retrieve all deleted campaigns           |
| POST   | /admin_api/v1/campaigns/{id}/restore          | Restore an archived campaign             |
| POST   | /admin_api/v1/campaigns/{id}/disable          | Disable a specific campaign              |
| POST   | /admin_api/v1/campaigns/{id}/enable           | Enable a specific campaign               |
| POST   | /admin_api/v1/campaigns/{id}/clone            | Clone a campaign                         |
| POST   | /admin_api/v1/campaigns/{id}/update_costs     | Update a campaign costs                  |
| POST   | /admin_api/v1/clicks/clean                    | Clean stats                              |
| POST   | /admin_api/v1/clicks/log                      | Retrieve the clicks                      |
| POST   | /admin_api/v1/conversions/log                 | Retrieve the conversions                 |
| GET    | /admin_api/v1/domains                         | Retrieve all domains                     |
| GET    | /admin_api/v1/domains/{id}                    | Retrieve the specific domain             |
| POST   | /admin_api/v1/domains/{id}/check              | Update status of the specific domain     |
| POST   | /admin_api/v1/domains                         | Create a domain                          |
| PUT    | /admin_api/v1/domains/{id}                    | Update a domain                          |
| DELETE | /admin_api/v1/domains/{id}                    | Move domain to archive                   |
| GET    | /admin_api/v1/domains/deleted                 | Retrieve all deleted domains             |
| POST   | /admin_api/v1/domains/{id}/restore            | Restore an archived domain               |
| POST   | /admin_api/v1/domains/{id}/clone              | Clone a domain                           |
| GET    | /admin_api/v1/groups                          | Get list of groups                       |
| POST   | /admin_api/v1/groups                          | Create group                             |
| PUT    | /admin_api/v1/groups/{id}                     | Update group                             |
| DELETE | /admin_api/v1/groups/{id}/delete              | Delete group                             |
| GET    | /admin_api/v1/landing_pages                   | Retrieve all landing pages               |
| GET    | /admin_api/v1/landing_pages/{id}              | Retrieve a specific langin page          |
| PUT    | /admin_api/v1/landing_pages/{id}/clone        | Clone a landing page                     |
| POST   | /admin_api/v1/landing_pages                   | Create a landing page                    |
| PUT    | /admin_api/v1/landing_pages/{id}              | Edit a landing page                      |
| DELETE | /admin_api/v1/landing_pages/{id}              | Archive landing page                     |
| GET    | /admin_api/v1/logs/{log}                      | Get log entries                          |
| GET    | /admin_api/v1/logs/types                      | Get log types                            |
| DELETE | /admin_api/v1/logs/{log}                      | Clear a log file                         |
| GET    | /admin_api/v1/offers                          | Get list of offers                       |
| GET    | /admin_api/v1/offers/{id}                     | Get a specific offer                     |
| POST   | /admin_api/v1/offers                          | Create an offer                          |
| PUT    | /admin_api/v1/offers/{id}                     | Update an offer                          |
| POST   | /admin_api/v1/offers/{id}/clone               | Clone offer                              |
| DELETE | /admin_api/v1/offers/{id}/archive             | Move an offer to archive                 |
| POST   | /admin_api/v1/clicks/summary                  | Retrieve summary data                    |
| POST   | /admin_api/v1/report/build                    | Build a report                           |
| GET    | /admin_api/v1/report/definition               | Retrieve report definition               |
| GET    | /admin_api/v1/report/labels                   | Retrieve labels                          |
| GET    | /admin_api/v1/report/labels                   | Retrieve labels                          |
| POST   | /admin_api/v1/report/labels                   | Update labels                            |
| GET    | /admin_api/v1/streams_actions                 | Retrieve stream actions                  |
| GET    | /admin_api/v1/campaigns/{campaign_id}/streams | Retrieve streams of a campaign           |
| POST   | /admin_api/v1/streams                         | Create a stream                          |
| DELETE | /admin_api/v1/streams/{id}                    | Move steam to archive                    |
| PUT    | /admin_api/v1/streams/{id}                    | Update a stream                          |
| GET    | /admin_api/v1/streams/deleted                 | Retrieve deleted streams                 |
| GET    | /admin_api/v1/streams/{id}                    | Retrieve a specific stream               |
| POST   | /admin_api/v1/streams/{id}/restore            | Restore an archived stream               |
| POST   | /admin_api/v1/streams/{id}/enable             | Enable a stream                          |
| POST   | /admin_api/v1/streams/{id}/disable            | Disable a stream                         |
| POST   | /admin_api/v1/streams/{id}/enable             | Enable a stream                          |
| POST   | /admin_api/v1/streams/{id}/disable            | Disable a stream                         |
| GET    | /admin_api/v1/streams/search                  | Search streams                           |
| GET    | /admin_api/v1/stream/:id/events               | Retrieve stream events                   |
| GET    | /admin_api/v1/stream_types                    | Retrieve available stream types          |
| GET    | /admin_api/v1/stream_actions                  | Retrieve available stream actions        |
| GET    | /admin_api/v1/stream_schemas                  | Retrieve available stream schemas        |
| GET    | /admin_api/v1/traffic_sources                 | Retrieve all sources                     |
| GET    | /admin_api/v1/traffic_sources/{id}            | Retrieve a specific source               |
| POST   | /admin_api/v1/traffic_sources/{id}/clone      | Clone source                             |
| POST   | /admin_api/v1/traffic_sources                 | Create a source                          |
| PUT    | /admin_api/v1/traffic_sources/{id}            | Update a source                          |
| DELETE | /admin_api/v1/traffic_sources/{id}            | Move to archive a source                 |
+--------+-----------------------------------------------+------------------------------------------+

All examples are written in PHP.

Authentication

To authorize, you must provide 'Api-Key' header.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://api_endpoint_here');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

You must replace your-personal-api-key with your API key. To create a new API key visit Profile page in your Keitaro Admin area.

Affiliate Networks

Get all Affiliate Networks

This endpoint retrieves all affiliate networks.

GET /admin_api/v1/affiliate_networks

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/affiliate_networks');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

The above command returns JSON structured like this:

[
    {
        "created_at": "2016-11-19 11:17:45",
        "id": 1,
        "name": "bitterstrawberry.com",
        "postback_url": "",
        "state": "active",
        "template_name": "bitterstrawberrycom",
        "updated_at": "2017-03-28 19:55:13"
    },
    {
        "created_at": "2017-01-26 16:50:59",
        "id": 2,
        "name": "affiliatecube.com",
        "postback_url": "",
        "state": "active",
        "template_name": "affiliatecube",
        "updated_at": "2017-03-28 19:55:03"
    }
]

Get Affiliate Network

This endpoint retrieves a specific affiliate network.

GET /admin_api/v1/affiliate_networks/[i:id]

Fields

Name Description
id The ID of the affiliate network to retrieve

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/affiliate_networks/1');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Create Affiliate Network

POST  /admin_api/v1/affiliate_networks

Fields:

Name Description
name
postback_url Postback URL that must be added in the affiliate network

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/affiliate_networks');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_POST, 1);
$params = ["name" => "test", "postback_url" => "http://postback"];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
[
    {
        "id": "4",
        "name": "test",
        "postback_url": "http://postback",
        "state": "active",
        "template_name": "",
        "created_at": "2017-03-29 11:49:49",
        "updated_at": "2017-03-29 11:49:49"
    }
]

Update Affiliate Network

This endpoint updates a affiliate network.

PUT  /admin_api/v1/affiliate_networks/[i:id]

Fields:

Name Description
id ID of affiliate network
name New name
postback_url New Postback URL value

Example:

$params = ["name": "test2", "postback_url": "http://postback2"];
 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/affiliate_networks/4');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);
[
    {
        "id": "4",
        "name": "test2",
        "postback_url": "http://postback2",
        "state": "active",
        "template_name": "",
        "created_at": "2017-03-29 11:49:49",
        "updated_at": "2017-03-29 11:49:49"
    }
]

Clone Affiliate Network

This endpoint clones an affilaite network.

POST  /admin_api/v1/affiliate_networks/[i:id]/clone

Fields:

Name Description
id The ID of the affiliate network to retrieve

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '/admin_api/v1/affiliate_networks/1/clone');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response:

[
    {
        "created_at": "2017-03-29 11:49:49",
        "id": "3",
        "name": "bitterstrawberry.com Copy 29 Mar 2017 11:49",
        "postback_url": "",
        "state": "active",
        "template_name": "bitterstrawberrycom",
        "updated_at": "2017-03-29 11:49:49"
    }
]

Move Affiliate Network to Archive

This endpoint moves an affiliate network to archive.

POST  /admin_api/v1/affiliate_networks/[i:id]/archive

Fields:

Name Description
id The ID of the affiliate network to retrieve

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/affiliate_networks/1');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response:

[
    {
        "id": "1",
        "name": "bitterstrawberry.com Copy 29 Mar 2017 11:49",
        "postback_url": "",
        "state": "deleted",
        "template_name": "bitterstrawberrycom",
        "created_at": "2017-03-29 11:49:49",
        "updated_at": "2017-03-29 11:49:49"
    }
]

Domains

Get all Domains

This entry-point retrieves all the domains.

GET  /admin_api/v1/domains

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/domains');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response:

[
	{
		id: 1,
		name: "domain1.com",
		is_ssl: false,
		network_status: "error",
		default_campaign_id: 1,
		state: "active",
		created_at: {
			date: "2018-01-23 20:29:29.000000",
			timezone_type: 3,
			timezone: "UTC"
		},
		updated_at: {
			date: "2018-01-23 20:29:29.000000",
			timezone_type: 3,
			timezone: "UTC"
		},
		wildcard: false,
		catch_not_found: true,
		notes: "test",
		campaigns_count: 0
	},
]

Response fields described in section Create Domain

Get Domain

GET  /admin_api/v1/domains/[i:id]

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/domains/1');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response:

{
	id: 1,
	name: "domain1.com",
	is_ssl: false,
	network_status: "error",
	default_campaign_id: 1,
	state: "active",
	created_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	updated_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	wildcard: false,
	catch_not_found: true,
	notes: "test",
	campaigns_count: 0
}

See descriptions of the response fields at section Create Domain.

Update Domain Status

POST  /admin_api/v1/domains/[i:id]/check

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/domains/1/check');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
echo curl_exec($ch);

Response:

{
	id: 1,
	name: "domain1.com",
	is_ssl: false,
	network_status: "error",
	default_campaign_id: 1,
	state: "active",
	created_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	updated_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	wildcard: false,
	catch_not_found: true,
	notes: "test",
	campaigns_count: 0
}

See descriptions of the response fields at section Create Domain.

Create Domain

POST  /admin_api/v1/domains

FIelds

Name Description Required Default
name Domain name Yes
is_ssl http or https No
default_campaign_id Default campaign id for domain No
state Campaign state (active/disabled/removed) No active
wildcard Include all subdomains No CPC
catch_not_found Catch traffic for unexistent path Yes
notes Notes for domain No

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/domains);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
$params = [
    'name' => 'domain1.com',
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
echo curl_exec($ch);

Response:

{
	id: 1,
	name: "domain1.com",
	is_ssl: false,
	network_status: "error",
	default_campaign_id: 1,
	state: "active",
	created_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	updated_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	wildcard: false,
	catch_not_found: true,
	notes: "test",
	campaigns_count: 0
}

Update Domain

PUT /admin_api/v1/domains/1

See fields in section Create Domain

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/domains');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POST, 1);
$params = [
	'name' => 'domain1.com',
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
echo curl_exec($ch);

Response:

{
	id: 1,
	name: "domain1.com",
	is_ssl: false,
	network_status: "error",
	default_campaign_id: 1,
	state: "active",
	created_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	updated_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	wildcard: false,
	catch_not_found: true,
	notes: "test",
	campaigns_count: 0
}

Move Domain to Archive

DELETE /admin_api/v1/domains/[i:id]

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/domains/1');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
echo curl_exec($ch);

Response:

{
	id: 1,
	name: "domain1.com",
	is_ssl: false,
	network_status: "error",
	default_campaign_id: 1,
	state: "active",
	created_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	updated_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	wildcard: false,
	catch_not_found: true,
	notes: "test",
	campaigns_count: 0
}

Get Deleted Domains

GET  /admin_api/v1/domains/deleted

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/domains/deleted');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response the same as in the section retrieve_all_domains.

Restore Domain

POST /admin_api/v1/domain/[i:id]

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/domains/734/restore');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
echo curl_exec($ch);

Response:

{
	id: 1,
	name: "domain1.com",
	is_ssl: false,
	network_status: "error",
	default_campaign_id: 1,
	state: "active",
	created_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	updated_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	wildcard: false,
	catch_not_found: true,
	notes: "test",
	campaigns_count: 0
}

Clone Domain

POST /admin_api/v1/domains/[i:id]/clone

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/domains/734/clone');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
echo curl_exec($ch);

Response:

{
	id: 1,
	name: "domain1.com",
	is_ssl: false,
	network_status: "error",
	default_campaign_id: 1,
	state: "active",
	created_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	updated_at: {
		date: "2018-01-23 20:29:29.000000",
		timezone_type: 3,
		timezone: "UTC"
	},
	wildcard: false,
	catch_not_found: true,
	notes: "test",
	campaigns_count: 0
}

Campaigns

Get all Campaigns

This entry-point retrieves all the campaigns.

GET  /admin_api/v1/campaigns

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response:

[
    {
    "id": 89,
    "alias": "c8bL9W",
    "name": "Test cost1",
    "type": "position",
    "cookies_ttl": 24,
    "position": 1,
    "state": "active",
    "updated_at": "2017-02-13 16:48:19",
    "cost_type": "CPC",
    "cost_value": "10.0000",
    "cost_currency": "RUB",
    "group_id": null,
    "bind_visitors": null,
    "traffic_source_id": 1,
    "token": "5552798f1c388c8ade27c13ba47fe46090abd9d",
    "cost_auto": false
  }
]

Response fields described in section Create Campaign

Get Deleted Campaigns

GET  /admin_api/v1/campaigns/deleted

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns/deleted');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response the same as in the section retrieve_all_campaigns.

Disable Campaign

POST  /admin_api/v1/campaigns/[i:id]/disable

Fields:

Name Description
id Campaign ID

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns/662/disable');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
echo curl_exec($ch);

Response:

[{
  "id": 662,
  "alias": "HBWgh8",
  "name": "Offers",
  "type": "weight",
  "cookies_ttl": 24,
  "position": 9999,
  "state": "disabled",
  "updated_at": "2017-05-03 20:39:16",
  "cost_type": "CPC",
  "cost_value": "0.0000",
  "cost_currency": "USD",
  "group_id": 71,
  "bind_visitors": "slo",
  "traffic_source_id": 1,
  "token": "47jmtgv14ldjdj7qbswwtmjjlg57xzg5",
  "cost_auto": true,
}]

Enable Campaign

POST  /admin_api/v1/campaigns/[i:id]/enable

Fields

Name Description
id Campaign ID

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns/662/enable');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
echo curl_exec($ch);

Response:

[{
  "id": 662,
  "alias": "HBWgh8",
  "name": "Offers",
  "type": "weight",
  "cookies_ttl": 24,
  "position": 1,
  "state": "active",
  "updated_at": "2017-05-03 20:39:16",
  "cost_type": "CPC",
  "cost_value": "0.0000",
  "cost_currency": "USD",
  "group_id": 71,
  "bind_visitors": "slo",
  "traffic_source_id": 1,
  "token": "47jmtgv14ldjdj7qbswwtmjjlg57xzg5",
  "cost_auto": true,
}]

Get Campaign

GET  /admin_api/v1/campaigns/[i:id]

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns/89');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response:

{
    "id": 89,
    "alias": "c8bL9W",
    "name": "Test cost",
    "type": "position",
    "cookies_ttl": 24,
    "position": 1,
    "state": "active",
    "updated_at": "2017-02-13 16:48:19",
    "cost_type": "CPC",
    "cost_value": "10.0000",
    "cost_currency": "USD",
    "group_id": null,
    "bind_visitors": null,
    "traffic_source_id": 1,
    "token": "5552798f1c388c8ade27c13ba47fe46090abd9d",
    "cost_auto": false
  }

See descriptions of the response fields at section Create Campaign.

Create Campaign

POST  /admin_api/v1/campaigns

FIelds

Name Description Required Default
alias Campaign alias which is used in URL http://domain.com/ALIAS) Yes
type Stream rotation type (position/weight) Yes position
name Campaign name Yes
cookies_ttl When click get uniqu status again (in hours) No 24
position Position in campaigns list No
state Campaign state (active/disabled/removed) No active
cost_type Cost type (CPC/CPUC/CPM) No CPC
cost_value Cost value No
cost_currency (EUR/USD/RUB/UAH/GBP) No Get from settings
cost_auto Enable automatic costs (0/1) No 0
group_id Campaign Group ID No null
bind_visitors Bind visitors feature (null - disabled/ s - only to streams/ sl - to streams and LPs/ slo — to streams, LPs and offers) No null
traffic_source_id Traffic Source ID No
token Token to gain access to Click API No

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
$params = [
    'name' => 'Test Campaign X',
    'alias' => 'test-campaign-x',
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
echo curl_exec($ch);

Response:

{
  "id": 734,
  "alias": "test-campaign-x",
  "name": "Test Campaign X",
  "type": "position",
  "cookies_ttl": 24,
  "position": 9999,
  "state": "active",
  "updated_at": null,
  "cost_type": "CPC",
  "cost_value": "0.0000",
  "cost_currency": "USD",
  "group_id": null,
  "bind_visitors": null,
  "traffic_source_id": null,
  "token": "4084055f1b4009b5c76e5f674779646b2da82df",
  "cost_auto": false
}

Update Campaign

PUT /admin_api/v1/campaigns/734

See fields in section Create Campaign

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POST, 1);
$params = [
    'name' => 'Test Campaign X2',
    'alias' => 'test-campaign-x2',
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
echo curl_exec($ch);

Response:

{
  "id": 734,
  "alias": "test-campaign-x2",
  "name": "Test Campaign X2",
  "type": "position",
  "cookies_ttl": 24,
  "position": 9999,
  "state": "active",
  "updated_at": null,
  "cost_type": "CPC",
  "cost_value": "0.0000",
  "cost_currency": "USD",
  "group_id": null,
  "bind_visitors": null,
  "traffic_source_id": null,
  "token": "4084055f1b4009b5c76e5f674779646b2da82df",
  "cost_auto": false
}

Move Campaign to Archive

DELETE /admin_api/v1/campaigns/[i:id]

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns/734');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
echo curl_exec($ch);

Response:

[
  {
    "id": 734,
    "alias": "test-campaign-x2",
    "name": "Test Campaign X2",
    "type": "position",
    "cookies_ttl": 24,
    "position": 9999,
    "state": "deleted",
    "updated_at": "2017-06-01 13:46:20",
    "cost_type": "CPC",
    "cost_value": "0.0000",
    "cost_currency": "USD",
    "group_id": null,
    "bind_visitors": null,
    "traffic_source_id": null,
    "token": "4084055f1b4009b5c76e5f674779646b2da82df",
    "cost_auto": false
  }
]

Restore Campaign

POST /admin_api/v1/campaigns/[i:id]

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns/734/restore');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
echo curl_exec($ch);

Response:

[
  {
    "id": 734,
    "alias": "test-campaign-x2",
    "name": "Test Campaign X2",
    "type": "position",
    "cookies_ttl": 24,
    "position": 9999,
    "state": "active",
    "updated_at": "2017-06-01 13:46:20",
    "cost_type": "CPC",
    "cost_value": "0.0000",
    "cost_currency": "USD",
    "group_id": null,
    "bind_visitors": null,
    "traffic_source_id": null,
    "token": "4084055f1b4009b5c76e5f674779646b2da82df",
    "cost_auto": false
  }
]

Clone Campaign

POST /admin_api/v1/campaigns/[i:id]/clone

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns/734/clone');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
echo curl_exec($ch);

Response:

[
  {
    "id": 735,
    "alias": "2nhpeS",
    "name": "Test Campaign X2 Copy",
    "type": "position",
    "cookies_ttl": 24,
    "position": 9999,
    "state": "active",
    "updated_at": "2017-06-01 13:46:20",
    "cost_type": "CPC",
    "cost_value": "0.0000",
    "cost_currency": "USD",
    "group_id": null,
    "bind_visitors": null,
    "traffic_source_id": null,
    "token": "1902eh90120981u23458u123",
    "cost_auto": false
  }
]

Update Campaign Costs

This endpoint updates campaign costs

POST /admin_api/v1/campaigns/[i:id]/update_costs

Fields:

Name Description Required
id Campaign ID Yes
start_date Start date and time (Example, “2017-09-10 20:10”) Yes
end_date End date and time (Example, “2017-09-10 20:10”) Yes
timezone Timezone (Example, Europe/Madrid) No
cost Cost value (Example, 19.22) Yes
currency Currency (Example, EUR) No
only_campaign_uniques Apply costs only for unique clicks (1 or 0) No
filters Filter the clicks (Example, {"sub_id_1": "1,2,3", "source": "site.ru"}) No

Example:

$params = [
  'start_date' => '2017-09-10 00:00:00',
  'end_date' => '2017-09-12 00:00:00', 
  'cost' => 10.02, 
  'currency' => 'EUR',
  'timezone' => 'Europe/Moscow', 
  'only_campaign_uniques' => 1,
  'filters': ['sub_id_1' => '1,2,3', 'source': 'site.ru']
];
 
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns/2/update_costs');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response:

{"success":true}

Streams

Get Streams

GET    | /admin_api/v1/campaigns/[i:campaign_id]/streams

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/campaigns/2/strems');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response example for stream with schema “Redirect”:

[
  {
    "id": 1282,
    "type": "forced",
    "name": "Test Stream",
    "campaign_id": 2,
    "position": 1,
    "chance": 14,
    "action_options": null,
    "comments": "",
    "state": "active",
    "updated_at": "2016-08-20 15:30:04",
    "action_type": "http",
    "action_payload": "http:\/\/test.com",
    "schema": "redirect",
    "collect_clicks": true,
    "filter_or": true,
    "filters": [
      {
        "id": 386,
        "stream_id": 1282,
        "name": "uniqueness",
        "mode": "reject",
        "payload": "stream",
      }
    ],
    "triggers": [],
    "landings": [],
    "offers": []
  }
]

Response example for stream with schema “Landings”:

[
  {
    "id": 1282,
    "type": "regular",
    "name": "Test Stream",
    "campaign_id": 2,
    "position": 1,
    "chance": 14,
    "action_options": null,
    "comments": "",
    "state": "active",
    "updated_at": "2016-08-20 15:30:04",
    "action_type": "http",
    "action_payload": "http:\/\/test.com",
    "schema": "landings",
    "collect_clicks": true,
    "filter_or": false,
    "landings": [
      {
        "id": 46,
        "stream_id": 3659,
        "landing_id": 26,
        "state": "active",
        "share": 100,
        "created_at": "2017-05-23 11:34:17",
        "updated_at": "2017-05-23 11:55:00"
      }
    ],
    "offers": [
      {
        "id": 42,
        "stream_id": 3659,
        "offer_id": 3,
        "state": "active",
        "share": 0,
        "created_at": "2017-05-23 11:55:00",
        "updated_at": "2017-05-23 11:55:00"
      },
      {
        "id": 41,
        "stream_id": 3659,
        "offer_id": 4,
        "state": "active",
        "share": 100,
        "created_at": "2017-05-23 11:55:00",
        "updated_at": "2017-05-23 11:55:00"
      }
    ]
  }
]

Create Stream

POST /admin_api/v1/streams

Fields:

Name Description Required Default Value
campaign_id Campaign ID Yes
type Stream Type (regular/forced/default) Yes
name Stream Name No
position Position or stream weight No
action_options Action options (if action has options) No
comments Comments for stream No
state State of the stream (active/disabled/deleted) No active
action_type Action to perform (see 'Retrieve available stream action types') Yes
schema Stream schema (redirect/action/landings/offers) Yes
collect_clicks Stream collects clicks (true/false) No false
filter_or Use 'OR' relation between streams (true/false) No false
filters Stream filters (see section 'filters-block') No
triggers Stream triggers (see section 'triggers-block') No
landings Stream landings (see section 'landings-block') No
offers Stream offers (see section 'offers-block') No

Fields of stream filters:

Name Description Required Default Value
id Stream Filter ID (provide it if you updates the filter) No
name Stream Filter Name (see section 'retrive-stream-filters') Yes
mode Filter mode (allow/reject) Yes
payload Stream payload. This field contains values for filters. For, example for filter “keyword” you can provide array ["value1", "value2"] No

Fields of Stream Triggers

Name Type Description Required Example
id Number Trigger ID (provide if you want to update that exists)
condition String Condtion (not_respond, always, not_contains, av_detected) Yes 100
target String Target (stream, landings, offers, selected_page) Yes stream
selected_page String Page URL to check No http://example.com
pattern String Text pattern to check No keyword
action String Action (disable, replace_url, grab_from_page) Yes disable
interval Number Interval between checks No 60
alternative_urls String URLs to replace (splitted by \n ) No
grab_from_page String URL of page that contains new URL No
av_settings String Settings for AV scanners
reverse 1 or 0 Perform alsose in reverse mode (true/false) No 1
scan_page 1 or 0 AV scanner should scan the page content No 1

Update Stream

PUT /admin_api/v1/streams/[i:id]

Fields:

name Description Required Default Value
id Stream ID Yes

The request body is the similar as Create Stream.

Offers

Get Landing Pages

GET /admin_api/v1/landings

Create Landing Page

POST /admin_api/v1/landings

Get Offers

GET   /admin_api/v1/offers

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/offers');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response example for offer:

[  
   {  
      "id":1,
      "name":"test",
      "group_id":null,
      "url":"http:\/\/test.ru",
      "affiliate_network_id":1,
      "payout_value":"0.0200",
      "payout_currency":"USD",
      "payout_type":"CPC",
      "state":"active",
      "created_at":{  
         "date":"2017-08-10 13:38:41.000000",
         "timezone_type":3,
         "timezone":"UTC"
      },
      "updated_at":{  
         "date":"2017-08-10 22:28:54.000000",
         "timezone_type":3,
         "timezone":"UTC"
      },
      "payout_auto":false,
      "payout_upsell":false,
      "country":null,
      "notes":"test note",
      "affiliate_network":"wapcombine.com"
   },
]

Create Offer

POST  /admin_api/v1/offers

Fields:

Name Description Required Default
name Offer name Yes
group_id Offer Group ID No
offer_type 'external', 'preloaded', or 'other' Yes
action_type Action or redirect type Yes
action_payload Action payload or url Yes
affiliate_network_id Offer Affiliate network ID No null
payout_value Payout value for offer No null
payout_currency Payout currency for offer No null
payout_type Payout type for offer (CPACPC) No null
state Offer state (active/disabled/removed) No active
payout_auto Treat offer action as sale No 0
payout_upsell Allow upsells for offer No 0
country Country of offer No null
notes Offer user notes No null

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/offers');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
$params = [
    'name' => 'Test Offer X',
    'offer_type' => 'external',
    'action_type' => 'http',          // HTTP redirect
    'action_payload' => 'http://offer.com?ad_campaign_id={ad_campaign_id}&stream_id={stream_id}',
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
echo curl_exec($ch);

Response:

{  
   "name":"Test Offer X",
   "offer_type": "external",
   "action_type": "http",
   "action_payload":"http:\/\/offer.com?ad_campaign_id={ad_campaign_id}&stream_id={stream_id}",
   "created_at":{  
      "date":"2017-09-12 18:09:20.000000",
      "timezone_type":3,
      "timezone":"UTC"
   },
   "updated_at":{  
      "date":"2017-09-12 18:09:20.000000",
      "timezone_type":3,
      "timezone":"UTC"
   },
   "state":"active",
   "id":"16",
   "group":"No group",
   "affiliate_network":null
}

Update offer

PUT /admin_api/v1/offers/[i:id]

See fields at section Create Offer

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/offers/16');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POST, 1);
$params = [
    'name' => 'Test Offer X2',
    'offer_type' => 'external',
    'action_type' => 'http',          // HTTP redirect
    'action_payload' => 'http://offer.com?ad_campaign_id={ad_campaign_id}'
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
echo curl_exec($ch);

Response:

{  
   "id":16,
   "name":"Test Offer X2",
   "group_id":null,
   "offer_type": "external",
   "action_type": "http",
   "action_payload":"http:\/\/offer.com?ad_campaign_id={ad_campaign_id}",
   "affiliate_network_id":null,
   "payout_value":"0.0000",
   "payout_currency":null,
   "payout_type":null,
   "state":"active",
   "created_at":{  
      "date":"2017-09-12 18:09:20.000000",
      "timezone_type":3,
      "timezone":"UTC"
   },
   "updated_at":{  
      "date":"2017-09-12 18:15:49.000000",
      "timezone_type":3,
      "timezone":"UTC"
   },
   "payout_auto":false,
   "payout_upsell":false,
   "country":null,
   "notes":null,
   "affiliate_network":null
}

Move Offer to Archive

DELETE /admin_api/v1/offers/[i:id]/archive

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/offers/16/archive');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
echo curl_exec($ch);

Response:

[  
   {  
      "id":16,
      "name":"Test Offer X2",
      "group_id":null,
      "url":"http:\/\/offer.com?ad_campaign_id={ad_campaign_id}",
      "affiliate_network_id":null,
      "payout_value":"0.0000",
      "payout_currency":null,
      "payout_type":null,
      "state":"deleted",
      "created_at":{  
         "date":"2017-09-12 18:09:20.000000",
         "timezone_type":3,
         "timezone":"UTC"
      },
      "updated_at":{  
         "date":"2017-09-12 18:15:49.000000",
         "timezone_type":3,
         "timezone":"UTC"
      },
      "payout_auto":false,
      "payout_upsell":false,
      "country":null,
      "notes":null,
      "affiliate_network":null
   }
]

Groups

Get Groups

GET   /admin_api/v1/groups?type=(campaigns|offers|landings)

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/groups?type=campaigns');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response example for offer:

[  
   {  
      "id":1,
      "name":"group1",
      "position":1,
      "type":"campaigns"
   },
   {  
      "id":2,
      "name":"group2",
      "position":2,
      "type":"campaigns"
   }
]

Create Group

POST  /admin_api/v1/groups

Fields:

Field Description Required Default
name Group name Yes
position Group position in default sorting Yes
type Group type (campaignsofferslandings) Yes

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/groups');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
$params = [
    'name' => 'Test Group X',
    'position' => '10',
    'type' => 'campaigns',
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
echo curl_exec($ch);

Response:

{  
   "name":"Test Group X",
   "position":2,
   "type":"campaigns",
   "id":"19"
}

Update Group

PUT /admin_api/v1/groups/[i:id]

See fields Create Group

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/groups/19');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POST, 1);
$params = [
    'id' => 19,
    'name' => 'Test Group X2',
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
echo curl_exec($ch);

Response:

{  
   "id":19,
   "name":"Test Group X2",
   "position":2,
   "type":"campaigns",
   "count":"0"
}

Delete Group

DELETE /admin_api/v1/groups/[i:id]/delete

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/offers/19/delete');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
$params = [
    'id' => 19
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
echo curl_exec($ch);

Response - empty

Reports

Build Custom Report

Build any report

POST /admin_api/v1/report/build

Fields:

Field Type Description Required Example
range Object Range value (see to Field 'range') You must always 'limit' or 'range' {interval: 'yesterday'}
limit Number Limit count You must always 'limit' or 'range' 10
offer Number Result offset No 10
grouping Array Grouping fields (see to Field 'columns') Yes [“country”, “city”]
metrics Array Metric fields (see to Field 'metrics') Yes
sort Array or objects Specify query sorting (see to Field 'sort') No [{“name”: “datetime”, “order”: “desc”}, {“name”: “revenue”, “order”, “desc”}]
filters Array of objects Perform filtering data (see to Field 'filters')

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/report/build');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
$params = [ 
  'range' => [ 
    'from' => '2017-09-10', 
    'to' => '2017-09-12', 
    'timezone' => 'Europe/Madrid' 
  ], 
  'grouping' => ['ts', 'landing'], 
  'metrics' => ['clicks', 'bot_share', 'cr'], 
  'filters' => [
     ['name' => 'campaign_id', 'operator' => 'EQUALS', 'expression' => 4],
     ['name' => 'stream_id', 'operator' => 'EQUALS', 'expression' => 8],
  ]
]; 
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
echo curl_exec($ch);

Response:

{
    "rows" => [
        {"ts": "Traffic Source X", "landing": "LP EU X1", "clicks": 100, "bot_share": 1.10, "cr": 8.20},
        {"ts": "Traffic Source X", "landing": "LP EU X2", "clicks": 70, "bot_share": 0.10, "cr": 2.10},
    ],
    "total" => 7,
    "meta" => {
        "datetime" => "2017-07-21T11:54:34+00:00",
        "execution_time" => "0.0001"
    }
}

Field 'range'

Range is specified as an object with attributes from, to, interval. You must either specify from and to or interval.

Attribute Type Description Required Example
from String Start date No
to String End date No
interval String One of interval: today, yesterday, 7_days_ago, first_day_of_this_week, 1_month_ago, first_day_of_this_month, 1_year_ago, first_day_of_this_year, all_time No today

You must either specify from and to or interval.

Field 'filters'

Filters are specified as an array of objects. Each object must contain the following attributes: name, operator, expression, case_sensitive.

Attribute Type Description Required Example
name String Name of field Yes campaign_id
operator String One of the available operators (see the list below) Yes
expression String/array Expression of the filter No 19

List of available operators:

Operator Type Expression Example
EQUALS Number 10
NOT_EQUAL Number 10
EQUALS_OR_GREATER_THAN Number 10
EQUALS_OR_LESS_THAN Number 10
GREATER_THAN Number 10
LESS_THAN Number 10
MATCH_REGEXP String /uuid=100[0-9]{2}/
NOT_MATCH_REGEXP String /uuid=100[0-9]{2}/
BEGINS_WITH String abc
ENDS_WITH String zyx
CONTAINS String mnp
NOT_CONTAIN String abc
IN_LIST Array [“a”, “b”, “c”]
NOT_IN_LIST Array [“a”, “b”, “c”]
BETWEEN Array
IS_SET
IS_NOT_SET
IS_TRUE
IS_FALSE
HAS_LABEL whitelist or blacklist
NOT_HAS_LABEL whitelist or blacklist

Field 'sort'

Sort must be specified as array of objects. Each object contains name (column or metric) and order (ASC or DESC). Example, [{"name": "roi", "order": "DESC"}].

Field 'columns'

You can find available fields by requesting this entry point:

GET /admin_api/v1/report/definition

Field 'metrics'

Stats

  • clicks
  • campaign_unique_clicks
  • stream_unique_clicks
  • global_unique_clicks
  • uc_campaign_rate
  • uc_stream_rate
  • uc_global_rate
  • bots
  • bot_share
  • proxies
  • empty_referrers
  • conversions
  • leads
  • sales
  • rejected
  • rebills
  • approve
  • lp_clicks
  • lp_ctr
  • landing_clicked_period
  • cr
  • crs
  • crl
  • roi
  • roi_confirmed
  • epc
  • epc_confirmed
  • cps
  • cpa
  • cpc
  • ecpc
  • ecpm
  • ecpm_confirmed
  • ec
  • ec_confirmed

Money

  • profitability
  • cost
  • revenue
  • profit
  • lead_revenue
  • sale_revenue
  • rejected_revenue
  • profit_confirmed

Field 'columns'

IDS

  • click_id
  • sub_id
  • visitor_code
  • campaign_id
  • campaign_group_id
  • parent_campaign_id
  • landing_id
  • offer_id
  • ts_id
  • stream_id
  • language_id
  • device_type_id

Data

  • campaign
  • campaign_group
  • parent_campaign
  • landing
  • landing_clicked_datetime
  • landing_clicked_period
  • offer
  • ts
  • stream
  • language
  • device_type
  • connection_type
  • ip
  • country_code
  • country
  • region
  • city
  • user_agent
  • operator
  • os
  • os_version
  • browser
  • browser_version
  • device_model
  • isp
  • source
  • referrer
  • search_engine
  • keyword
  • destination
  • sub_id_1..10
  • extra_param_1..10
  • revenue
  • cost
  • profit
  • ad_campaign_id
  • external_id
  • creative_id

Flags

  • is_unique_stream
  • is_unique_campaign
  • is_lead
  • is_sale
  • is_rejected
  • is_bot
  • is_using_proxy

Date and Time

  • datetime
  • year
  • month
  • week
  • weekday
  • day
  • hour
  • day_hour

Other

  • ip_mask1
  • ip_mask2
  • label

Conversions specific (for entry-point Conversions):

  • conversion_id
  • click_datetime
  • postback_datetime
  • sale_datetime
  • sale_period
  • tid
  • status
  • previous_status
  • original_status
  • params

Clicks

Retrieve click log

POST /admin_api/v1/clicks/log

Fields:

Field Type Description Required Example
range Object Range value (see to Field 'range') You must always 'limit' or 'range' {interval: 'yesterday'}
limit Number Limit count You must always 'limit' or 'range' 10
offer Number Offset rows No 10
columns Array See to Field 'columns' Yes [“country”, “city”]
sort Array or objects Specify query sorting (see to Field 'sort') No [{“name”: “datetime”, “order”: “desc”}, {“name”: “revenue”, “order”, “desc”}]
filters Array of objects Perform filtering data (see to Field 'filters')

Conversions

POST /admin_api/v1/conversions/log

Fields:

N Type Description Required Example
range Object Range value (see to Field 'range') You must always 'limit' or 'range' {interval: 'yesterday'}
limit Number Limit count You must always 'limit' or 'range' 10
offer Number Offset rows No 10
columns Array See to Field 'columns' Yes [“postback_datetime”, “city”]
sort Array or objects Specify query sorting (see to Field 'sort') No [{“name”: “datetime”, “order”: “desc”}, {“name”: “revenue”, “order”, “desc”}]
filters Array of objects Perform filtering data (see to Field 'filters')

Example:

<?php
$ch = curl_init();
$params = [
   'columns' => ['postback_datetime', 'click_datetime', 'sub_id'],
   'filters' => [
      ['name' => 'status', 'operator' => 'EQUALS', 'expression' => 'lead']
   ],
   'order' => [['postback_datetime', 'DESC']],
   'range' => [
      'from' => '2017-01-01',
      'to' => '2018-04-01'
   ]
 ];
 
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/conversions/log');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
 
echo curl_exec($ch);

Result:

{
  "rows": [
    {
      "postback_datetime": "2017-01-31 14:35:14",
      "conversion_id": "31257",
      "click_datetime": "2017-01-31 14:35:14",
      "sub_id": "bhjmom",
      "status": "lead"
    },
    {
      "postback_datetime": "2017-03-18 14:09:56",
      "conversion_id": "31365",
      "click_datetime": "2017-03-18 13:52:07",
      "sub_id": "1c3gvuv",
      "status": "lead"
    }
  ],
  "total": "2",
  "meta": {
    "execution_time": "0.0101",
    "datetime": "2018-03-21T09:39:17+00:00"
  }
}

Clean Stats

POST /admin_api/v1/clicks/clean

Fields

Name Description
start_date Date and time for the period to delete 2017-04-01 10:10
end_date Date and time for the period to delete 2017-10-01 10:10
campaign_id ID of campaign (optional) 1
timezone Timezone for dates (optional) UTC or Europe/Madrid

Example:

$params = [
  "start_date": "2017-04-01", 
  "end_date": "2017-04-10",
  "timezone": "UTC"
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/clicks/clean');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params)); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Bot Lists

Retrieve Rows from the Bot List

GET  /admin_api/v1/botlist            

Example:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/botlist');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($ch);

Response:

{
    "value": "1.1.1.1\n2.2.2.2\n3.3.3.3"
}

Update the Bot List

PUT  /admin_api/v1/botlist           

Fields

Name Type Description
value string List of IPs. Example, 1.2.3.4\n2.3.4.5

Example

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/botlist');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
 
$params = [
   'value' => "3.3.3.3\n5.5.5.5"
];
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
echo curl_exec($ch);

Response:

{"count": 2}

Add IPs to the Bot List

POST /admin_api/v1/botlist/add                    

Example:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/botlist/add');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
 
$params = [
   'value' => "1.1.1.2"
];
 
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
 
echo curl_exec($ch);

Response:

{"count": 3}

Exclude IPs from the Bot List

POST /admin_api/v1/botlist/exclude      

Example:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/botlist/exclude');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
 
$params = [
   'value' => "1.1.1.2"
];
 
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
 
echo curl_exec($ch);

Response:

{"count": 2}

Clear the Bot List

DELETE /admin_api/v1/botlist         

Example:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://example.com/admin_api/v1/botlist');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Api-Key: your-api-key'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
echo curl_exec($ch);

Response:

{"count": 0}

Why all the entry points triggers domain action?

If you user How to Install Keitaro before 10 April, you must make a change to the file /etc/nginx/conf.d/vhosts.conf.

Find the line:

location /admin {

and change it to

location /admin/ {

Why all the entry points return "404 NotFound"?