CPlugin
Operational since 2015 · for brokers, integrators and trading-software teams

The MT4 / MT5 API
that just works.

A Windows-only C++ DLL stands between you and your first server call — calling it from Python, TypeScript or anything outside Windows means writing native bindings and keeping a Windows host alive. Skip it: one API for MT4 and MT5, in any language, connected in a day.

A RESTful JSON Web API to manage MT4 and MT5 trading servers from any HTTP-enabled client. REST for request / response, plus a live stream of quotes, margins and trade events over WebSockets. OAuth 2.0, geographically distributed.

REST + live streaming·OAuth 2.0·Multi-region·4 SDKs
Step 1

Create a Sandbox account

Register in the Sandbox Toolbox, then add an API client — a client id and secret. Free: no billing, no SLA.

Create an account →
Step 2

Register your trade server

You need your own MT4/MT5 server and a manager login with the rights you need. Allow the Sandbox address 88.99.65.181 in the server firewall, then add the server in Toolbox.

Open the Sandbox Toolbox ↗·Firewall settings ↗
Step 3 · Copy and run
auth-and-call.ps1PowerShell 5.1+ or 7+ — nothing extra to install
# The Sandbox — free, no billing. For Production comment out these two lines,
# uncomment the two below and use a client created in toolbox.cplugin.com.
$Api  = 'https://pre.mywebapi.com'
$Auth = 'https://pre.auth.cplugin.net'
# $Api  = 'https://cloud.mywebapi.com'
# $Auth = 'https://auth.cplugin.net'

# 1. OAuth Client Credentials → Bearer JWT
$body = @{
    grant_type    = 'client_credentials'
    scope         = 'webapi'
    client_id     = $env:CPLUGIN_WEBAPI_CLIENT_ID
    client_secret = $env:CPLUGIN_WEBAPI_CLIENT_SECRET
}
$token   = (Invoke-RestMethod -Method Post -Uri "$Auth/connect/token" -Body $body).access_token
$headers = @{ Authorization = "Bearer $token" }

# 2. Take the first trade platform registered in your workspace
$ID = (Invoke-RestMethod -Headers $headers -Uri "$Api/api/TradePlatforms")[0].id
Write-Host "Platform id: $ID"

# 3. Ping it
Invoke-RestMethod -Headers $headers -Uri "$Api/api/TradePlatforms/$ID/Ping"
These calls go to the Sandbox. For Production, switch the lines the comment at the top of each snippet names, create a client in toolbox.cplugin.com (Sandbox clients do not work there) and allow the Production addresses in the server firewall (Firewall settings ↗) — a platform used in a month is billed €49, including usage up to that amount. More languages, OAuth details and every operation: cplugin.com/docs/webapi ↗
Realtime streaming

Live quotes in a few lines

Streaming has been part of WebAPI since API v1. With v2, the SDKs do the plumbing: one call opens the stream with the credentials you use for REST, and quotes, trades and margin calls arrive as a stream you simply loop over.

live-prices.tsnpm i @mywebapi.com/sdk
import { CPluginWebApiClient } from '@mywebapi.com/sdk';

const client = new CPluginWebApiClient({
  env: 'prod', // or 'staging' for the Sandbox
  clientId: process.env.CPLUGIN_WEBAPI_CLIENT_ID!,
  clientSecret: process.env.CPLUGIN_WEBAPI_CLIENT_SECRET!,
});

// client.realtime.mt5(…) for an MT5 platform
const rt = client.realtime.mt4('<paste the id of a platform here>');
await rt.start();
for await (const tick of rt.streamTicks('EURUSD')) {
  console.log(tick.symbol, tick.bid, tick.ask);
}

The credentials you already have

The realtime client comes from the same client object as REST and uses its OAuth token — nothing extra to set up.

Streams you loop over

for await in TypeScript, await foreach in .NET, a pipeline in PowerShell. Stop the loop and the subscription ends.

Batched ticks

Ask for one array per symbol every 200 ms (20 ms to 60 s) instead of a message per tick — fewer messages on busy symbols.

Survives a dropped connection

Every SDK reconnects on its own with a fresh token, re-subscribes and keeps your stream loop running — and tells you when it did, so you can catch up on what you missed.

What you can stream. MT4: ticks, batched ticks, trades, account and symbol updates, margin calls. MT5: ticks, batched ticks, margin calls, deals, orders, positions, account and symbol updates. No SDK for your language? Connect to the stream directly (below).
Documentation

Two API versions, one reference each

Every operation served by the main host, for both versions, grouped by platform and tag: organizations and trade platforms first, then the platform calls. Both versions run side by side on the same hosts, with the same token; the same references apply to Production and Sandbox.

Guides — authentication, timeouts, idempotency, realtime: cplugin.com/docs/webapi ↗ · What is new in v2

HTML API reference — every operation with parameters, schemas and curl examples OpenAPI JSON: v1, v2 llms.txt

Swagger UI stays available alongside the HTML reference and Redoc. Connectivity test calls (API v0.1, no token needed) ↗

Current versionNow in production

Meet the v2 API

A larger, cleaner endpoint surface, live in production and in the Sandbox. v2 puts the version in the path — call /api/v2/… directly, no query string — and answers every call in the same envelope, so one parser serves all of them. v1 stays legacy: its routes, parameters and response shapes are unchanged apart from a few listed exceptions, and no deprecation date is set; migrate at your own pace.

Versioning
Version in the path

Call /api/v2/… directly — no api-version query parameter to remember.

Response format
One answer format

Every call answers the same envelope: { data, error, meta }, with the error code in the body.

Realtime
Live streaming

Quotes, margins and trade events stream straight into the SDKs — endpoints /hubs/mt4/v2 and /hubs/mt5/v2.

Four open-source SDKs — TypeScript, .NET, PowerShell, Python — are built on v2 and handle the OAuth token for you: see them run in Step 3 above, and live quotes in Realtime streaming. Full guide: cplugin.com/docs/webapi ↗.

API v2 referencev2 is the current version. v1 stays served as legacy — existing integrations keep working.
MT4 · x86 companion hostCompanion instance · 32-bit only

Need the 32-bit MT4 methods?

A handful of MT4 calls need the 32-bit Manager API library, so they run on a separate companion host at the same /api/v2/MT4/{tradePlatform}/… path, with the same OAuth bearer token and the same tradePlatform id. Everything else — MT5, the rest of the MT4 surface, live streaming — stays on the main API.

Served on the companion host
  • ·Messaging — NewsSend, MailSend, MailsRequest
  • ·Plugins — PluginsGet, PluginParamGet, PluginUpdate, CfgRequestPlugin, CfgUpdatePlugin
  • ·Batch snapshots — UsersSnapshot, UsersSyncRead, TradesSnapshot, TradesSyncRead
  • ·Plugin commands — ExternalCommandBinary
Why a companion hostx86 method reference ↗Only call these on the companion host — the main API returns 404 for them by design.
Environments

Two environments, one API

Same surface, same OAuth flow, just different hosts. Sandbox is fully separated — no billing, no SLA, safe to break.

ProductionBilled

Multi-region cloud — instances in several data centres, a DNS traffic manager routes to the nearest one. Your pricing in Toolbox ↗

SandboxFree · No SLA

Fully separated environment with its own Toolbox for client and MT4 / MT5 connection management. No charges, no SLA, may be reset without notice. Use for integration testing before pointing at Production. Its documentation describes what runs in the Sandbox — new operations show up there before they reach Production.

No SDK for your language?

Connect to the stream directly. It speaks SignalR, an open protocol over WebSockets — with an automatic fallback where WebSockets are blocked — and client libraries exist for most languages.

Endpoints: cloud.mywebapi.com/hubs/mt4/v2 and cloud.mywebapi.com/hubs/mt5/v2, with the trade platform id in ?tradePlatform= and your access token in signalr_token. API v1 has its own hubs (/hubs/mt4/v1, /hubs/mt5/v1) for existing integrations.

Runnable streaming examples

Complete programs from the open-source SDKs: set the client id and secret, run, and watch live quotes arrive.

FAQ

Questions about the MT4 / MT5 API

What is CPlugin WebAPI?

A hosted REST JSON API over the MT4 and MT5 Manager API. Your application manages accounts, trades, groups and symbols on MetaTrader 4 and 5 servers from any language that speaks HTTP, and receives quotes, margin and trade events in realtime over a WebSocket stream.

Do I need to install anything on my MT4 or MT5 server?

No. WebAPI connects to your trade server with a regular manager account, the same way the MetaTrader Manager terminal does. You register the server address and the manager credentials once in Toolbox; no server plugin is required.

How do I authenticate?

With OAuth 2.0 client credentials: exchange your client id and secret at auth.cplugin.net for a bearer token and send it in the Authorization header. The SDKs discover, cache and refresh the token for you. Realtime connections pass the same token in the signalr_token query parameter.

Is there a free sandbox?

Yes. The Sandbox at pre.mywebapi.com has the same API surface and the same OAuth flow as Production, with its own Toolbox at pre.toolbox.cplugin.com and its own token server, pre.auth.cplugin.net. Clients and tokens of the two environments are separate: a token issued by one is refused with 401 by the other. It is free, has no SLA and may be reset without notice, so use it for integration testing.

How do I receive realtime quotes and trade events?

The easiest way is an SDK: one call opens a live stream with the credentials you already use for REST — client.realtime.mt4(platformId) in TypeScript, client.Realtime.MT4(platformId) in .NET, Connect-MT4Realtime in PowerShell, client.realtime.mt4(platform_id) in Python. You then loop over what arrives: ticks, batched ticks (one array per symbol, every 200 ms by default) and margin calls on both platforms, trades and account and symbol updates on MT4, deals, orders, positions, accounts and symbols on MT5. The SDKs reconnect on their own and re-subscribe; events during an outage are not replayed, so re-read what you need after a reconnect. Without an SDK, any language connects to the streaming endpoints directly — /hubs/mt4/v2 and /hubs/mt5/v2 (/hubs/mt4/v1 and /hubs/mt5/v1 for API v1). They use SignalR, an open protocol with client libraries for most languages: WebSockets, falling back to Server-Sent Events or long polling where WebSockets are blocked. Every method and event is listed in the realtime guide at cplugin.com/docs/webapi#realtime.

What happens if the trading platform does not answer in time?

Every trade-platform request has a deadline, which you can set per request with the X-Request-Timeout header (1 to 300 seconds). A read that timed out changed nothing and is safe to repeat. A trade that timed out may still be completed by the platform: you get error.code = OutcomeUnknown (v1: HTTP 504 with the header X-Request-Outcome: unknown), and repeating it with the same Idempotency-Key returns its real result once the platform has answered, without executing it twice. Until the platform answers, a repeat with that key is refused with X-Request-Outcome: in-progress (v1: HTTP 409) instead of being executed again. A request that timed out while the platform connection was still being established carries X-Request-Outcome: not-started (v1: HTTP 503) — nothing was sent, so it is safe to repeat.

Which SDKs are available?

Open-source SDKs for TypeScript (npm @mywebapi.com/sdk), .NET (NuGet MyWebApi.Sdk), PowerShell (module MyWebApi) and Python (pip mywebapi-sdk). Any other language works over plain HTTP, using the OpenAPI references.

Should I use API v1 or v2?

v2 is the current version: it carries the larger surface — on the main host and on the x86 companion host — and every SDK is built on it. v1 is legacy — still served, with its REST routes, parameters and response shapes unchanged apart from a few accepted exceptions (the deliberate changes to its realtime hubs — including MT5 enum values that now arrive as names — and those REST exceptions are listed in the changelog) and no deprecation date, for integrations that were written against it. v2 is the larger surface on both platforms, MT4 and MT5; the API reference (mywebapi.com/reference/) counts the operations of each version and platform. It includes far more than the calls v1 exposed: accounts, groups and symbols with their configurations, orders, deals and positions with their history, charts and ticks, subscriptions, reports, client documents and comments, mail and news, the dealer queue with profit and margin calculations, and writes into the price database. The update calls for accounts, groups, symbols, deals and orders, and the PATCH calls, carry only the fields you send; a field you leave out keeps its value on the trade server. Calls that replace a whole table or set of bars (for example a configuration matrix or chart bars) take the full content, as their descriptions state. Both versions run side by side on the same hosts with the same token, so you can migrate one call at a time, and v1 keeps working for integrations already on it (its REST routes, parameters and response shapes stay compatible apart from those listed exceptions).

How is WebAPI priced?

The Sandbox is free. Production: €49 per month for each trading platform you use in that month, which includes API and streaming usage up to that amount; usage above it is billed by volume, post-paid. A month with no calls on a platform costs nothing — no prepayment, no minimum commitment. Your current rates are shown on the pricing page in Toolbox.

Live status
Production
cloud.mywebapi.com
checking…
Production · x86 companion
cloud-x86.mywebapi.com
checking…
Sandbox
pre.mywebapi.com
checking…
Sandbox · x86 companion
pre-x86.mywebapi.com
checking…