MetaScalp API

SDK & Source metascalp.io
Searching...

Connect your scripts and bots to MetaScalp to interact with exchange connections. Use HTTP REST to query data and execute trades, or WebSocket to receive real-time order, position, and balance updates.

HTTP API: Host: 127.0.0.1   Ports: 1784517855   CORS enabled for all origins.

Socket API: Host: 127.0.0.1   Same port as HTTP   Endpoint: ws://127.0.0.1:{port}/

Getting started: 1. Launch MetaScalp. 2. Discover the HTTP port with GET /ping. 3. List connections with GET /api/connections. 4. Use connection IDs for REST or WebSocket operations.   Full documentation

Discovery
GET /ping Discover running instance

Scan ports 1784517855 to find the running MetaScalp instance. Returns the app name and version.

Ticker
POST /api/change-ticker Switch ticker in MetaScalp UI

Changes the current ticker. The active window is always notified. When a named binding is provided, that binding's linked panels are also updated.

Accepts two request formats: a ticker pattern string (e.g. BINANCE:BTCUSDT.p) or explicit fields (exchange + market + ticker).

A binding is a named group of linked panels inside MetaScalp (e.g. a chart, order book, and trade feed showing the same ticker). Bindings are numbered "001""500" and configured by the user in the MetaScalp UI.

Format: EXCHANGE:SYMBOL.suffix — suffix: .p (futures), .m (margin), .o (options), omitted (spot)
Exchange and suffix are optional. Symbol may contain letters, digits, _, /, -, $, :.
Examples: BINANCE:BTCUSDT.p, BYBIT:ETHUSDT, OKX:BTC-USDT.m, HYPERLIQUID:cash:HOODUSDT0.p
Combo
POST /api/combo Open combo layout

Opens a combo layout for the specified ticker in the MetaScalp UI.

Connections
GET /api/connections List active exchange connections

Returns all currently active exchange connections. Use the Id from the response to query orders, positions, balances, or to subscribe via WebSocket.

FieldTypeDescription
IdintegerConnection ID — use for all exchange operations
NamestringUser-defined connection name
ExchangestringExchange name
ExchangeIdintegerExchange identifier
MarketstringMarket display name
MarketTypeintegerMarket type enum value
Stateinteger0=Disconnected, 1=Connecting, 2=Connected, 3=Reconnecting, 4=Resetting
ViewModebooleanRead-only (no trading)
DemoModebooleanPaper trading
GET /api/connections/{ConnectionId} Get single connection

Returns details for a single connection by ID.

Trading Operations
GET /api/connections/{ConnectionId}/tickers Get available tickers

Returns all available trading pairs on a connection with price/size precision, trading status, and constraints.

GET /api/connections/{ConnectionId}/orders?Ticker=... Get open orders

Returns open orders for a specific ticker on a connection. The Ticker query parameter is required.

FieldTypeDescription
IdintegerExchange order ID
TickerstringTrading pair
ClientIdstring?Client-generated order ID
Sideinteger0 None, 1 Buy, 2 Sell
PricedecimalOrder price
SizedecimalOrder size
FilledSizedecimalFilled amount
FilledPricedecimalExecution price (0 if not yet filled)
RemainingSizedecimalRemaining amount
Statusinteger0 New, 1 Open, 2 Closed
Typeinteger0 Limit, 1 Stop, 2 StopLoss, 3 TakeProfit, 4 Market
TriggerPricedecimal?Trigger price for stop/conditional orders
CreateDatestring (ISO)Order creation timestamp
GET /api/connections/{ConnectionId}/positions Get open positions

Returns all open positions on a connection (futures/margin markets).

GET /api/connections/{ConnectionId}/balance Get account balance

Returns account balances for all assets on a connection.

POST /api/connections/{ConnectionId}/orders Place order

Places a new order on the exchange through a connection. Returns an auto-generated ClientId for order tracking and ExecutionTimeMs indicating how long the exchange request took (in milliseconds).

FieldTypeRequiredDescription
TickerstringyesTrading pair symbol
Sideintegeryes1 Buy, 2 Sell
Pricedecimalyes*Order price (*required for non-market orders)
SizedecimalyesOrder size (must be > 0)
Typeintegerno0 Limit (default), 1 Stop, 2 StopLoss, 3 TakeProfit, 4 Market
ReduceOnlybooleannoClose-only, default false
POST /api/connections/{ConnectionId}/orders/cancel Cancel order

Cancels an existing order on the exchange.

