Admin API

Admin API is avaiable only for PRO or higher editions.

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/[i:id]         | Get affiliate network details      |
| POST   | /admin_api/v1/affiliate_networks/[i:id]/clone   | Clone affiliate network            |
| POST   | /admin_api/v1/affiliate_networks                | Create affiliate network           |
| PUT    | /admin_api/v1/affiliate_networks/[i:id]         | Update affiliate network           |
| DELETE | /admin_api/v1/affiliate_networks/[i:id]         | Archive affiliate network          |
| GET    | /admin_api/v1/campaigns                         | Retrieve all campaigns             |
| GET    | /admin_api/v1/campaigns/[i:id]                  | Retrieve the specific campaign     |
| POST   | /admin_api/v1/campaigns                         | Create a campaign                  |
| PUT    | /admin_api/v1/campaigns/[i:id]                  | Update a campaign                  |
| DELETE | /admin_api/v1/campaigns/[i:id]                  | Move a campaign to archive         |
| GET    | /admin_api/v1/campaigns/deleted                 | Retrieve all deleted campaigns     |
| POST   | /admin_api/v1/campaigns/[i:id]/restore          | Restore an archived campaign       |
| POST   | /admin_api/v1/campaigns/[i:id]/disable          | Disable a specific campaign        |
| POST   | /admin_api/v1/campaigns/[i:id]/enable           | Enable a specific campaign         |
| POST   | /admin_api/v1/campaigns/[i:id]/clone            | Clone a campaign                   |
| POST   | /admin_api/v1/campaigns/[i:id]/update_costs     | Update a campaign costs            |
| POST   | /admin_api/v1/clicks/log                        | Retrieve the clicks log            |
| POST   | /admin_api/v1/clicks/summary                    | Retrieve summary data              |
| POST   | /admin_api/v1/clicks/build                      | Build and retrieve a report        |
| GET    | /admin_api/v1/conversions/log                   | Retrieve the conversions log       |
| GET    | /admin_api/v1/groups                            | Get list of groups                 |
| POST   | /admin_api/v1/groups                            | Create group                       |
| PUT    | /admin_api/v1/groups/[i:id]                     | Update group                       |
| DELETE | /admin_api/v1/groups/[i:id]/delete              | Delete group                       |
| GET    | /admin_api/v1/landing_pages                     | Retrieve all landing pages         |
| GET    | /admin_api/v1/landing_pages/[i:id]              | Retrieve a specific langin page    |
| PUT    | /admin_api/v1/landing_pages/[i:id]/clone        | Clone a landing page               |
| POST   | /admin_api/v1/landing_pages                     | Create a landing page              |
| PUT    | /admin_api/v1/landing_pages/[i:id]              | Edit a landing page                |
| DELETE | /admin_api/v1/landing_pages/[i:id]              | Archive landing page               |
| GET    | /admin_api/v1/logs/[a:log]                      | Get log entries                    |
| GET    | /admin_api/v1/logs/types                        | Get log types                      |
| DELETE | /admin_api/v1/logs/[a:log]                      | Clear a log file                   |
| GET    | /admin_api/v1/offers                            | Get list of offers                 |
| GET    | /admin_api/v1/offers/[i:id]                     | Get a specific offer               |
| POST   | /admin_api/v1/offers                            | Create an offer                    |
| PUT    | /admin_api/v1/offers/[i:id]                     | Update an offer                    |
| POST   | /admin_api/v1/offers/[i:id]/clone               | Clone offer                        |
| DELETE | /admin_api/v1/offers/[i:id]/archive             | Move an offer to archive           |
| 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/[i:campaign_id]/streams | Retrieve streams of a campaign     |
| POST   | /admin_api/v1/streams                           | Create a stream                    |
| DELETE | /admin_api/v1/streams/[i:id]                    | Move steam to archive              |
| PUT    | /admin_api/v1/streams/[i:id]                    | Update a stream                    |
| GET    | /admin_api/v1/streams/deleted                   | Retrieve deleted streams           |
| GET    | /admin_api/v1/streams/[i:id]                    | Retrieve a specific stream         |
| POST   | /admin_api/v1/streams/[i:id]/restore            | Restore an archived stream         |
| POST   | /admin_api/v1/streams/[i:id]/enable             | Enable a stream                    |
| POST   | /admin_api/v1/streams/[i:id]/disable            | Disable a stream                   |
| POST   | /admin_api/v1/streams/copy                      | Copy campaign streams              |
| POST   | /admin_api/v1/streams/move_streams              | Move streams                       |
| 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 traffic sources       |
| GET    | /admin_api/v1/traffic_sources/[i:id]            | Retrieve a specific traffic source |
| POST   | /admin_api/v1/traffic_sources/[i:id]/clone      | Clone traffic source               |
| POST   | /admin_api/v1/traffic_sources                   | Create a traffic source            |
| PUT    | /admin_api/v1/traffic_sources/[i:id]            | Update a traffic source            |
| DELETE | /admin_api/v1/traffic_sources/[i:id]            | Move to archive a traffic 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 a Specific Affiliate Network

