Type Notation and Conventions
This page documents the type conventions used throughout the GX Exchange API documentation.
Primitive Types
| Notation | Description | Example |
|---|---|---|
int | Integer number, transmitted as a JSON number | 42 |
float | Floating-point number, transmitted as a JSON number | 3.14 |
string | UTF-8 string | "BTC" |
bool | Boolean value | true |
address | 42-character hex-encoded Ethereum address with 0x prefix | "0x1234...abcd" |
hex | Hex-encoded byte string with 0x prefix | "0xdeadbeef" |
Numeric Strings
Prices, sizes, and monetary amounts are transmitted as strings to avoid floating-point precision loss. All arithmetic should be performed using fixed-point or decimal libraries.
{
"p": "67432.5",
"s": "0.001",
"withdrawable": "12500.00"
}Important: Never parse price or size fields as native floating-point numbers. Use
BigNumber,Decimal, or equivalent in your language.
Composite Types
| Notation | Description | Example |
|---|---|---|
Array<T> | Ordered list of type T | [1, 2, 3] |
T? | Optional field (may be absent or null) | "c": "0x1a2b" or absent |
Object | A JSON object with documented fields | { "px": "100", "sz": "1.5" } |
Map<K, V> | Object used as a key-value map | { "BTC": "67432.5" } |
[T, T] | Fixed-length tuple | [10000, 10001] |
Asset Identifiers
| Context | Type | Description |
|---|---|---|
| Perpetual markets | int | Zero-based index from the meta endpoint universe array |
| Spot markets | int | Index from the spotMeta endpoint; spot indices begin at 10000 |
| Human-readable | string | Coin symbol such as "BTC", "ETH", or pair name "BTC-USDC" |
See Asset IDs for the complete mapping.
Order Side Encoding
The API uses compact encodings for order sides:
| Field | Buy | Sell |
|---|---|---|
b (exchange endpoint) | true | false |
side (info/fills) | "B" | "A" |
The "A" and "B" convention maps to Ask (sell) and Bid (buy).
Time-in-Force Values
| Value | Name | Description |
|---|---|---|
"Gtc" | Good-til-cancelled | Rests on the book until filled or cancelled |
"Ioc" | Immediate-or-cancel | Fills what is available immediately, cancels the remainder |
"Alo" | Add-liquidity-only | Post-only order; rejected if it would cross the spread |
Order Grouping
| Value | Description |
|---|---|
"na" | No grouping. Each order is independent. |
"normalTpsl" | Take-profit / stop-loss group. Orders are linked. |
"positionTpsl" | Position-level TP/SL. Attached to the entire position. |
Timestamps
All timestamps in the API are Unix epoch in milliseconds unless otherwise noted:
{
"time": 1700000000000,
"nonce": 1700000000123,
"startTime": 1700000000000,
"endTime": 1700100000000
}The one exception is the GX-API-TIMESTAMP header used for HMAC authentication, which uses seconds.
Pagination
Endpoints that return lists of historical data accept startTime and endTime parameters (milliseconds). Results are sorted by time in ascending order by default.
Null vs Absent
- A field documented as optional (
T?) may be omitted entirely from the JSON object or set tonull. - Required fields are always present in responses.
- Do not send
nullfor required fields in requests; the server will reject the request with a 400 error.
String Number Precision
| Field Type | Max Significant Figures | Example Valid | Example Invalid |
|---|---|---|---|
Price (p, px, limitPx) | 5 | "67432" | "67432.123" |
Size (s, sz) | Governed by szDecimals | "0.00100" | "0.000001" (if szDecimals=5) |
| Dollar amounts | 8 | "12500.00" | — |