FieldTypeRequiredDescription
TickerstringyesTrading pair symbol
OrderIdintegeryesExchange order ID
TypeintegernoOrder type (default 0 Limit)
POST /api/connections/{ConnectionId}/orders/cancel-all Cancel all orders

Cancels all open orders for a given ticker on the exchange.

FieldTypeRequiredDescription
TickerstringyesTrading pair symbol

Returns CancelledCount: 0 if there are no open orders for that ticker.

Market Data
GET /api/connections/{ConnectionId}/cluster-snapshot Cluster snapshot

Returns the current cluster (volume profile / footprint) data for a ticker. The snapshot contains up to 10 time columns, each holding bid/ask volumes at every price level.

ParameterTypeRequiredDefaultDescription
TickerstringyesTrading pair symbol
TimeFramestringyesS30, M1, M5, M10, M15, M30, H1, D1
ZoomIndexintno1Price aggregation factor (1 = raw levels)

When ZoomIndex > 1, prices are grouped into buckets of ZoomIndex × PriceIncrement and volumes are summed.

Signal Levels
GET /api/connections/{ConnectionId}/signal-levels?Ticker=... Get signal levels

Returns all signal levels for a specific ticker on a connection. Signal levels are price alerts that trigger when the market price crosses the threshold.

FieldTypeDescription
IdintegerSignal level ID
ConnectionIdintegerConnection this signal level belongs to
TickerstringTrading pair symbol
PricedecimalPrice threshold
IsTriggeredbooleanWhether the signal has been triggered
TriggerTimestring (ISO)?When triggered (null if not triggered)
TriggerRulestring"LessThanEqual" or "GreaterThanEqual"
POST /api/connections/{ConnectionId}/signal-levels Place signal level

Places a new signal level at a specific price. The trigger rule is determined automatically from the current order book. Order book must be active for this ticker.

FieldTypeRequiredDescription
TickerstringyesTrading pair symbol
PricedecimalyesPrice threshold (must be > 0)
DELETE /api/connections/{ConnectionId}/signal-levels/{Id} Remove signal level

Removes a single signal level by ID.

DELETE /api/connections/{ConnectionId}/signal-levels?Ticker=... Remove all signal levels (by ticker)

Removes all signal levels for a specific ticker on a connection.

DELETE /api/signal-levels/triggered Remove all triggered signal levels

Removes all triggered signal levels across all connections and tickers.

Order Book Settings
GET /api/connections/{ConnectionId}/orderbook-settings?Ticker=... Get order book settings

Returns all order book settings for a specific ticker on a connection. Settings include trading defaults, order book display configuration, tick thresholds, and cluster options.

PUT /api/connections/{ConnectionId}/orderbook-settings?Ticker=... Update order book settings (partial)

Partial update — only send the fields you want to change. Omitted fields keep their current values. Returns the full updated settings object.

Enum fields: ShowRuler (None, Points, Percent, PercentVolume), ZoomType (Absolute, Percentage), SizeType (Coin, Usd), ClusterTimeFrame (M1, M5, M15, M30, H1, H4, D1).

Real-time WebSocket
WS ws://127.0.0.1:{port}/ Real-time updates via WebSocket
Disconnected
(order_update, position_update, finres_update, balance_update)
(futures only — no events on spot)
Waiting for connection...
Subscribe to order book
to see live depth
Subscribe to trades
to see live feed

Connect via WebSocket to receive real-time updates for your exchange connections. Subscribe by connection ID for order, position, balance, and finres events. Subscribe by connection ID + ticker for real-time trade and order book market data.

Connection

The WebSocket server shares the same port as the HTTP API (1784517855). Connect to ws://127.0.0.1:{port}/.

Message format

All messages (inbound and outbound) are JSON with this envelope:

{ "Type": "message_type", "Data": { ... } }

Inbound messages (client → server)

Connection-level — subscribe by connection ID for order, position, balance, and finres updates:

TypeDataDescription
subscribe{ "ConnectionId": 123 }Subscribe to updates for a connection. Connection must be active. Idempotent.
unsubscribe{ "ConnectionId": 123 }Stop receiving updates for a connection. Idempotent.

Market data — subscribe by connection ID + ticker for trade or order book updates:

