Flex Exchange API Documentation

Base URL: https://api.flexex.io/v1/

Two families of endpoints exist: Public (no auth) and Private (signed requests required).

All endpoints return a response envelope: {'code': 0, 'error': [], 'result': <payload>}. code = 0 means success and result will be non-null; otherwise error is a list of messages.

GETPOSTAuth: Ed25519

To create or manage API keys, go to /apimanagement. Keep your private key secure—it’s used to sign requests.

Authentication (Private endpoints)

Send these headers with every private request (required):

  • X-API-Key — your public API key
  • X-API-Algoed25519
  • X-API-Timestamp — UNIX nanoseconds (must be recent; typically ±10s window)
  • X-API-Signature — lowercase hex of Ed25519 signature over the message below

Message to sign (exact bytes):

METHOD + "
" + RELATIVE_URL + "
" + HEX( SHA3-256( SHA3-256( BODY_BYTES ) ) ) + "
" + TIMESTAMP_NS + "
" + API_KEY
  • RELATIVE_URL includes query string, e.g. /v1/trades?market=BNB_USDT&limit=50.
  • BODY_BYTES is exactly what you send on POST (empty for GET).
  • For JSON bodies, hash the exact serialized bytes you transmit (use a stable serializer).

Error format

{
  "code": -1,
  "error": ["Bad request"],
  "result": null
}

Success format

{
  "code": 0,
  "error": [],
  "result": { /* endpoint-specific */ }
}

Public Endpoints

No authentication required.

GETPOST/assets

Enumerates all supported assets (tickers/networks you can trade, deposit and withdraw). Useful for populating dropdowns and validating user inputs.

Parameters:none
GETPOST/markets

Lists all available trading pairs (markets). Use this to build market selectors and to validate market symbols.

Parameters:none
GETPOST/trades

Returns recent trades for the specified market. Supports pagination via offset/limit. Handy for a trade ticker/tape.

Parameters:{ market, offset?, limit? }
GETPOST/orderbook

Returns the current aggregated order book snapshot for a market. Use to render depth and price ladders.

Parameters:{ market }
Example: fetch /trades?market=BNB_USDT&limit=3
curl -sS "https://api.flexex.io/v1/trades?market=BNB_USDT&limit=3"

Private Endpoints

Signed requests required.

GETPOSTauth/account

Returns account metadata tied to your API key (read-only).

Parameters:none
GETPOSTauth/deposit_address

Generates or returns your deposit address for a given ticker. The first request may return null while the address is being generated — poll until available.

Parameters:{ network }
GETPOSTauth/balances

Returns your balances by asset (e.g., available vs. locked).

Parameters:none
GETPOSTauth/active_orders

Lists your currently open orders. Paginate with offset and limit.

Parameters:{ offset?, limit? }
GETPOSTauth/history_orders

Lists your past orders (filled/cancelled/expired). Paginate with offset and limit.

Parameters:{ offset?, limit? }
GETPOSTauth/user_trades

Lists your executed trades for a given market. Paginate with offset/limit.

Parameters:{ market, offset?, limit? }
GETPOSTauth/create_order

Places a new order. For type=limit provide price; for type=market price is ignored.

Parameters:{ market, side, type, amount, price? }
GETPOSTauth/cancel_order

Cancels an order by id (only open orders can be cancelled).

Parameters:{ id }
Example: POST /create_order
# pip install cryptography requests pysha3
from time import time_ns
from hashlib import sha3_256
from binascii import unhexlify, hexlify
from json import dumps
import requests
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey

BASE = 'https://api.flexex.io'
API_KEY = 'YOUR_API_KEY'
API_SECRET_HEX = 'YOUR_32BYTE_SECRET_HEX'  # 64 hex chars

def dbl_sha3_hex(b: bytes) -> str:
    return sha3_256(sha3_256(b).digest()).hexdigest()

def sign(method: str, relurl: str, body: bytes, ts_ns: int) -> str:
    msg = f"{method}
{relurl}
{dbl_sha3_hex(body)}
{ts_ns}
{API_KEY}".encode()
    sk = Ed25519PrivateKey.from_private_bytes(unhexlify(API_SECRET_HEX))
    sig = sk.sign(msg)
    return hexlify(sig).decode()

# Example: create a LIMIT sell order
method = 'POST'
rel = '/v1/create_order'
payload = { 'market':'BNB_USDT','side':'sell','type':'limit','amount':'100','price':'1' }
# Stable JSON: separators without spaces + sorted keys recommended
body = dumps(payload, separators=(',',':'), sort_keys=True).encode()
ts = time_ns()
headers = {
    'X-API-Key': API_KEY,
    'X-API-Algo': 'ed25519',
    'X-API-Timestamp': str(ts),
    'X-API-Signature': sign(method, rel, body, ts),
}
res = requests.post(BASE+rel, data=body, headers=headers, timeout=10)
print(res.status_code, res.text)

Order payloads

Create order (/create_order):

{
  "market": "BNB_USDT",
  "side": "sell", // "buy"|"sell"
  "type": "limit", // "limit"|"market"
  "amount": "100",
  "price": "1"       // required for limit; ignored for market
}

Cancel order (/cancel_order): { "id": "..." }