Brokeret LogoDocs
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
}
FieldTypeDescription
indexIntegerRule index (used for DELETE)
masterIntegerMaster account login
followerIntegerFollower account login
modeString"mult" (multiplier) or "fixed" (fixed lot)
valueNumberMultiplier factor or fixed lot size
directionString"same" or "reverse"

POST/api/rules

Add a new copy rule.

Request Body

{
  "master": 3005,
  "follower": 45165,
  "mode": "mult",
  "value": 1.0,
  "direction": "same"
}
FieldTypeRequiredDescription
masterIntegerYesMaster account login
followerIntegerYesFollower account login
modeStringYes"mult" / "multiplier" or "fixed"
valueNumberYesMultiplier factor or fixed lot size (must be > 0)
directionStringYes"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_N parameters
  • To reset: delete BrokeretCopyTrade_rules.dat and restart the plugin

Error Responses

All errors return JSON:

{
  "error": "description of the error"
}
StatusMeaning
200Success
201Created (rule added successfully)
400Bad request (invalid JSON, missing fields)
401Unauthorized (missing or wrong API key)
404Not found (unknown endpoint or invalid rule index)
405Method not allowed
500Internal server error (capacity reached)