This endpoint retrieves a specific affiliate network.

GET /admin_api/v1/affiliate_networks/[i:id]
Param 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 an Affiliate Network

POST  /admin_api/v1/affiliate_networks
Param 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 an Affiliate Network

This endpoint updates a affiliate network.

PUT  /admin_api/v1/affiliate_networks/[i:id]
Param 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 an affiliate network

This endpoint clones an affilaite network.

POST  /admin_api/v1/affiliate_networks/[i:id]/clone
Param 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 to archive an affiliate network

This endpoint moves an affiliate network to archive.

POST  /admin_api/v1/affiliate_networks/[i:id]/archive
Param 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"
    }
]

Campaigns

Retrieve 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 at section campaign_fields

Retrieve all deleted campaign

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 a Campaign

POST  /admin_api/v1/campaigns/[i:id]/disable
Param 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 a campaign

POST  /admin_api/v1/campaigns/[i:id]/enable
Param 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,
}]

Retrieve a specific 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 campaign_fields.

Create a campaign

POST  /admin_api/v1/campaigns

<a id=“campaign_fields”></a>

Param 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 param descriptions at section campaign_fields

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
}

Archive a Campaign

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 a Campaign

DELETE /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 a 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
Param 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

Example:

$params = ['start_date' => '2017-09-10',
 'end_date' => '2017-09-12', 
 'cost' => 10.02, 
 'currency' => 'EUR',
 'timezone' => 'Europe/Moscow', 
 'only_campaign_uniques' => 1
];
 
$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

Retrieve streams of a campaign

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

<a id=“stream-fields”></a> Params:

Param 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

<a id=“filters-block”></a> Fields of stream filters:

Param 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

<a id=“triggers-block”></a> Fields of stream triggers:

Param 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]

Params:

Param Description Required Default Value
id Stream ID Yes

The request body is the similiar as create_stream.

Offers

Retrieve 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 an offer

POST  /admin_api/v1/offers

<a id=“offer_fields”></a>

Param Description Required Default
name Offer name Yes
group_id Offer Group ID No null
url Offer 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',
    'url' => '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",
   "url":"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 param descriptions at section offer_fields

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',
    'url' => '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,
   "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":"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
}

Archive an Offer

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

Retrieve 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

<a id=“group_fields”></a>

Param 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 param descriptions at section group_fields

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 Report

Build any report

POST /admin_api/v1/report/build

Params:

Param Type Description Required Example
range Object Range value (read more information below) 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 list of avaible fields below) Yes [“country”, “city”]
metrics Array Metric fields (see list of avaible fields below) Yes
sort Array or objects Specify query sorting No [{“name”: “datetime”, “order”: “desc”}, {“name”: “revenue”, “order”, “desc”}]
filters Array of objects Perform result filtering

Range is specified as 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.

Filters are specified as 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 avaible operators (see the list bellow) Yes
expression Expression for 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”

Sort must be specified as array of objects. Each object contains name and order. Example, [{"name": "roi", "order": "desc"}].

(This isn't implemented yet). You can find avaible fields and all grid definition by requesting this entry point

GET /admin_api/v1/report/definition

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"
    }
}

Click Log

Retrieve click log

POST /admin_api/v1/clicks/log

Params and output the same as in Build Report entry-point. The difference is that instead of using params 'grouping' and 'metrics', you must use param 'columns'.

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

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

Why all the entry points triggers domain action?

If you user Single-click Installation 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"?