Introduction
Developers can easily connect to the GTE WebSocket API to stream available market data. We recommend using a single connection to subscribe to multiple topics. Each subscription requires the following fields:
- id
- An arbitrary
int64
identifier chosen by the developer. The Websocket server will respond with the same id
to confirm actions.
- method
- Specifies the topic to subscribe or unsubscribe from.
- params
- Parameters specific to the subscription topic. When unsubscribing, the params must match the original subscription.
Trades
The trades channel provides real-time updates for trades of a specified market.
Trades Subscription Request
{
"id": number,
"method": "trades.subscribe",
"params": {
"market": string, // Market address
}
}
Trades Unsubscription Request
{
"id": number,
"method": "trades.unsubscribe",
"params": {
"market": string, // Market address
}
}
The response structure is as follows:
{
"s": "trades",
"d": {
"sd": string, // Side ("buy" or "sell")
"m": string, // Market address
"px": string, // Price
"sz": string, // Size
"h": string, // Transaction hash
"id": number, // Trade Id
"t": number // Timestamp (UTC millis)
}
}
Candles
The candles channel provide OHLCV.
Supported candle intervals: 1s, 30s, 1m, 3m, 5m, 15m, 30m, 1h, 4h, 6h, 8h, 12h, 1d, 1w
Candles Subscription Request
{
"id": number,
"method": "candles.subscribe",
"params": {
"market": string, // Market address
"interval": number
}
}
Candles Unsubscription Request
{
"id": number,
"method": "candles.unsubscribe",
"params": {
"market": string, // Market address
"interval": number
}
}
The response structure is as follows:
{
"s": "candles",
"d": {
"m": string, // Market address
"t": number, // Candle start time (timestamp in milliseconds)
"i": string, // Interval (e.g., "1m" for 1 minute)
"o": string, // Open price
"h": string, // High price
"l": string, // Low price
"c": string, // Close price
"v": string, // Volume (base unit)
"n": number // Number of trades
}
}
L2 Orderbook
The orderbook channel provides real-time updates for the order book of a specified market.
Orderbook Subscription Request
{
"id": number,
"method": "book.subscribe",
"params": {
"market": string, // Market address
"limit": number // Optional - defaults to 10
}
}
Orderbook Unsubscription Request
{
"id": number,
"method": "book.unsubscribe",
"params": {
"market": string, // Market address
"limit": number // Optional - defaults to 10
}
}
The response structure is as follows:
{
"s": "book",
"d": {
"a": [{"px": string, "sz": string , "n": number}], // Asks. Sorted from lowest to highest (px)
"b": [{"px": string, "sz": string , "n": number}], // Bids. Sorted from highest to lowest (px)
"t": number, // Timestamp (UTC Millis)
"m": string // Market address
}
}
Order Events
The order events channel provides real-time order updates for users.
Order Events Subscription Request
{
"id": number,
"method": "orders.subscribe",
"params": {
"market": string, // Market address
"user": string // User wallet address
}
}
Order Events Unsubscription Request
{
"id": number,
"method": "orders.unsubscribe",
"params": {
"market": string, // Market address
"user": string // User wallet address
}
}
The stream will return these order events: placed
, filled
, amended
, and canceled
.
The payload for each order event contains the following structure:
Order Placed
{
"s": "orders",
"d": {
"e": "placed",
"id": string, // Order Id
"m": string, // Market address
"h": string, // Transaction hash
"t": number, // Timestamp (UTC millis)
"sd": string, // Side
"sz": string, // Size
"px": string // Price
}
}
Order Filled
{
"s": "orders",
"d": {
"e": "filled",
"id": string, // Order Id
"m": string, // Market address
"h": string, // Transaction hash
"t": number, // Timestamp (UTC millis)
"tid": string, // Taker Order Id
"sd": string, // Side
"sz": string, // Size Filled
"px": string, // Executed Price
"tkr": string // Taker address
}
}
Order Amended
{
"s": "orders",
"d": {
"e": "amended",
"id": string, // Order Id
"m": string, // Market address
"h": string, // Transaction hash
"t": number, // Timestamp (UTC millis)
"osz": string, // Old Size
"sz": string, // New Size
"opx": string, // Old Price
"px": string, // New Price
"osd": string, // Old Side
"sd": string // New Side
}
}
Order Canceled
{
"s": "orders",
"d": {
"e": "canceled",
"id": string, // Order Id
"m": string, // Market address
"h": string, // Transaction hash
"t": number // Timestamp (UTC millis)
}
}
Error Handling
In case of an error, the following structure will be returned:
{
"id": number,
"code": number, // Error code
"message": string // Error message
}
Error codes
Code | Description |
---|
1 | Malformed Request |
2 | Unknown Method |