Skip to content

Instantly share code, notes, and snippets.

@asabirov
Created June 11, 2018 05:17
Show Gist options
  • Save asabirov/3cd29f43de41bd76ab93de073a7883a9 to your computer and use it in GitHub Desktop.
Save asabirov/3cd29f43de41bd76ab93de073a7883a9 to your computer and use it in GitHub Desktop.
====== Admin API =====
{badge}That feature available only for PRO or higher editions{badge}
~~TOC~~
Sorry, this page is not finished yet. You can see all entry points by using cli.php:
<code bash>
$ 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 |
| 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 |
+--------+-------------------------------------------------+------------------------------------+
</code>
All examples are written in PHP.
===== Authentication ======
To authorize, you must provide 'Api-Key' header.
<code php>
$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);
</code>
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.
<code>
GET /admin_api/v1/affiliate_networks
</code>
Example:
<code php>
$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);
</code>
The above command returns JSON structured like this:
<code javascript>
[
{
"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"
}
]
</code>
====Get Affiliate Network====
This endpoint retrieves a specific affiliate network.
<code>
GET /admin_api/v1/affiliate_networks/[i:id]
</code>
Fields
^ Name ^ Description ^
| id | The ID of the affiliate network to retrieve|
Example:
<code php>
$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);
</code>
====Create Affiliate Network====
<code>
POST /admin_api/v1/affiliate_networks
</code>
Fields:
^ Name ^ Description ^
| name | |
| postback_url | Postback URL that must be added in the affiliate network |
Example:
<code php>
$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);
</code>
<code javascript>
[
{
"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"
}
]
</code>
====Update Affiliate Network====
This endpoint updates a affiliate network.
<code>
PUT /admin_api/v1/affiliate_networks/[i:id]
</code>
Fields:
^ Name ^ Description ^
| id | ID of affiliate network|
| name | New name|
| postback_url | New Postback URL value |
Example:
<code php>
$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);
</code>
<code javascript>
[
{
"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"
}
]
</code>
====Clone Affiliate Network====
This endpoint clones an affilaite network.
<code>
POST /admin_api/v1/affiliate_networks/[i:id]/clone
</code>
Fields:
^ Name ^ Description ^
| id | The ID of the affiliate network to retrieve|
Example:
<code php>
$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);
</code>
Response:
<code javascript>
[
{
"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"
}
]
</code>
====Move Affiliate Network to Archive====
This endpoint moves an affiliate network to archive.
<code>
POST /admin_api/v1/affiliate_networks/[i:id]/archive
</code>
Fields:
^ Name ^ Description ^
| id | The ID of the affiliate network to retrieve|
Example:
<code php>
$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);
</code>
Response:
<code javascript>
[
{
"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"
}
]
</code>
===== Campaigns =====
==== Get all Campaigns ====
This entry-point retrieves all the campaigns.
<code>
GET /admin_api/v1/campaigns
</code>
Example:
<code php>
$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);
</code>
Response:
<code javascript>
[
{
"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
}
]
</code>
Response fields described in section [[#Create Campaign]]
==== Get Deleted Campaigns ====
<code>
GET /admin_api/v1/campaigns/deleted
</code>
Example:
<code php>
$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);
</code>
Response the same as in the section [[retrieve_all_campaigns]].
==== Disable Campaign ====
<code>
POST /admin_api/v1/campaigns/[i:id]/disable
</code>
Fields:
^ Name ^ Description ^
| id | Campaign ID|
Example:
<code php>
$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);
</code>
Response:
<code javascript>
[{
"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,
}]
</code>
==== Enable Campaign ====
<code>
POST /admin_api/v1/campaigns/[i:id]/enable
</code>
Fields
^ Name ^ Description ^
| id | Campaign ID|
Example:
<code php>
$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);
</code>
Response:
<code javascript>
[{
"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,
}]
</code>
==== Get Campaign====
<code>
GET /admin_api/v1/campaigns/[i:id]
</code>
Example:
<code php>
$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);
</code>
Response:
<code javascript>
{
"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
}
</code>
See descriptions of the response fields at section [[#Create Campaign]].
==== Create Campaign ====
<code>
POST /admin_api/v1/campaigns
</code>
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 | 0
| token | Token to gain access to Click API | No | Auto-generated
Example:
<code php>
$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);
</code>
Response:
<code javascript>
{
"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
}
</code>
==== Update Campaign ====
<code>
PUT /admin_api/v1/campaigns/734
</code>
See fields in section [[#Create Campaign]]
Example:
<code php>
$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);
</code>
Response:
<code javascript>
{
"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
}
</code>
==== Move Campaign to Archive====
<code>
DELETE /admin_api/v1/campaigns/[i:id]
</code>
Example:
<code php>
$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);
</code>
Response:
<code javascript>
[
{
"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
}
]
</code>
==== Restore Campaign ====
<code>
DELETE /admin_api/v1/campaigns/[i:id]
</code>
Example:
<code php>
$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);
</code>
Response:
<code javascript>
[
{
"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
}
]
</code>
==== Clone Campaign ====
<code>
POST /admin_api/v1/campaigns/[i:id]/clone
</code>
Example:
<code php>
$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);
</code>
Response:
<code javascript>
[
{
"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
}
]
</code>
==== Update Campaign Costs ====
This endpoint updates campaign costs
<code>
POST /admin_api/v1/campaigns/[i:id]/update_costs
</code>
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:
<code php>
$params = [
'start_date' => '2017-09-10',
'end_date' => '2017-09-12',
'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);
</code>
Response:
<code javascript>
{"success":true}
</code>
===== Streams =====
==== Get Streams ====
<code>
GET | /admin_api/v1/campaigns/[i:campaign_id]/streams
</code>
Example:
<code php>
$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);
</code>
Response example for stream with schema "Redirect":
<code javascript>
[
{
"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": []
}
]
</code>
Response example for stream with schema "Landings":
<code javascript>
[
{
"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"
}
]
}
]
</code>
====Create Stream =====
<code>
POST /admin_api/v1/streams
</code>
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 =====
<code>
PUT /admin_api/v1/streams/[i:id]
</code>
Fields:
^ name ^ Description ^ Required ^ Default Value ^
| id | Stream ID | Yes | |
The request body is the similar as [[#Create Stream]].
===== Offers =====
==== Get Offers ====
<code>
GET | /admin_api/v1/offers
</code>
Example:
<code php>
$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);
</code>
Response example for offer:
<code javascript>
[
{
"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"
},
]
</code>
==== Create Offer ====
<code>
POST /admin_api/v1/offers
</code>
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 (CPA|CPC) | 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:
<code php>
$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);
</code>
Response:
<code javascript>
{
"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
}
</code>
==== Update offer ====
<code>
PUT /admin_api/v1/offers/[i:id]
</code>
See fields at section [[#Create Offer]]
Example:
<code php>
$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);
</code>
Response:
<code javascript>
{
"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
}
</code>
==== Move Offer to Archive====
<code>
DELETE /admin_api/v1/offers/[i:id]/archive
</code>
Example:
<code php>
$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);
</code>
Response:
<code javascript>
[
{
"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
}
]
</code>
===== Groups =====
==== Get Groups ====
<code>
GET /admin_api/v1/groups?type=(campaigns|offers|landings)
</code>
Example:
<code php>
$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);
</code>
Response example for offer:
<code javascript>
[
{
"id":1,
"name":"group1",
"position":1,
"type":"campaigns"
},
{
"id":2,
"name":"group2",
"position":2,
"type":"campaigns"
}
]
</code>
==== Create Group ====
<code>
POST /admin_api/v1/groups
</code>
Fields:
^ Field ^ Description ^ Required ^ Default ^
| name | Group name | Yes |
| position | Group position in default sorting | Yes |
| type | Group type (campaigns|offers|landings) | Yes |
Example:
<code php>
$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);
</code>
Response:
<code javascript>
{
"name":"Test Group X",
"position":2,
"type":"campaigns",
"id":"19"
}
</code>
==== Update Group ====
<code>
PUT /admin_api/v1/groups/[i:id]
</code>
See fields [[#Create Group]]
Example:
<code php>
$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);
</code>
Response:
<code javascript>
{
"id":19,
"name":"Test Group X2",
"position":2,
"type":"campaigns",
"count":"0"
}
</code>
==== Delete Group====
<code>
DELETE /admin_api/v1/groups/[i:id]/delete
</code>
Example:
<code php>
$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);
</code>
Response - empty
=====Reports=====
====Build Custom Report ====
Build any report
<code>
POST /admin_api/v1/report/build
</code>
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 | ["revenue", "cost", "roi"]
| 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:
<code php>
$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);
</code>
Response:
<code javascript>
{
"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"
}
}
</code>
====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 | 2017-02-02 22:10:01
| to | String | End date | No | 2017-02-02 22:10:01
| 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 | EQUALS
| 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 | [1, 9999]
| 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:
<code>
GET /admin_api/v1/report/definition
</code>
====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
<code>
POST /admin_api/v1/clicks/log
</code>
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 ====
<code>
POST /admin_api/v1/conversions/log
</code>
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:
<code php>
<?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);
</code>
Result:
<code javascript>
{
"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"
}
}
</code>
=====Clean Stats====
<code>
POST /admin_api/v1/clicks/clean
</code>
Fields
^ Name ^ Description ^ Example
| 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:
<code php>
$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);
</code>
===== Bot Lists=====
==== Retrieve Rows from the Bot List ====
<code>
GET /admin_api/v1/botlist
</code>
Example:
<code 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);
echo curl_exec($ch);
</code>
Response:
<code>
{
"value": "1.1.1.1\n2.2.2.2\n3.3.3.3"
}
</code>
==== Update the Bot List ====
<code>
PUT /admin_api/v1/botlist
</code>
Fields
^ Name ^ Type ^ Description ^
| value | string | List of IPs. Example, 1.2.3.4\n2.3.4.5 |
Example
<code php>
<?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);
</code>
Response:
<code javascript>
{"count": 2}
</code>
==== Add IPs to the Bot List ====
<code>
POST /admin_api/v1/botlist/add
</code>
Example:
<code php>
<?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);
</code>
Response:
<code javascript>
{"count": 3}
</code>
==== Exclude IPs from the Bot List ====
<code>
POST /admin_api/v1/botlist/exclude
</code>
Example:
<code php>
<?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);
</code>
Response:
<code javascript>
{"count": 2}
</code>
==== Clear the Bot List ====
<code>
DELETE /admin_api/v1/botlist
</code>
Example:
<code php>
<?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);
</code>
Response:
<code>
{"count": 0}
</code>
=====Why all the entry points triggers domain action?=====
If you user [[::auto-installation]] before 10 April, you must make a change to the file %%/etc/nginx/conf.d/vhosts.conf%%.
Find the line:
<code>
location /admin {
</code>
and change it to
<code>
location /admin/ {
</code>
=====Why all the entry points return "404 NotFound"?=====
You must [[::troubleshooting#campaign_link_displays_error_404_what_should_i_do|enable mod_rewrite or setup rewrite paths]] in Nginx.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment