Typed TypeScript SDK for the CPlugin WebAPI v2 — manage MT4 and MT5 servers from Node.js and browsers.

OAuth2, retries, pagination and SignalR real-time included; types regenerated from the OpenAPI spec so they never drift.

bash
npm install @mywebapi.com/sdk

Why this SDK

Always-in-sync types

Types are auto-generated from the live OpenAPI spec — no hand-maintained mirror. Run bun run generate after a server-side DTO change and your IDE is up-to-date the same day.

Batteries-included reliability

OAuth2 client-credentials flow with auto-refresh; idempotent retries on 408/429/502/503/504 with exponential backoff; v2 envelope unwrap; structured ApiError with code / description / activityId for log correlation.

REST + SignalR in one package

One client object exposes client.mt4 / client.mt5 for REST and client.realtime.mt4(tp) for streaming — same token, same env, no second handshake.

Quickstart

Copy this snippet, set your environment variables, and you are up and running in under a minute.

Need credentials? Create API keys in the Toolbox: toolbox.cplugin.com (production) pre.toolbox.cplugin.com (staging).
TypeScript
import { CPluginWebApiClient } from '@mywebapi.com/sdk';

const client = CPluginWebApiClient.fromEnvironment();
// or: new CPluginWebApiClient({ env: 'prod', clientId: '...', clientSecret: '...' });

const tp = '3029d415-d0a6-4710-a9c1-8cb063ef872f';
const time = await client.mt4.getServerTime(tp);
console.log('MT4 server time:', time.data.timestamp);

Real-time streaming (SignalR)

Built into the same package — no separate install. The optional peer dependency @microsoft/signalr is required only when you use real-time.

Install the peer dependency: npm install @microsoft/signalr (only if you use real-time). The REST surface works without it.
TypeScript
const rt = client.realtime.mt4(tp);   // or .mt5
rt.onConnectionStatus((s) => console.log('connected:', s.connected));
await rt.start();
for await (const tick of rt.streamTicks('EURUSD')) {
  console.log(tick.symbol, tick.bid, tick.ask);
}
await rt.stop();

Get API credentials

API keys (clientId / clientSecret) and trade-platform IDs are managed in the CPlugin Toolbox. Toolbox provisions your WebAPI access; the SDK is the client.

Full TypeDoc reference

Browse every class, interface, function, and type — auto-generated from the OpenAPI spec and always up-to-date.

29 modules, auto-generated from the OpenAPI spec.