Plugins / Copy Trade/API
API
REST API reference for the Copy Trade plugin.
Authentication
All endpoints require authentication via one of:
- Header:
X-API-Key: <your_api_key> - Header:
Authorization: Bearer <your_api_key>
Set the API key via the API_Key plugin parameter in MT5 Administrator. Leave API_Key empty to disable the API entirely.
Base URL
http://<server_ip>:<API_Port>/api/
Default port: 8443
GET/api/status
Returns plugin status, version, license info, and rule count.
{
"plugin": "Brokeret Copy Trade",
"version": "1.0",
"license_active": true,
"rules_loaded": 2,
"api_port": 8443
}
GET/api/rules
Returns all active copy rules.
{
"rules": [
{
"index": 0,
"master": 3005,
"follower": 45163,
"mode": "mult",
"value": 1.0,
"direction": "same"
},
{
"index": 1,
"master": 3005,
"follower": 46569,
"mode": "mult",
"value": 1.0,
"direction": "same"
}
],
"total": 2
}
| Field | Type | Description |
|---|---|---|
index | Integer | Rule index (used for DELETE) |
master | Integer | Master account login |
follower | Integer | Follower account login |
mode | String | "mult" (multiplier) or "fixed" (fixed lot) |
value | Number | Multiplier factor or fixed lot size |
direction | String | "same" or "reverse" |
POST/api/rules
Add a new copy rule.
Request Body
{
"master": 3005,
"follower": 45165,
"mode": "mult",
"value": 1.0,
"direction": "same"
}
| Field | Type | Required | Description |
|---|---|---|---|
master | Integer | Yes | Master account login |
follower | Integer | Yes | Follower account login |
mode | String | Yes | "mult" / "multiplier" or "fixed" |
value | Number | Yes | Multiplier factor or fixed lot size (must be > 0) |
direction | String | Yes | "same" or "reverse" |
Response (201)
{
"success": true,
"index": 2,
"master": 3005,
"follower": 45165
}
DELETE/api/rules/{index}
Remove a copy rule by its index.
{
"success": true
}
📧
NoteAfter deletion, remaining rule indices shift. Always use GET
/api/rules to confirm current indices before deleting.Rule Persistence
- Rules added/removed via API are automatically saved to
BrokeretCopyTrade_rules.dat - On startup: if the file exists, rules load from it. Otherwise falls back to
Copy_Nparameters - To reset: delete
BrokeretCopyTrade_rules.datand restart the plugin
Error Responses
All errors return JSON:
{
"error": "description of the error"
}
| Status | Meaning |
|---|---|
200 | Success |
201 | Created (rule added successfully) |
400 | Bad request (invalid JSON, missing fields) |
401 | Unauthorized (missing or wrong API key) |
404 | Not found (unknown endpoint or invalid rule index) |
405 | Method not allowed |
500 | Internal server error (capacity reached) |