Skip to content
CPlugin logo
  • Home
  • Blog
  • Store
  • Contact
  • FAQ
  • Cart
  • My account
  • Knowledge Base
CPlugin logo
  • Home
  • Blog
  • Store
  • Contact
  • FAQ
  • Cart
  • My account
  • Knowledge Base

General

  • How to obtain files

MT4 ManagerAPI .NET Wrapper

  • Installation
  • Connection pool
  • Price Helper

Standalone Apps

  • Join two MT4 Servers
  • Compress MT4 database
  • Quotes Monitor
  • Quotes Monitor (WPF)
  • MT4 Report Server extended replication
  • EMIR
  • DividenderLT
  • Tools to calculate dividends
  • CopyTrading
    • Sentiment Strategy (LMAX)
    • MT4 (ManagerAPI) to LMAX
    • MT4 Plugin
    • MT4 (ManagerAPI) to MT4

Plugins for MT4/MT5

  • Flexible Leverage
  • GapHelper plugin
  • Multi Account Manager (MAM)
  • Spread Extender
  • HedgeHelper
  • Multi-Tier IB
  • Multi-Tier IB advanced version

Cloud

  • General info
  • WebAPI
    • WebAPI
    • Authorization
    • Pricing and terms
    • RESTful
    • Web Sockets (SignalR)
  • Home
  • Docs
  • Cloud
  • WebAPI
  • RESTful

RESTful

Brief #

This is a standard RESTful JSON WebAPI.

Before making any calls to WebAPI you need to be authenticated.

Authentication #

Once you get authorized you shall pass token within each call inside HTTP headers.

Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjE0M2U4MjljMmI1NzQ4OTk2OTc1M2JhNGY4MjA1OTc5ZGYwZGE5ODh......<truncated for clarity>

TradePlatform #

To understand with what MT4/MT5 server you are going to work we have unique identifier assigned to each trade platform you registered at Admin portal → Trade platforms (https://admin.cplugin.net/TradePlatforms). There you choose type of this trade platform: MT4, MT5, etc. So, WebAPI will use right MetaQuotes Manager API.

Each trade platform has unique ID.
Controllers might require you to pass this TradePlatformID which can be obtained once (and saved locally to save time).
To get a list of all trade platforms available for you with its identifiers request this list using method: https://cloud.mywebapi.com/swagger/ui/index#!/TradePlatforms/TradePlatforms_Get
So, get it and pass it where is supposed to be as additional URL encoded parameter like in example:

GET /api/MT4/{tradePlatform}/UserRecordGet/{login}

Replace {tradePlatform} and {login} with real identifiers.

Powershell Example #

# Flows :: ClientCredentials
 
$VerbosePreference = [System.Management.Automation.ActionPreference]::Continue
 
$ass = [Reflection.Assembly]::LoadFile("\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll")
$ass = [Reflection.Assembly]::LoadWithPartialName("System.Net.Http")
$ass = [Reflection.Assembly]::LoadWithPartialName("System.IdentityModel")
$ass = [Reflection.Assembly]::LoadFile("\packages\IdentityModel.1.3.1\lib\net45\IdentityModel.Net45.dll")
 
$IdSrvURI = "https://auth.cplugin.net"
$apiURI = "https://cloud.mywebapi.com"
 
$clientId="<put your client id here>"
$clientSecret="<put your client secret here>"
 
#orgs:
$org_cplugin = "<put your organization id here>"
 
#mt4:
$tp = "<put your trade platform id here>"
 
'==> authenticating...' | Write-Host -BackgroundColor Black
$client = new-object IdentityModel.Client.TokenClient `
    (($IdSrvURI+"/connect/token"), $clientId, $clientSecret, [IdentityModel.Client.AuthenticationStyle]::BasicAuthentication)
#$client | Format-List
 
$ct = new-object System.Threading.CancellationToken
$authResult = [IdentityModel.Client.TokenClientExtensions]::RequestClientCredentialsAsync(`
    $client, "webapi", $null, $ct).Result
'==> done!' | Write-Host -BackgroundColor Black
 
"authResult:" | Write-Host -BackgroundColor Black
$authResult | Format-List
 
$auth_headers = @{
    "Authorization" = "Bearer " + $authResult.AccessToken
}
 
function rest_get($url)
{
    #$url | Write-Host -BackgroundColor Black
    Invoke-RestMethod -Uri ($apiURI + $url)  -ContentType "application/json" -Headers $auth_headers -Verbose -MaximumRedirection 0
    ($url + " done") | Write-Verbose
}
 
function rest_get_single($url)
{
    "Result: " + (rest_get $url)
}
 
function rest_get_list($url)
{
    (rest_get $url).value | Format-List
}
 
function rest_get_table($url)
{
    (rest_get $url).value | Format-Table
}
 
function rest_put($url, $data = $null)
{
    #$url | Write-Host -BackgroundColor Black
    Invoke-RestMethod -Method Put -Uri ($apiURI + $url)  -ContentType "application/json" -Headers $auth_headers -Verbose -MaximumRedirection 0 | Format-List
    ($url + " done") | Write-Verbose
}
 
function rest_post($url, $data = $null)
{
    #$url | Write-Host -BackgroundColor Black
    Invoke-RestMethod -Method Post -Uri ($apiURI + $url)  -ContentType "application/json" -Headers $auth_headers -Verbose -MaximumRedirection 0 | Format-List
    ($url + " done") | Write-Verbose
}
 
rest_get_list "/API/Organizations"
rest_get_list "/API/TradePlatforms"
rest_get_list "/API/MT4/$tp/UsersGet"

Balance transaction example #

https://cloud.mywebapi.com/swagger/index.html#/MT4/MT4_TradeTransaction

TradeTransInfo can be partially specified with only fields below:

tradeTransactionType = BrBalance
tradeCommand = Balance
orderBy = account login
price = amount to be deposited/withdrawn

PowerShell example

rest_post -url "/api/MT4/$your_tradeplatform/TradeTransaction" -data "{'tradeTransactionType':'BrBalance', 'tradeCommand':'Balance', 'orderBy':1000, 'price':100}"
How to create new trade account? #

https://cloud.mywebapi.com/swagger/index.html#/MT4/MT4_UserRecordNew

UserRecord an be partially specified with only fields below:

group
name

rest fields MT4 will fill/generate for you in response

Still stuck? How can we help?

How can we help?

Updated on June 30, 2023
Pricing and termsWeb Sockets (SignalR)

Powered by BetterDocs

Table of Contents
  • Brief
  • Authentication
  • TradePlatform
  • Powershell Example
    • Balance transaction example
      • How to create new trade account?

Copyright © 2015  - 2025 CPlugin

Telegram Email EmailLinkedinFacebookTwitter

Powered by CPlugin