TypeDataDescription
trade_subscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT", "ZoomIndex": 1 }Subscribe to real-time trade updates. When ZoomIndex > 1, trades are aggregated by zoomed price level. Re-subscribing updates ZoomIndex.
trade_unsubscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Stop receiving trade updates for that ticker. Idempotent.
orderbook_subscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT", "ZoomIndex": 0, "DepthLevels": 50, "DepthPercent": 0.5 }Subscribe to order book updates. ZoomIndex > 1 aggregates price levels into zoomed buckets. Optional DepthLevels (top-N per side, snapshot only) and DepthPercent (per-side band on best ask / best bid, snapshot + updates). Idempotent — re-subscribing replaces these atomically.
orderbook_unsubscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Stop receiving order book updates for that ticker. Idempotent.
mark_price_subscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Subscribe to mark price updates (futures only). No initial snapshot — only live updates. Idempotent.
mark_price_unsubscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Stop receiving mark price updates for that ticker. Idempotent.
funding_subscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Subscribe to funding rate updates (perpetual futures only). No initial snapshot. Idempotent.
funding_unsubscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Stop receiving funding updates for that ticker. Idempotent.

Signal level subscriptions — subscribe to receive signal level events (placed, triggered, removed):

TypeDataDescription
signal_level_subscribe{}Subscribe to signal level updates. Receives an initial snapshot of all signal levels, then live events. Idempotent.
signal_level_unsubscribe{}Stop receiving signal level updates. Idempotent.

Outbound messages (server → client)

Acknowledgements:

TypeWhenData fields
subscribedAfter successful connection subscribeConnectionId
unsubscribedAfter successful connection unsubscribeConnectionId
trade_subscribedAfter successful trade subscribeConnectionId, Ticker
trade_unsubscribedAfter successful trade unsubscribeConnectionId, Ticker
orderbook_subscribedAfter successful order book subscribeConnectionId, Ticker, ZoomIndex, DepthLevels, DepthPercent (last two echoed only when set)
orderbook_unsubscribedAfter successful order book unsubscribeConnectionId, Ticker
mark_price_subscribedAfter successful mark price subscribeConnectionId, Ticker
mark_price_unsubscribedAfter successful mark price unsubscribeConnectionId, Ticker
funding_subscribedAfter successful funding subscribeConnectionId, Ticker
funding_unsubscribedAfter successful funding unsubscribeConnectionId, Ticker
notification_subscribedAfter successful notification subscribe
notification_unsubscribedAfter successful notification unsubscribe
signal_level_subscribedAfter successful signal level subscribe
signal_level_unsubscribedAfter successful signal level unsubscribe
ErrorInvalid message, bad connection ID, or missing tickerError (string)

Connection-level updates:

TypeWhenData fields
order_updateOrder created/changed/filled/cancelledConnectionId, OrderId, Ticker, Side, Type, Price, FilledPrice, Size, FilledSize, Fee, FeeCurrency, Status, Time
position_updatePosition opened/changed/closedConnectionId, PositionId, Ticker, Side, Size, AvgPrice, AvgPriceFix, AvgPriceDyn, Status
balance_updateAccount balance changedConnectionId, Balances[] with Coin, Total, Free, Locked
finres_updateFinancial results updatedConnectionId, Finreses[] with Currency, Result, Fee, Funds, Available, Blocked

Market data updates:

TypeWhenData fields
trade_updateNew trades for subscribed tickerConnectionId, Ticker, Trades[] with Price, Size, Side, Time
orderbook_snapshotFull order book on subscribeConnectionId, Ticker, Asks[], Bids[], BestAsk, BestBid — each with Price, Size, Type
orderbook_updateIncremental order book changesConnectionId, Ticker, Updates[] with Price, Size, Type
mark_price_updateMark price changed (futures only)ConnectionId, Ticker, MarkPrice
funding_updateFunding rate / time changed (perpetual futures only)ConnectionId, Ticker, FundingRate, FundingTime (ISO 8601)

Notification updates:

TypeWhenData fields
notification_snapshotOn subscribe — recent notifications (up to 200)Notifications[] with Type, Exchange, Ticker, Price, Size, Date, ...
notification_updateNew notifications (~1 sec batches)Notifications[] — same fields

Signal level updates:

TypeWhenData fields
signal_levels_snapshotOn subscribe — all signal levelsSignalLevels[] with Id, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule
signal_level_placedNew signal level createdId, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule
signal_level_triggeredSignal level triggered by priceId, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule
signal_level_removedSingle signal level removedId, ConnectionId, Ticker
signal_levels_removed_allAll signal levels for ticker clearedConnectionId, Ticker
signal_levels_removed_triggeredAll triggered signal levels cleared

Lifecycle

