Simplified version of setSettings: add one or several settings with only the master/slave symbols and Ids defined. This will only add a mapping if it does not exist already.
URL: https://www.trade-copier.com/webservice/v4/mapping/addMappings.php
Even if adding only one mapping, it must be inside an array
Response: JSON response description, with either how many mappings have been added, or an error message
Fields noted with a * are optional
| Field Name | Field Type | Field Description |
|---|---|---|
| id_master | string | Unique identifier of the master account linked to the mapping |
| id_slave* | string | Unique identifier of the slave account linked to the mapping, or null if defining a template |
| id_group* | string | Unique identifier of the template linked to the mapping, or null if defining a slave |
| symbol | string | Slave symbol of setting you want to add |
| symbol_master | string | Master symbol of setting you want to add |
PHP example
<?php
$url="https://www.trade-copier.com/webservice/v4/mapping/addMappings.php";
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer [[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);
$mappings = [
['id_slave' => "DEF", 'id_master' => "ABC", 'symbol' => 'APITEST', 'symbol_master' => 'TESTAPI'],
['id_group' => "GHI", 'id_master' => "ABC", 'symbol' => 'TESTAPI', 'symbol_master' => 'APITEST']
];
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($settings));
// Execute request
$json = json_decode(curl_exec($ch));
// Close connection
curl_close($ch);
if(array_key_exists('success', $json))
{
echo 'Added '.$json->added_count.' mappings';
}
else
{
//This is an error message that can be access like this:
//echo $json>code." ".$json>error;
echo json_encode($json);
}
?>