Documentation: AffiliationSoftware's API - AffiliationSoftware

AffiliationSoftware's API

What Is it?

AffiliationSoftware has an API (Application Programming Interface) that allows developers to directly connect with the affiliate network and do certain actions automatically. For example, you can automatically approve or decline affiliate transactions based on the order status, or automatically signup an affiliate when he register to your site, and much more.


HOW IT WORKS?

The AffiliationSoftware API can be called up using the cURL function and by sending data via POST method. The result of each API call returns a JSON message. To use the API you need to use your URL and your key, which are available in the settings page of the admin panel.


API CALLS

Listed below are all the API calls available and the related codes to use for making API calls using PHP cURL function.

Approve a transaction
Add a transaction
Edit a transaction
Edit an affiliate
Sign up an affiliate
Read affiliate data
Delete an affiliate
Add a relation
Edit a relation
Read the statistics
Read the daily statistics
Sign up an advertiser
Add a banner/link
Edit a banner/link
Add a campaign
Edit a campaign
Add a commission
Edit a commission
Delete a commission
Read the coupons


Approve a transaction

<?php
$data = array(
  'action' => 'transaction_status',
  'transaction' => 'xxx', // enter the transaction ID or orderID
  'status' => '1', // enter the status (1 = approved, 2 = declined)
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Add a transaction

<?php
$data = array(
  'action' => 'transaction_add',
  'commission' => '17.95', // required, enter commission amount
  'affiliate' => 'example@example.com', // required, enter the affiliate ID, RefID or email
  'campaign' => 'afsr', // optional
  'tier' => '1', // optional
  'status' => '1', // optional (0=pending, 1=approved, 2=declined)
  'type' => 'S', // optional (S=sale,L=lead,A=action,C=click,U=referral,B=bonus)
  'orderid' => 'sale_num_123', // optional
  'cost' => '97.95', // optional
  'gross' => '27.95', // optional, plugin required
  'notes' => 'this is a note', // optional
  'channel' => 'api', // optional
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Edit a transaction

<?php
$data = array(
  'action' => 'transaction_edit',
'transaction' => 'xxx', // enter the transaction ID or orderID
  'field' => 'orderid', // fields: status, amount, cost, orderid, channel, channel2, channel3, note
  'value' => 'xxx', // enter the corresponding value
  'field2' => 'channel', // optional, up to 10 fields
  'value2' => 'xxx', 
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Edit an affiliate

<?php
$data = array(
  'action' => 'affiliate_edit',
  'affiliate' => 'xxx', // enter the affiliate ID, RefID or email
  'field' => 'status', // columns: name, email, password, status, note
  'value' => '1', // enter the corresponding value
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Signup an affiliate

<?php
$data = array(
  'action' => 'affiliate_add',
  'name' => 'Affiliate name', // required
  'email' => 'test@test.com', // required
  'password' => 'test123', // required
  'parent' => '', // optional
  'status' => 1, // optional
  'language' => 'en', // optional
  'notes' => '', // optional
  'data1' => '', // optional
  'data2' => '', // optional
  // ...
  'data25' => '', // optional
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Read affiliate data

<?php
$data = array(
  'action' => 'affiliate_data',
  'affiliate' => 'xxx', // enter the affiliate ID or email
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Delete an affiliate

<?php
$data = array(
  'action' => 'affiliate_delete',
  'affiliate' => 'xxx', // enter the affiliate ID or email
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Add relation

<?php
$data = array(
'action' => 'relation_add',
'affiliate' => 'xxx', // enter the affiliate ID or email
'campaign' => 'xxx', // enter the campaignID
'status' => 1, // optional
'segment' => 'default', // optional
'notes' => '', // optional
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


EDIT RELATION

<?php
$data = array(
'action' => 'relation_edit',
'affiliate' => 'xxx', // enter the affiliate ID or email
'campaign' => 'xxx', // enter the campaignID
'field' => 'status', // required (allowed columns: status, segment, notes)
'value' => 2, // required
'field2' => 'segment', // optional
'value2' => 'NewGroup95', // optional
'field3' => 'notes', // optional
'value3' => 'test note', // optional
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Read statistics and commissions

<?php
$data = array(
  'action' => 'affiliate_stats',
  'from' => 'YYYY-MM-DD', // enter the start date
  'to' => 'YYYY-MM-DD', // enter the end date
  'affiliate' => 'xxx', // enter the affiliate ID or email (optional)
  'campaign' => 'xxx', // enter the campaign ID (optional)
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Read the daily statistics

<?php
$data = array(
'action' => 'affiliate_stats_daily',
'campaign' => 'XXX', // enter the campaign ID
'affiliate' => 'XXX', // enter the affiliate ID or email
'days' => '7', // default 7, max 30
);
$api = curl_init( 'http://esempio.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Signup an advertiser

<?php
$data = array(
  'action' => 'advertiser_add',
  'name' => 'Advertiser name', // required
  'email' => 'test@test.com', // required
  'password' => 'test123', // required
  'status' => 1, // optional
  'language' => 'en', // optional
  'manage_transactions' => 1, // optional
  'manage_affiliates' => 1, // optional
  'notes' => '', // optional
  'data1' => '', // optional
  'data2' => '', // optional
  // ...
  'data25' => '', // optional
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


<?php
$data = array(
'action' => 'banner_add',
'campaign' => 'XXX', // required
'type' => 'L', // required (Link, Text, Image, Hover, Code, Email, Deeplink, QR)
'name' => 'Banner name', // required
'status' => 1, // optional
'language' => '', // optional
'url' => 'http://example.com', // required
'width' => '', // optional
'height' => '', // optional
'image' => '', // optional
'code' => '', // optional
'description' => '', // optional
'covering' => '', // optional (plugin required)
'prefill' => '', // optional (plugin required)
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


<?php
$data = array(
'action' => 'banner_edit',
'banner' => 'XXX', // required
'field' => 'url', // required
'value' => 'http://example.com', // required
'field2' => 'image', // optional
'value2' => 'http://example.com', // optional
'field3' => 'status', // optional
'value3' => 2, // optional
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Add campaign

<?php
$data = array(
'action' => 'campaign_add',
'name' => 'campaign name', // required
'description' => '', // optional (HTML allowed)
'slogan' => '',  // optional
'logo' => '', // optional
'category' => '', // optional
'notes' => '', // optional
'status' => '1', // optional
'sort' => 0, // optional
'advertiser' => '', // optional
'geotarget' => 'us,uk', // optional (plugin required)
'featured' => 1, // optional (plugin required)
'directlink' => '1', // optional (plugin required)
't3pp_postback' => '1', // optional (plugin required)
't3pp_pixel' => '1', // optional (plugin required)
't3pp_code' => '1', // optional (plugin required)
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


EDIT campaign

<?php
$data = array(
'action' => 'campaign_edit',
'campaign' => 'xczxy0', // required
'field' => 'status', // required
'value' => '1', // required
'field2' => 'name', // optional
'value2' => 'new name here', // optional
'field3' => 'slogan', // optional
'value3' => 'new slogan here', // optional
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


ADD commission

<?php
$data = array(
'action' => 'commission_add',
'campaign' => 'XXX', // required
'type' => 'L', // required
'segment' => 'default', // optional
'commission' => '2.50', // required
'commission2' => '0.50', // optional
// ...
'commission10' => '0', // optional
'percentage' => 0, // optional
'hide' => 1, // optional
'gross' => 0, // optional (plugin required)
'recurring' => '', // optional (plugin required)
'freetrial' => '', // optional (plugin required)
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


EDIT commission

<?php
$data = array(
'action' => 'commission_edit',
'campaign' => 'XXX', // required
'type' => 'S', // required
'segment' => 'default', // optional
'commission' => '10', // optional
'commission2' => '0', // optional
// ...
'commission10' => 0, // optional
'percentage' => 0, // optional
'hide' => 0, // optional
'gross' => 0, // optional (plugin required)
'recurring' => '', // optional (plugin required)
'freetrial' => '', // optional (plugin required)
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Delete commission

<?php
$data = array(
'action' => 'commission_delete',
'campaign' => 'XXX', // required
'type' => 'S', // required
'segment' => 'default', // optional
);
$api = curl_init( 'http://example.com/script/api?key=xxx' ); // enter your API URL
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>


Read the coupons

<?php
$data = array(
'action' => 'coupon_get',
'campaign' => 'XXX', // enter the campaign ID
'affiliate' => 'XXX', // enter the affiliate ID or email
);
$api = curl_init( 'http://esempio.com/script/api?key=xxx' ); // enter your API URL 
curl_setopt( $api, CURLOPT_POST, 1 );
curl_setopt( $api, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $api, CURLOPT_POSTFIELDS, $data );
$res = curl_exec( $api );
curl_close( $api );
print_r( json_decode( $res, true ) );
?>

Go back