Get a full list of your existing accounts in your Trade Copier cockpit
URL: https://www.trade-copier.com/webservice/v4/account/getAccounts.php
The request may specify an optional filter object containing a single account_id that you want to select, or an array of IDs. If the filter is empty or absent, it will select all your accounts.
Response: JSON object list
Field Name | Field Type | Field Description |
---|---|---|
account_id | string | Unique identifier of the account |
type | int | 0=Master or 1=Slave |
name | string | Custom account name |
broker | string | mt4, mt5, ctrader, fxcm_fc or lmax (always in lower case) |
login | string | Your broker account login |
account | string | Account name |
password | string | The account's password |
server | string | MT4: IG-DEMO, FxPro.com-Real02, Ava-Real 1, etc. MT5: ActivTrades-Server, Binary.com-Server, FxPro-MT5, etc. cTrader: leave blank LMax Demo: https://web-order.london-demo.lmax.com LMax Live: https://api.lmaxtrader.com FXCM_FC: http://www.fxcorporate.com/Hosts.jsp |
environment | string | Real or Demo |
status | int | The account is 0=disabled, 1=enabled |
state | string | Last state of the account: CONNECTED DISCONNECTED SYMBOL_NOT_FOUND ORDER_FAILED ORDER_FAILED_MARGIN INVESTOR_PASSWORD SELLOUT_SL SELLOUT_TP CLOSE_ONLY_SL CLOSE_ONLY_TP FROZEN_SL FROZEN_TP EMPTY_EWALLET NONE |
groupid | string | One of your existing templates's Id. Empty if none are assigned |
subscription_key | string | Unique key of the subscription assigned to the account. Empty if none are assigned |
subscription_name | string | Name of the subscription assigned to the account. Empty if none are assigned |
expiration | string | Expiration date of the subscription assigned to the account. Empty if none are assigned |
pending | int | Copy pending order is 0=disabled, 1=enabled |
stop_loss | int | Copy StopLoss is 0=disabled, 1=enabled |
take_profit | int | Copy TakeProfit is 0=disabled, 1=enabled |
comment | string | Custom comment that appears in MT4, MT5 and cTrader terminal trade comment |
alert_email | int | Send warning email for account disconnection is 0=disabled, 1=enabled |
alert_sms | int | Send warning sms for account disconnection is 0=disabled, 1=enabled |
alert_email_failed | int | Send warning email for failed copied orders is 0=disabled, 1=enabled |
alert_sms_failed | int | Send warning sms for failed copied orders is 0=disabled, 1=enabled |
globalstoploss | int | Global account StopLoss is 0=disabled, 1=enabled |
globalstoplosstype | int | Global account StopLoss is 0=Close Only, 1=Sell Out, 2=Frozen |
globalstoplossvalue | float | Global account StopLoss |
globatakeprofit | int | Global account TakeProfit is 0=disabled, 1=enabled |
globaltakeprofitvalue | float | Global account TakeProfit |
globaltakeprofittype | int | Global account TakeProfit is 0=Close Only, 1=Sell Out, 2=Frozen |
balance | string | Updated after each trade and every 5 minutes. Balance should be used carefully since it is not updated regularly |
equity | string | Updated after each trade and every 5 minutes. Equity should be used carefully since it is not updated regularly |
free_margin | string | Updated after each trade and every 5 minutes. FreeMargin should be used carefully since it is not updated regularly |
credit | string | Updated after each trade and every 5 minutes. Credit should be used carefully since it is not updated regularly |
ccy | string | Account currency |
mode | int | Accounting type: 0: Hedging, 1:Netting |
open_trades | int | Number of open trades on the account |
lastUpdate | string | Date and time of last update on the account |
access_token | string | Access token for ctrader |
refresh_token | string | Refresh token for ctrader |
expiry_token | string | Expiry token for ctrader |
account | string | Account name for ctrader |
PHP example
<?php
echo "<link rel='stylesheet' type='text/css' href='https://www.trade-copier.com/webservice/example.css'>";
$url="https://www.trade-copier.com/webservice/v4/account/getAccounts.php";
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'Auth-Username: [[USERNAME]]',
'Auth-Token: [[TOKEN]]',
);
// Open connection
$ch = curl_init();
// Setting the options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$filter = ['account_id' => 'ABC'];
//$filter = ['account_id' => ['ABC', 'DEF']];
//$filter = [];
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($filter));
// Execute request
$json = json_decode(curl_exec($ch));
// Close connection
curl_close($ch);
//We access the existing account(s) list
if(array_key_exists('accounts', $json))
{
echo '<table id="api_data">';
foreach($json->accounts as $row) {
foreach($row as $key => $val) {
echo '<th>'.$key.'</th>';
}
break;
}
foreach($json->accounts as $account)
{
echo '<tr>';
foreach($account as $key => $val)
{
echo '<td>'.$val.'</td>';
}
echo '</tr>';
}
echo '</table>';
}
else
{
//This is an error message that can be access like this:
//echo $json->code." ".$json->error;
echo json_encode($json);
}
?>