EventBehavior
Client connectsSession created. No updates until subscribe.
Subscribe (valid ID)Server responds with subscribed. Order, position, balance, finres updates start flowing.
Subscribe (invalid ID)Server responds with Error. No subscription created.
Subscribe (already subscribed)Idempotent — responds with confirmation, no duplicate events.
Trade/orderbook subscribe (valid)Server responds with trade_subscribed / orderbook_subscribed. Market data starts flowing for that ticker.
Trade/orderbook subscribe (invalid)Server responds with Error (bad connection ID or missing ticker).
Mark price / funding subscribe (valid)Server responds with mark_price_subscribed / funding_subscribed. Updates flow as the exchange publishes them (no initial snapshot). Spot connections will not emit any events.
UnsubscribeServer responds with confirmation. Updates stop for that subscription.
Notification subscribeServer responds notification_subscribed. Sends snapshot, then live updates.
Notification unsubscribeServer responds notification_unsubscribed. Updates stop.
Signal level subscribeServer responds signal_level_subscribed. Sends snapshot of all signal levels, then live events (placed, triggered, removed).
Signal level unsubscribeServer responds signal_level_unsubscribed. Signal level updates stop.
Client disconnectsAll subscriptions (connection-level, market data, notifications, signal levels) are cleaned up automatically.
Multiple connectionsA single client can subscribe to multiple connection IDs and multiple tickers simultaneously.
Example payloads
// Subscribe
{ "Type": "subscribe", "Data": { "ConnectionId": 1 } }

// Server confirms
{ "Type": "subscribed", "Data": { "ConnectionId": 1 } }

// Order update pushed by server
{
  "Type": "order_update",
  "Data": {
    "ConnectionId": 1,
    "OrderId": 98765,
    "Ticker": "BTCUSDT",
    "Side": "Buy",
    "Type": "Limit",
    "Price": 65000.0,
    "FilledPrice": 64980.5,
    "Size": 0.01,
    "FilledSize": 0.0,
    "Fee": 0.0013,
    "FeeCurrency": "USDT",
    "Status": "New",
    "Time": "2025-03-24T14:30:00+00:00"
  }
}

// Position update pushed by server
{
  "Type": "position_update",
  "Data": {
    "ConnectionId": 1,
    "PositionId": 4321,
    "Ticker": "ETHUSDT",
    "Side": "Buy",
    "Size": 1.5,
    "AvgPrice": 3200.00,
    "AvgPriceFix": 3200.00,
    "AvgPriceDyn": 3195.50,
    "Status": "Open"
  }
}

// Balance update pushed by server
{
  "Type": "balance_update",
  "Data": {
    "ConnectionId": 1,
    "Balances": [
      { "Coin": "USDT", "Total": 10000.0, "Free": 8500.0, "Locked": 1500.0 },
      { "Coin": "BTC", "Total": 0.5, "Free": 0.5, "Locked": 0.0 }
    ]
  }
}

// FinRes update pushed by server
{
  "Type": "finres_update",
  "Data": {
    "ConnectionId": 1,
    "Finreses": [
      { "Currency": "USDT", "Result": 250.50, "Fee": 12.30, "Funds": 10000.0, "Available": 8500.0, "Blocked": 1500.0 },
      { "Currency": "BTC", "Result": 0.005, "Fee": 0.0001, "Funds": 0.5, "Available": 0.5, "Blocked": 0.0 }
    ]
  }
}

