Type Notation and Conventions

This page documents the type conventions used throughout the GX Exchange API documentation.

Primitive Types

NotationDescriptionExample
intInteger number, transmitted as a JSON number42
floatFloating-point number, transmitted as a JSON number3.14
stringUTF-8 string"BTC"
boolBoolean valuetrue
address42-character hex-encoded Ethereum address with 0x prefix"0x1234...abcd"
hexHex-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

NotationDescriptionExample
Array<T>Ordered list of type T[1, 2, 3]
T?Optional field (may be absent or null)"c": "0x1a2b" or absent
ObjectA 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

ContextTypeDescription
Perpetual marketsintZero-based index from the meta endpoint universe array
Spot marketsintIndex from the spotMeta endpoint; spot indices begin at 10000
Human-readablestringCoin 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:

FieldBuySell
b (exchange endpoint)truefalse
side (info/fills)"B""A"

The "A" and "B" convention maps to Ask (sell) and Bid (buy).

Time-in-Force Values

ValueNameDescription
"Gtc"Good-til-cancelledRests on the book until filled or cancelled
"Ioc"Immediate-or-cancelFills what is available immediately, cancels the remainder
"Alo"Add-liquidity-onlyPost-only order; rejected if it would cross the spread

Order Grouping

ValueDescription
"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 to null.
  • Required fields are always present in responses.
  • Do not send null for required fields in requests; the server will reject the request with a 400 error.

String Number Precision

Field TypeMax Significant FiguresExample ValidExample Invalid
Price (p, px, limitPx)5"67432""67432.123"
Size (s, sz)Governed by szDecimals"0.00100""0.000001" (if szDecimals=5)
Dollar amounts8"12500.00"