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: 17845–17855 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
Scan ports 17845–17855 to find the running MetaScalp instance. Returns the app name and version.
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.
EXCHANGE:SYMBOL.suffix — suffix: .p (futures), .m (margin), .o (options), omitted (spot)_, /, -, $, :.BINANCE:BTCUSDT.p, BYBIT:ETHUSDT, OKX:BTC-USDT.m, HYPERLIQUID:cash:HOODUSDT0.p
Opens a combo layout for the specified ticker in the MetaScalp UI.
Returns all currently active exchange connections. Use the Id from the response to query orders, positions, balances, or to subscribe via WebSocket.
| Field | Type | Description |
|---|---|---|
Id | integer | Connection ID — use for all exchange operations |
Name | string | User-defined connection name |
Exchange | string | Exchange name |
ExchangeId | integer | Exchange identifier |
Market | string | Market display name |
MarketType | integer | Market type enum value |
State | integer | 0=Disconnected, 1=Connecting, 2=Connected, 3=Reconnecting, 4=Resetting |
ViewMode | boolean | Read-only (no trading) |
DemoMode | boolean | Paper trading |
Returns details for a single connection by ID.
Returns all available trading pairs on a connection with price/size precision, trading status, and constraints.
Returns open orders for a specific ticker on a connection. The Ticker query parameter is required.
| Field | Type | Description |
|---|---|---|
Id | integer | Exchange order ID |
Ticker | string | Trading pair |
ClientId | string? | Client-generated order ID |
Side | integer | 0 None, 1 Buy, 2 Sell |
Price | decimal | Order price |
Size | decimal | Order size |
FilledSize | decimal | Filled amount |
FilledPrice | decimal | Execution price (0 if not yet filled) |
RemainingSize | decimal | Remaining amount |
Status | integer | 0 New, 1 Open, 2 Closed |
Type | integer | 0 Limit, 1 Stop, 2 StopLoss, 3 TakeProfit, 4 Market |
TriggerPrice | decimal? | Trigger price for stop/conditional orders |
CreateDate | string (ISO) | Order creation timestamp |
Returns all open positions on a connection (futures/margin markets).
Returns account balances for all assets on a connection.
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).
| Field | Type | Required | Description |
|---|---|---|---|
Ticker | string | yes | Trading pair symbol |
Side | integer | yes | 1 Buy, 2 Sell |
Price | decimal | yes* | Order price (*required for non-market orders) |
Size | decimal | yes | Order size (must be > 0) |
Type | integer | no | 0 Limit (default), 1 Stop, 2 StopLoss, 3 TakeProfit, 4 Market |
ReduceOnly | boolean | no | Close-only, default false |
Cancels an existing order on the exchange.
| Field | Type | Required | Description |
|---|---|---|---|
Ticker | string | yes | Trading pair symbol |
OrderId | integer | yes | Exchange order ID |
Type | integer | no | Order type (default 0 Limit) |
Cancels all open orders for a given ticker on the exchange.
| Field | Type | Required | Description |
|---|---|---|---|
Ticker | string | yes | Trading pair symbol |
Returns CancelledCount: 0 if there are no open orders for that ticker.
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.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
Ticker | string | yes | Trading pair symbol | |
TimeFrame | string | yes | S30, M1, M5, M10, M15, M30, H1, D1 | |
ZoomIndex | int | no | 1 | Price aggregation factor (1 = raw levels) |
When ZoomIndex > 1, prices are grouped into buckets of ZoomIndex × PriceIncrement and volumes are summed.
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.
| Field | Type | Description |
|---|---|---|
Id | integer | Signal level ID |
ConnectionId | integer | Connection this signal level belongs to |
Ticker | string | Trading pair symbol |
Price | decimal | Price threshold |
IsTriggered | boolean | Whether the signal has been triggered |
TriggerTime | string (ISO)? | When triggered (null if not triggered) |
TriggerRule | string | "LessThanEqual" or "GreaterThanEqual" |
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.
| Field | Type | Required | Description |
|---|---|---|---|
Ticker | string | yes | Trading pair symbol |
Price | decimal | yes | Price threshold (must be > 0) |
Removes a single signal level by ID.
Removes all signal levels for a specific ticker on a connection.
Removes all triggered signal levels across all connections and tickers.
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.
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).
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.
The WebSocket server shares the same port as the HTTP API (17845–17855). Connect to ws://127.0.0.1:{port}/.
All messages (inbound and outbound) are JSON with this envelope:
{ "Type": "message_type", "Data": { ... } }
Connection-level — subscribe by connection ID for order, position, balance, and finres updates:
| Type | Data | Description |
|---|---|---|
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:
| Type | Data | Description |
|---|---|---|
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):
| Type | Data | Description |
|---|---|---|
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. |
Acknowledgements:
| Type | When | Data fields |
|---|---|---|
subscribed | After successful connection subscribe | ConnectionId |
unsubscribed | After successful connection unsubscribe | ConnectionId |
trade_subscribed | After successful trade subscribe | ConnectionId, Ticker |
trade_unsubscribed | After successful trade unsubscribe | ConnectionId, Ticker |
orderbook_subscribed | After successful order book subscribe | ConnectionId, Ticker, ZoomIndex, DepthLevels, DepthPercent (last two echoed only when set) |
orderbook_unsubscribed | After successful order book unsubscribe | ConnectionId, Ticker |
mark_price_subscribed | After successful mark price subscribe | ConnectionId, Ticker |
mark_price_unsubscribed | After successful mark price unsubscribe | ConnectionId, Ticker |
funding_subscribed | After successful funding subscribe | ConnectionId, Ticker |
funding_unsubscribed | After successful funding unsubscribe | ConnectionId, Ticker |
notification_subscribed | After successful notification subscribe | — |
notification_unsubscribed | After successful notification unsubscribe | — |
signal_level_subscribed | After successful signal level subscribe | — |
signal_level_unsubscribed | After successful signal level unsubscribe | — |
Error | Invalid message, bad connection ID, or missing ticker | Error (string) |
Connection-level updates:
| Type | When | Data fields |
|---|---|---|
order_update | Order created/changed/filled/cancelled | ConnectionId, OrderId, Ticker, Side, Type, Price, FilledPrice, Size, FilledSize, Fee, FeeCurrency, Status, Time |
position_update | Position opened/changed/closed | ConnectionId, PositionId, Ticker, Side, Size, AvgPrice, AvgPriceFix, AvgPriceDyn, Status |
balance_update | Account balance changed | ConnectionId, Balances[] with Coin, Total, Free, Locked |
finres_update | Financial results updated | ConnectionId, Finreses[] with Currency, Result, Fee, Funds, Available, Blocked |
Market data updates:
| Type | When | Data fields |
|---|---|---|
trade_update | New trades for subscribed ticker | ConnectionId, Ticker, Trades[] with Price, Size, Side, Time |
orderbook_snapshot | Full order book on subscribe | ConnectionId, Ticker, Asks[], Bids[], BestAsk, BestBid — each with Price, Size, Type |
orderbook_update | Incremental order book changes | ConnectionId, Ticker, Updates[] with Price, Size, Type |
mark_price_update | Mark price changed (futures only) | ConnectionId, Ticker, MarkPrice |
funding_update | Funding rate / time changed (perpetual futures only) | ConnectionId, Ticker, FundingRate, FundingTime (ISO 8601) |
Notification updates:
| Type | When | Data fields |
|---|---|---|
notification_snapshot | On subscribe — recent notifications (up to 200) | Notifications[] with Type, Exchange, Ticker, Price, Size, Date, ... |
notification_update | New notifications (~1 sec batches) | Notifications[] — same fields |
Signal level updates:
| Type | When | Data fields |
|---|---|---|
signal_levels_snapshot | On subscribe — all signal levels | SignalLevels[] with Id, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule |
signal_level_placed | New signal level created | Id, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule |
signal_level_triggered | Signal level triggered by price | Id, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule |
signal_level_removed | Single signal level removed | Id, ConnectionId, Ticker |
signal_levels_removed_all | All signal levels for ticker cleared | ConnectionId, Ticker |
signal_levels_removed_triggered | All triggered signal levels cleared | — |
| Event | Behavior |
|---|---|
| Client connects | Session 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. |
| Unsubscribe | Server responds with confirmation. Updates stop for that subscription. |
| Notification subscribe | Server responds notification_subscribed. Sends snapshot, then live updates. |
| Notification unsubscribe | Server responds notification_unsubscribed. Updates stop. |
| Signal level subscribe | Server responds signal_level_subscribed. Sends snapshot of all signal levels, then live events (placed, triggered, removed). |
| Signal level unsubscribe | Server responds signal_level_unsubscribed. Signal level updates stop. |
| Client disconnects | All subscriptions (connection-level, market data, notifications, signal levels) are cleaned up automatically. |
| Multiple connections | A single client can subscribe to multiple connection IDs and multiple tickers simultaneously. |
// 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" } }
| Value | Exchange |
|---|---|
| 2 | Binance |
| 3 | Gate |
| 5 | KuCoin |
| 6 | Bybit |
| 7 | Bitget |
| 8 | Mexc |
| 10 | Okx |
| 11 | BingX |
| 12 | HTX |
| 13 | BitMart |
| 14 | LBank |
| 15 | HyperLiquid |
| 16 | UpBit |
| 17 | AsterDex |
| 18 | Moex |
| 19 | Lighter |
| Value | Type | Description |
|---|---|---|
| 0 | Spot | Spot trading |
| 1 | Futures | Generic futures |
| 2 | UsdtFutures | USDT-margined futures |
| 3 | CoinFutures | Coin-margined futures |
| 4 | InverseFutures | Inverse futures |
| 5 | UsdtPerpetual | USDT perpetual swaps |
| 6 | UsdcPerpetual | USDC perpetual swaps |
| 7 | Margin | Margin (cross/isolated) |
| 8 | Options | Options contracts |
| 9 | Stock | Stock / equity markets |
.p suffix auto-resolves to the right futures type. For explicit fields, 2 (UsdtFutures) is the most common choice for perpetual futures.Errors return HTTP 400 or 404 with a JSON body.
| Endpoint | Condition | HTTP | Error message |
|---|---|---|---|
/api/change-ticker | Missing fields | 400 | Invalid request body. Provide 'TickerPattern' or 'exchange'+'market'+'ticker'. |
/api/change-ticker | Invalid pattern | 400 | Invalid ticker pattern: '{pattern}' |
/api/change-ticker | Binding not found | 400 | Binding '{name}' not found. Available: {list} |
/api/change-ticker | No connection | 400 | No connection found for exchange ... and market ... |
/api/change-ticker | Ticker not on connection | 400 | Ticker '{ticker}' not found on connection {id} |
/api/combo | Missing ticker | 400 | Invalid request body. 'ticker' is required. |
/api/connections/{id} | Connection not found | 404 | Connection {id} not found |
/api/connections/{id}/... | Invalid connection ID | 400 | Invalid connection ID |
/api/connections/{id}/... | Connection not found | 404 | Connection {id} not found |
/api/connections/{id}/... | Connection not active | 400 | Connection {id} is not active |
/api/connections/{id}/orders | Missing ticker query param | 400 | Query parameter 'Ticker' is required |
/api/connections/{id}/orders | Invalid order fields | 400 | Invalid request body. 'ticker', 'side', 'price', and 'size' are required. |
/api/connections/{id}/orders | Size <= 0 | 400 | Size must be greater than zero |
/api/connections/{id}/orders | Price <= 0 (non-market) | 400 | Price must be greater than zero for non-market orders |
/api/connections/{id}/orders/cancel | Missing fields | 400 | Invalid request body. 'ticker' and 'OrderId' are required. |
/api/connections/{id}/orders/cancel-all | Missing ticker | 400 | Invalid request body. 'ticker' is required. |
/api/connections/{id}/cluster-snapshot | Missing ticker or timeframe | 400 | Query parameter 'Ticker' is required |
/api/connections/{id}/cluster-snapshot | Ticker not found | 404 | Ticker 'XYZ' not found |
/api/connections/{id}/signal-levels | Missing ticker query param | 400 | Query parameter 'Ticker' is required |
/api/connections/{id}/signal-levels | Invalid request body | 400 | Invalid request body. 'ticker' and 'price' are required. |
/api/connections/{id}/signal-levels | No market data | 400 | No market data for 'TICKER'. Subscribe to order book data for this ticker first. |
/api/connections/{id}/signal-levels | Price <= 0 | 400 | Price must be greater than zero |
/api/connections/{id}/orderbook-settings | Missing ticker | 400 | Query parameter 'Ticker' is required |
/api/connections/{id}/orderbook-settings | No settings found | 404 | No order book settings found for ticker 'X' |
/api/connections/{id}/orderbook-settings | Invalid enum value (PUT) | 400 | Invalid value 'X' for field 'ShowRuler'. Valid values: None, Points, Percent, PercentVolume |
| any | Unknown path | 400 | Not found |
| any | Wrong HTTP method | 400 | Method not allowed |
Socket errors are sent as { "Type": "error", "Data": { "Error": "..." } }
| Condition | Error message |
|---|---|
| Subscribe to non-existent connection | Connection {id} not found or not active |
| Trade/orderbook subscribe with missing ticker | Ticker is required for trade subscription / Ticker is required for order book subscription |
| Trade/orderbook subscribe with invalid connection | Connection {id} not found or not active |
| Unknown message type | Unknown message type: {type} |
| Invalid JSON | Invalid message format |
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.
127.0.0.1 (localhost only)17845–17855 (first available)application/jsonAccess-Control-Allow-Origin: *.Use HTTP to discover connections, query data, and execute trades:
| Endpoint | Purpose |
|---|---|
GET /ping | Find the running MetaScalp instance and check its version |
POST /api/change-ticker | Switch the active ticker in the MetaScalp UI |
POST /api/combo | Open a combo layout for a ticker |
GET /api/connections | List all active exchange connections |
GET /api/connections/{id}/... | Query tickers, orders, positions, balances for a connection |
POST /api/connections/{id}/orders | Place an order on a connection |
POST /api/connections/{id}/orders/cancel | Cancel a single order |
POST /api/connections/{id}/orders/cancel-all | Cancel all orders for a ticker |
GET /api/connections/{id}/cluster-snapshot | Get cluster (volume profile) snapshot data |
GET /api/connections/{id}/signal-levels?Ticker= | List signal levels for a ticker |
POST /api/connections/{id}/signal-levels | Place 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/triggered | Remove 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) |
Connect via WebSocket to receive real-time updates for your exchange connections.
ws://127.0.0.1:{port}/ (same port as HTTP — scan 17845–17855)subscribe with a connection ID to receive order, position, balance, and finres updatestrade_subscribe, orderbook_subscribe, mark_price_subscribe, or funding_subscribe with connection ID + ticker to receive trade, order book, mark price, or funding updatessignal_level_subscribe to receive signal level events (no connection ID required)1. Launch MetaScalp — both HTTP and WebSocket servers start automatically.
2. Discover the port — scan 17845–17855 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.
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
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}}
| Type | Data | Description |
|---|---|---|
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. |
| Type | Data fields |
|---|---|
subscribed | ConnectionId |
unsubscribed | ConnectionId |
trade_subscribed | ConnectionId, Ticker |
trade_unsubscribed | ConnectionId, Ticker |
orderbook_subscribed | ConnectionId, Ticker |
orderbook_unsubscribed | ConnectionId, Ticker |
mark_price_subscribed | ConnectionId, Ticker |
mark_price_unsubscribed | ConnectionId, Ticker |
funding_subscribed | ConnectionId, Ticker |
funding_unsubscribed | ConnectionId, Ticker |
order_update | ConnectionId, OrderId, Ticker, Side, Type, Price, FilledPrice, Size, FilledSize, Fee, FeeCurrency, Status, Time |
position_update | ConnectionId, PositionId, Ticker, Side, Size, AvgPrice, AvgPriceFix, AvgPriceDyn, Status |
balance_update | ConnectionId, Balances[]: Coin, Total, Free, Locked |
finres_update | ConnectionId, Finreses[]: Currency, Result, Fee, Funds, Available, Blocked |
trade_update | ConnectionId, Ticker, Trades[]: Price, Size, Side, Time |
orderbook_snapshot | ConnectionId, Ticker, Asks[], Bids[], BestAsk, BestBid — each: Price, Size, Type |
orderbook_update | ConnectionId, Ticker, Updates[]: Price, Size, Type |
mark_price_update | ConnectionId, Ticker, MarkPrice |
funding_update | ConnectionId, Ticker, FundingRate, FundingTime (ISO 8601) |
notification_subscribed | — |
notification_unsubscribed | — |
notification_snapshot | Notifications[]: Type, Exchange, Ticker, Price, Size, Date, ... |
notification_update | Notifications[] — same fields |
signal_level_subscribed | — |
signal_level_unsubscribed | — |
signal_levels_snapshot | SignalLevels[]: Id, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule |
signal_level_placed | Id, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule |
signal_level_triggered | Id, ConnectionId, Ticker, Price, IsTriggered, TriggerTime, TriggerRule |
signal_level_removed | Id, ConnectionId, Ticker |
signal_levels_removed_all | ConnectionId, Ticker |
signal_levels_removed_triggered | — |
Error | Error (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.