Skip to content

In this tutorial, Rimantas explains how to use the Signal Magician API engine. Example PHP script included.

Get your API Key

Get your Signal Magician API Key.

Get your Signal Magician API Key.

To get your API Key, go to the Admin Settings, and open the API Settings tab.

The API key is hidden by default, but it will show up when you click on the SHOW button.

If you need to reset your API key, then use the Reset API key button. Note, that if you do this, any scripts using your old API key will lose connection to the API engine.

On this page, you will also find the URL where you need to send all your POST requests for the API.

Example PHP script

<?php
$api_url = 'https://your-api-url-goes-here/api.php'; //api endpoint
$fields = array(
'api_key' => '1e3d9...',
'action' => 'list_performance_fees',
'params' => array(
'include_demo_accounts' => 1,
'period' => '2020-02-01',
),
);
$fields = (is_array($fields)) ? http_build_query($fields) : $fields;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$result = curl_exec($ch);
curl_close($ch);
if (!$result) $result = file_get_contents($api_url);
if ($result === FALSE) {
echo "Request failed!\n";
}
echo "Result: ";
var_dump($result);
echo "<br>\n<br>\n";
try {
$resultObject = json_decode($result);
echo '<pre>'.print_r($resultObject, true).'</pre>';
} catch (Exception $e) {
echo 'Could not parse json';
}
?>

How API request looks like

You must send each API request through HTTP POST.

Every request must have the following variables:

api_key – this is for authenticating access to the API engine.

action – this tells the API engine what you are trying to do (i.e., get performance fees or affiliate commissions).

params – this must be sent as an array with any additional parameters. This variable is optional for some requests, and you will usually use it if you want to include some kind of search filters. Note that for some requests, this variable is mandatory, and you should study the specific request details below to learn how to use it properly.

If you do not need to use any search filters, you might still need the ‘params’ array because this is where you can include the page number of API results.

API results can include 100 records maximum to avoid abusing the system. If there are more than 100 results, you can access them by using the ‘page’ parameter.

For example, you are requesting information from the API engine, and there are 360 results in total.

API will return 100 results and also return special parameters for you to see how many results and pages there are in total.

  • results_count_this_page = 100
  • results_count_total = 360
  • results_count_pages = 4
  • results_count_from = 1
  • results_count_to = 100

From this information, you can see that there are 4 pages total, and since it was your first request, it means you just got results from page 1.

If you need more data, you have to repeat the API request, but this time instruct the API engine that you want to get the results from page 2. You do this by including the following variable in the ‘params’ array: ‘page’ => 2

Here’s how such API call would look like:

api_key: ‘1e4c5d…’action: ‘list_payments_aff’params: array(‘page’ => 2)

API request examples

Here are some of the examples that you can use to get the data from the Signal Magician system.

Example #1 – Performance Fees

Example data to send in an API request to receive a list of performance fees.

api_key: ‘1e4c5d…’
action: ‘list_performance_fees’
params: array(‘include_demo_accounts’ => 1, ‘period’ => ‘2020-02-01’)

Note that the params array includes two variables. One tells the API engine that we want to include performance fees for demo accounts as well, and the other tells for which period we want performance fees.

If you do not include ‘params’, then by default, API will return performance fees for the previous period (month) and won’t include demo accounts.

Example #2 – Affiliate Commissions

Example data to send in an API request to receive a list of affiliate commissions.

api_key: ‘1e4c5d…’
action: ‘list_payments_aff’
params: array(‘search_aff_id’ => 7632, ‘search_aff_payment_type’ => ‘Payout’)

If we leave ‘params’ array empty or won’t include it at all, the API will return all affiliate commissions records including commisions, refunds, and payouts.

However, if we know what we are looking for exactly, then we can include search filters in the ‘params’ array.

Here’s the list of params you can use:

  • search_name – this allows you to search by payer name or email.
  • search_uid – this allows you to search by payer user ID.
  • search_aff_name – this allows you to search by affiliate name or email.
  • search_aff_id – this allows you to search by affiliate ID.
  • search_aff_payment_type – this allows you to search by affiliate record type. Available options are Commissions, Payout, Refund.
  • search_aff_payment_date – this allows you to search by payout date.
  • search_cr_datetime – this allows you to search by payment date.
  • search_subscr_id – this allows you to search by subscription ID.
  • search_txn_id – this allows you to search by payment transaction ID.

Example API response on success

It does not matter if the API response includes any results or not; it will give an appropriate answer.

All responses are encoded in JSON format for smooth data transfer and handling.

Here’s an example API response on success. Note that the ‘data’ parameter is empty, indicating that there is no data to return by chosen params. But the response still includes information such as API version, action, time of response, etc.

{“action”:”list_payments_aff”,”success”:1,”created”:”2020-04-29 07:54:32″,”api_version”:1,”params”:{“search_aff_id”:”765″,”page”:1},”results_count_this_page”:0,”results_count_total”:”0″,”results_count_pages”:0,”results_count_from”:0,”results_count_to”:0,”data”:null}

The easiest way to know that this is a success response is by checking if the parameter ‘success’ exists and has a value of 1.

Example API response on error

In case of an error, the API response will include the error code and error message so you can understand what is wrong with your API request.

All responses are encoded in JSON format for smooth data transfer and handling.

Here’s an example API response on error.

{“action”:”list_payments_aff”,”created”:”2020-04-29 07:55:06″,”api_version”:1,”params”:{“search_aff_id”:”765″},”error_code”:1001,”error”:”Incorrect API key”}

The easiest way to know that this is an error response is by checking if the parameter ‘error_code’ exists and has a value greater than 0.

Don’t have API in your Signal Magician?

I have added API to Signal Magician panel version 1.9.8.200428. If you have an older version, you might want to upgrade if you’re going to use API.

Here’s how to get your Signal Magician update.

Terms & Conditions | Privacy Policy

Copyright © 2020 · SignalMagician.com · All Rights Reserved

Malcare WordPress Security