// Subscribe to trades for a specific ticker
{ "Type": "trade_subscribe", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT", "ZoomIndex": 1 } }

// Server confirms trade subscription
{ "Type": "trade_subscribed", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT", "ZoomIndex": 1 } }

// Trade update pushed by server
{
  "Type": "trade_update",
  "Data": {
    "ConnectionId": 1,
    "Ticker": "BTCUSDT",
    "Trades": [
      { "Price": 65123.50, "Size": 0.15, "Side": "Buy", "Time": "2026-03-16T12:00:01.234+00:00" },
      { "Price": 65123.00, "Size": 0.03, "Side": "Sell", "Time": "2026-03-16T12:00:01.235+00:00" }
    ]
  }
}

// Subscribe to order book for a specific ticker
{ "Type": "orderbook_subscribe", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT", "ZoomIndex": 0, "DepthLevels": 50, "DepthPercent": 0.5 } }

// Server confirms order book subscription
{ "Type": "orderbook_subscribed", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT", "ZoomIndex": 0, "DepthLevels": 50, "DepthPercent": 0.5 } }

// Order book snapshot (full state, sent once on subscribe)
{
  "Type": "orderbook_snapshot",
  "Data": {
    "ConnectionId": 1,
    "Ticker": "BTCUSDT",
    "Asks": [
      { "Price": 65124.00, "Size": 1.20, "Type": "Ask" },
      { "Price": 65125.00, "Size": 0.85, "Type": "Ask" }
    ],
    "Bids": [
      { "Price": 65123.00, "Size": 2.50, "Type": "Bid" },
      { "Price": 65122.00, "Size": 1.10, "Type": "Bid" }
    ],
    "BestAsk": { "Price": 65124.00, "Size": 1.20, "Type": "BestAsk" },
    "BestBid": { "Price": 65123.00, "Size": 2.50, "Type": "BestBid" }
  }
}

// Order book incremental update
{
  "Type": "orderbook_update",
  "Data": {
    "ConnectionId": 1,
    "Ticker": "BTCUSDT",
    "Updates": [
      { "Price": 65124.00, "Size": 0.90, "Type": "Ask" },
      { "Price": 65126.00, "Size": 0.50, "Type": "Ask" },
      { "Price": 65123.00, "Size": 2.80, "Type": "Bid" }
    ]
  }
}

// Subscribe to mark price (futures only)
{ "Type": "mark_price_subscribe", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT" } }
{ "Type": "mark_price_subscribed", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT" } }

// Mark price update pushed by server
{ "Type": "mark_price_update", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT", "MarkPrice": 65123.5 } }

// Subscribe to funding rate (perpetual futures only)
{ "Type": "funding_subscribe", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT" } }
{ "Type": "funding_subscribed", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT" } }

// Funding update pushed by server
{ "Type": "funding_update", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT", "FundingRate": 0.0001, "FundingTime": "2026-03-16T16:00:00+00:00" } }

// Unsubscribe from market data
{ "Type": "trade_unsubscribe", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT" } }
{ "Type": "orderbook_unsubscribe", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT" } }
{ "Type": "mark_price_unsubscribe", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT" } }
{ "Type": "funding_unsubscribe", "Data": { "ConnectionId": 1, "Ticker": "BTCUSDT" } }

// Unsubscribe from connection
{ "Type": "unsubscribe", "Data": { "ConnectionId": 1 } }

// Error (invalid connection)
{ "Type": "error", "Data": { "Error": "Connection 999 not found or not active" } }

Reference

Exchange values

ValueExchange
2Binance
3Gate
5KuCoin
6Bybit
7Bitget
8Mexc
10Okx
11BingX
12HTX
13BitMart
14LBank
15HyperLiquid
16UpBit
17AsterDex
18Moex
19Lighter

MarketType values

ValueTypeDescription
0SpotSpot trading
1FuturesGeneric futures
2UsdtFuturesUSDT-margined futures
3CoinFuturesCoin-margined futures
4InverseFuturesInverse futures
5UsdtPerpetualUSDT perpetual swaps
6UsdcPerpetualUSDC perpetual swaps
7MarginMargin (cross/isolated)
8OptionsOptions contracts
9StockStock / equity markets
Unsure which market type to use? Use the ticker pattern approach instead — the .p suffix auto-resolves to the right futures type. For explicit fields, 2 (UsdtFutures) is the most common choice for perpetual futures.
When the requested market is not Spot and no exact match is found, MetaScalp falls back to any non-Spot connection on the same exchange.

Error responses

Errors return HTTP 400 or 404 with a JSON body.

EndpointConditionHTTPError message
/api/change-tickerMissing fields400Invalid request body. Provide 'TickerPattern' or 'exchange'+'market'+'ticker'.
/api/change-tickerInvalid pattern400Invalid ticker pattern: '{pattern}'
/api/change-tickerBinding not found400Binding '{name}' not found. Available: {list}
/api/change-tickerNo connection400No connection found for exchange ... and market ...
/api/change-tickerTicker not on connection400Ticker '{ticker}' not found on connection {id}
/api/comboMissing ticker400Invalid request body. 'ticker' is required.
/api/connections/{id}Connection not found404Connection {id} not found
/api/connections/{id}/...Invalid connection ID400Invalid connection ID
/api/connections/{id}/...Connection not found404Connection {id} not found
/api/connections/{id}/...Connection not active400Connection {id} is not active
/api/connections/{id}/ordersMissing ticker query param400Query parameter 'Ticker' is required
/api/connections/{id}/ordersInvalid order fields400Invalid request body. 'ticker', 'side', 'price', and 'size' are required.
/api/connections/{id}/ordersSize <= 0400Size must be greater than zero
/api/connections/{id}/ordersPrice <= 0 (non-market)400Price must be greater than zero for non-market orders
/api/connections/{id}/orders/cancelMissing fields400Invalid request body. 'ticker' and 'OrderId' are required.
/api/connections/{id}/orders/cancel-allMissing ticker400Invalid request body. 'ticker' is required.
/api/connections/{id}/cluster-snapshotMissing ticker or timeframe400Query parameter 'Ticker' is required
/api/connections/{id}/cluster-snapshotTicker not found404Ticker 'XYZ' not found
/api/connections/{id}/signal-levelsMissing ticker query param400Query parameter 'Ticker' is required
/api/connections/{id}/signal-levelsInvalid request body400Invalid request body. 'ticker' and 'price' are required.
/api/connections/{id}/signal-levelsNo market data400No market data for 'TICKER'. Subscribe to order book data for this ticker first.
/api/connections/{id}/signal-levelsPrice <= 0400Price must be greater than zero
/api/connections/{id}/orderbook-settingsMissing ticker400Query parameter 'Ticker' is required
/api/connections/{id}/orderbook-settingsNo settings found404No order book settings found for ticker 'X'
/api/connections/{id}/orderbook-settingsInvalid enum value (PUT)400Invalid value 'X' for field 'ShowRuler'. Valid values: None, Points, Percent, PercentVolume
anyUnknown path400Not found
anyWrong HTTP method400Method not allowed

Socket error messages

Socket errors are sent as { "Type": "error", "Data": { "Error": "..." } }

ConditionError message
Subscribe to non-existent connectionConnection {id} not found or not active
Trade/orderbook subscribe with missing tickerTicker is required for trade subscription / Ticker is required for order book subscription
Trade/orderbook subscribe with invalid connectionConnection {id} not found or not active
Unknown message typeUnknown message type: {type}
Invalid JSONInvalid message format

📄 MetaScalp-Api.md

⬇ Download .md

MetaScalp API

MetaScalp exposes a local API that lets your scripts and bots interact with connected exchanges. Use HTTP REST endpoints for request/response operations and WebSocket for real-time streaming of orders, positions, balances, trades, and order book data.

  • Host: 127.0.0.1 (localhost only)
  • HTTP port range: 1784517855 (first available)
  • WebSocket: Same port as HTTP (upgrade requests accepted automatically)
  • Content-Type: application/json
  • CORS: All responses include Access-Control-Allow-Origin: *.

Overview

HTTP REST endpoints

Use HTTP to discover connections, query data, and execute trades:

EndpointPurpose
GET /pingFind the running MetaScalp instance and check its version
POST /api/change-tickerSwitch the active ticker in the MetaScalp UI
POST /api/comboOpen a combo layout for a ticker
GET /api/connectionsList all active exchange connections
GET /api/connections/{id}/...Query tickers, orders, positions, balances for a connection
POST /api/connections/{id}/ordersPlace an order on a connection
POST /api/connections/{id}/orders/cancelCancel a single order
POST /api/connections/{id}/orders/cancel-allCancel all orders for a ticker
GET /api/connections/{id}/cluster-snapshotGet cluster (volume profile) snapshot data
GET /api/connections/{id}/signal-levels?Ticker=List signal levels for a ticker
POST /api/connections/{id}/signal-levelsPlace a signal level
DELETE /api/connections/{id}/signal-levels/{slId}Remove a single signal level
DELETE /api/connections/{id}/signal-levels?Ticker=Remove all signal levels for a ticker
DELETE /api/signal-levels/triggeredRemove all triggered signal levels
GET /api/connections/{id}/orderbook-settings?Ticker=Get order book settings
PUT /api/connections/{id}/orderbook-settings?Ticker=Update order book settings (partial)

WebSocket streaming

Connect via WebSocket to receive real-time updates for your exchange connections.

  • Connect to ws://127.0.0.1:{port}/ (same port as HTTP — scan 1784517855)
  • Connection-level: Send subscribe with a connection ID to receive order, position, balance, and finres updates
  • Market data: Send trade_subscribe, orderbook_subscribe, mark_price_subscribe, or funding_subscribe with connection ID + ticker to receive trade, order book, mark price, or funding updates
  • Signal level subscriptions: Send signal_level_subscribe to receive signal level events (no connection ID required)
  • You can subscribe to multiple connections and tickers simultaneously
  • All subscriptions are automatically cleaned up when you disconnect

Getting started

1. Launch MetaScalp — both HTTP and WebSocket servers start automatically.

2. Discover the port — scan 1784517855 with GET /ping.

3. List connections — call GET /api/connections to see available exchange connections.

4. Execute operations — use a connection ID for REST queries or WebSocket subscriptions.

Typical REST client flow

GET /ping                                         → find MetaScalp
GET /api/connections                              → list active connections
GET /api/connections/{id}/tickers                 → get available tickers
GET /api/connections/{id}/balance                 → check balances
GET /api/connections/{id}/orders?Ticker=BTCUSDT   → view open orders
POST /api/connections/{id}/orders                 → place an order
POST /api/connections/{id}/orders/cancel          → cancel an order
POST /api/connections/{id}/orders/cancel-all      → cancel all orders for a ticker
GET  /api/connections/{id}/cluster-snapshot        → get cluster snapshot data
GET  /api/connections/{id}/signal-levels?Ticker=   → list signal levels
POST /api/connections/{id}/signal-levels           → place a signal level
DELETE /api/connections/{id}/signal-levels/{slId}  → remove a signal level
GET  /api/connections/{id}/orderbook-settings?Ticker= → get orderbook settings
PUT  /api/connections/{id}/orderbook-settings?Ticker= → update orderbook settings

Typical WebSocket client flow

1. Connect
ws = new WebSocket("ws://127.0.0.1:17845/")

2. Subscribe to a connection (orders, positions, balances, finres)
ws.send('{"Type":"subscribe","Data":{"ConnectionId":1}}')
← {"Type":"subscribed","Data":{"ConnectionId":1}}

3. Subscribe to market data for a specific ticker
ws.send('{"Type":"trade_subscribe","Data":{"ConnectionId":1,"Ticker":"BTCUSDT","ZoomIndex":1}}')
← {"Type":"trade_subscribed","Data":{"ConnectionId":1,"Ticker":"BTCUSDT","ZoomIndex":1}}
ws.send('{"Type":"orderbook_subscribe","Data":{"ConnectionId":1,"Ticker":"BTCUSDT","ZoomIndex":0,"DepthLevels":50,"DepthPercent":0.5}}')
← {"Type":"orderbook_subscribed","Data":{"ConnectionId":1,"Ticker":"BTCUSDT","ZoomIndex":0,"DepthLevels":50,"DepthPercent":0.5}}
ws.send('{"Type":"mark_price_subscribe","Data":{"ConnectionId":1,"Ticker":"BTCUSDT"}}')
← {"Type":"mark_price_subscribed","Data":{"ConnectionId":1,"Ticker":"BTCUSDT"}}
ws.send('{"Type":"funding_subscribe","Data":{"ConnectionId":1,"Ticker":"BTCUSDT"}}')
← {"Type":"funding_subscribed","Data":{"ConnectionId":1,"Ticker":"BTCUSDT"}}

4. Subscribe to signal levels
ws.send('{"Type":"signal_level_subscribe","Data":{}}')
← {"Type":"signal_level_subscribed","Data":{}}
← {"Type":"signal_levels_snapshot","Data":{"SignalLevels":[...]}}

5. Receive real-time updates
← {"Type":"order_update","Data":{"ConnectionId":1,"OrderId":123,...}}
← {"Type":"position_update","Data":{"ConnectionId":1,...}}
← {"Type":"balance_update","Data":{"ConnectionId":1,"Balances":[...]}}
← {"Type":"finres_update","Data":{"ConnectionId":1,"Finreses":[...]}}
← {"Type":"trade_update","Data":{"ConnectionId":1,"Ticker":"BTCUSDT","Trades":[...]}}
← {"Type":"orderbook_snapshot","Data":{"ConnectionId":1,"Ticker":"BTCUSDT","Asks":[...],"Bids":[...],...}}
← {"Type":"orderbook_update","Data":{"ConnectionId":1,"Ticker":"BTCUSDT","Updates":[...]}}
← {"Type":"mark_price_update","Data":{"ConnectionId":1,"Ticker":"BTCUSDT","MarkPrice":65123.5}}
← {"Type":"funding_update","Data":{"ConnectionId":1,"Ticker":"BTCUSDT","FundingRate":0.0001,"FundingTime":"2026-03-16T16:00:00+00:00"}}
← {"Type":"signal_level_placed","Data":{"Id":1,"ConnectionId":1,"Ticker":"BTCUSDT","Price":95000,...}}
← {"Type":"signal_level_triggered","Data":{"Id":1,"TriggerTime":"2026-04-13T..."}}

6. Unsubscribe when done
ws.send('{"Type":"signal_level_unsubscribe","Data":{}}')
ws.send('{"Type":"trade_unsubscribe","Data":{"ConnectionId":1,"Ticker":"BTCUSDT"}}')
ws.send('{"Type":"orderbook_unsubscribe","Data":{"ConnectionId":1,"Ticker":"BTCUSDT"}}')
ws.send('{"Type":"mark_price_unsubscribe","Data":{"ConnectionId":1,"Ticker":"BTCUSDT"}}')
ws.send('{"Type":"funding_unsubscribe","Data":{"ConnectionId":1,"Ticker":"BTCUSDT"}}')
ws.send('{"Type":"unsubscribe","Data":{"ConnectionId":1}}')
← {"Type":"unsubscribed","Data":{"ConnectionId":1}}

WebSocket message reference

Messages you send

TypeDataDescription
subscribe{ "ConnectionId": 123 }Start receiving order, position, balance, finres updates for a connection.
unsubscribe{ "ConnectionId": 123 }Stop receiving connection-level updates.
trade_subscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT", "ZoomIndex": 1 }Start receiving trade updates. ZoomIndex > 1 aggregates by zoomed price.
trade_unsubscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Stop receiving trade updates for that ticker.
orderbook_subscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT", "ZoomIndex": 0, "DepthLevels": 50, "DepthPercent": 0.5 }Start receiving order book updates. ZoomIndex > 1 aggregates price levels. Optional DepthLevels (snapshot only) and DepthPercent (snapshot + updates) trim the payload.
orderbook_unsubscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Stop receiving order book updates for that ticker.
mark_price_subscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Start receiving mark price updates (futures only). No initial snapshot.
mark_price_unsubscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Stop receiving mark price updates for that ticker.
funding_subscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Start receiving funding rate updates (perpetual futures only). No initial snapshot.
funding_unsubscribe{ "ConnectionId": 123, "Ticker": "BTCUSDT" }Stop receiving funding updates for that ticker.
notification_subscribe{}Start receiving app-wide notifications.
notification_unsubscribe{}Stop receiving notifications.
signal_level_subscribe{}Start receiving signal level events.
signal_level_unsubscribe{}Stop receiving signal level events.

Messages you receive

TypeData fields
subscribedConnectionId
unsubscribedConnectionId
trade_subscribedConnectionId, Ticker
trade_unsubscribedConnectionId, Ticker
orderbook_subscribedConnectionId, Ticker
orderbook_unsubscribedConnectionId, Ticker
mark_price_subscribedConnectionId, Ticker
mark_price_unsubscribedConnectionId, Ticker
funding_subscribedConnectionId, Ticker
funding_unsubscribedConnectionId, Ticker
order_updateConnectionId, OrderId, Ticker, Side, Type, Price, FilledPrice, Size, FilledSize, Fee, FeeCurrency, Status, Time
position_updateConnectionId, PositionId, Ticker, Side, Size, AvgPrice, AvgPriceFix, AvgPriceDyn, Status
balance_updateConnectionId, Balances[]: Coin, Total, Free, Locked
finres_updateConnectionId, Finreses[]: Currency, Result, Fee, Funds, Available, Blocked
trade_updateConnectionId, Ticker, Trades[]: Price, Size, Side, Time
orderbook_snapshotConnectionId, Ticker, Asks[], Bids[], BestAsk, BestBid — each: Price, Size, Type
orderbook_updateConnectionId, Ticker, Updates[]: Price, Size, Type
mark_price_updateConnectionId, Ticker, MarkPrice
funding_updateConnectionId, Ticker, FundingRate, FundingTime (ISO 8601)
notification_subscribed
notification_unsubscribed
notification_snapshotNotifications[]: Type, Exchange, Ticker, Price, Size, Date, ...
notification_updateNotifications[] — same fields
signal_level_subscribed
signal_level_unsubscribed
signal_levels_snapshotSignalLevels[]: Id, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule
signal_level_placedId, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule
signal_level_triggeredId, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule
signal_level_removedId, ConnectionId, Ticker
signal_levels_removed_allConnectionId, Ticker
signal_levels_removed_triggered
ErrorError (string message)

For complete endpoint documentation with request/response details, field descriptions, and integration examples, see the interactive panels above or download the Markdown file.