Builder ToolsGX Core Tools

GX Core Tools

Overview

GX Core tools provide direct access to the GX Core matching engine, orderbook, and trading APIs. These tools are designed for trading bots, market makers, data aggregators, and applications that need low-latency access to the exchange.

API Endpoints

InterfaceURLProtocol
REST APIhttps://api.gx.exchange/v4/HTTP/JSON
WebSocketwss://ws.gx.exchangeWebSocket/JSON
Testnet RESThttps://testnet-api.gx.exchange/v4/HTTP/JSON
Testnet WebSocketwss://testnet-ws.gx.exchangeWebSocket/JSON

REST API

Public Endpoints (No Authentication)

# Markets
GET /v4/markets
 
# Orderbook
GET /v4/orderbook?market=BTC-USD&depth=20
 
# Recent trades
GET /v4/trades?market=BTC-USD&limit=100
 
# Candles
GET /v4/candles?market=BTC-USD&interval=1h&limit=500
 
# Funding rates
GET /v4/funding?market=BTC-USD
 
# Open interest
GET /v4/openInterest?market=BTC-USD

Authenticated Endpoints (EIP-712 Signature Required)

# Place order
POST /v4/order
{
  "market": "BTC-USD",
  "side": "buy",
  "type": "limit",
  "price": "67400.00",
  "size": "0.1",
  "timeInForce": "GTC",
  "signature": "0x..."
}
 
# Cancel order
DELETE /v4/order?orderId=12345&signature=0x...
 
# Account positions
GET /v4/account?address=0x...&signature=0x...
 
# Order history
GET /v4/orders?address=0x...&signature=0x...

WebSocket API

Subscriptions

const ws = new WebSocket("wss://ws.gx.exchange");
 
// Subscribe to L2 orderbook
ws.send(JSON.stringify({
  method: "subscribe",
  subscription: { type: "l2Book", coin: "BTC" }
}));
 
// Subscribe to trades
ws.send(JSON.stringify({
  method: "subscribe",
  subscription: { type: "trades", coin: "BTC" }
}));
 
// Subscribe to candles
ws.send(JSON.stringify({
  method: "subscribe",
  subscription: { type: "candle", coin: "BTC", interval: "1m" }
}));
 
// Subscribe to user fills (requires auth)
ws.send(JSON.stringify({
  method: "subscribe",
  subscription: { type: "userFills", user: "0x..." }
}));

EIP-712 Order Signing

All authenticated requests require an EIP-712 typed data signature:

const domain = {
  name: "GXExchange",
  version: "1",
  chainId: 42069,
};
 
const types = {
  Order: [
    { name: "market", type: "string" },
    { name: "side", type: "string" },
    { name: "price", type: "string" },
    { name: "size", type: "string" },
    { name: "nonce", type: "uint256" },
    { name: "expiry", type: "uint256" },
  ],
};
 
const signature = await wallet._signTypedData(domain, types, order);

Rate Limits

TierRequests/MinuteWebSocket Subscriptions
Free605
Authenticated30020
GX Staker1,00050
Market Maker10,000Unlimited

Order Types

TypeDescription
limitLimit order at specified price
marketMarket order at best available price
stopLimitStop-limit trigger order
stopMarketStop-market trigger order

Time-in-Force Options

OptionDescription
GTCGood-til-cancelled
IOCImmediate-or-cancel
FOKFill-or-kill
PostOnlyPost-only (maker only, rejects if would cross)

Error Codes

CodeDescription
400Bad request — invalid parameters
401Unauthorized — invalid or missing signature
403Forbidden — rate limit exceeded
404Not found — market or order does not exist
429Too many requests — rate limited
500Internal server error