Get started
Authentication
Market data is open to everyone. Everything on your account takes a signed request, so every call proves it came from you and nobody can replay it.
Create a key#
- 1Log in and open Account → API and connections. A personal account holds one key, a company account up to ten.
- 2Name the key and choose what it may do: Read to see everything on the account, Trade to place orders, convert, move money between sub-accounts and run Earn, recurring buys and leveraged positions as well.
- 3Add the IP addresses your servers call from. Requests from anywhere else are refused, even with the right signature.
- 4Confirm with the code we email you and copy the secret. We show it once and store it encrypted, never in clear.
No API key can withdraw, pay by card or change an address, a password or a key. Money only leaves Reirex from the site, signed in as you, so a leaked key can never empty an account.
Sign a request#
Send three headers with every private request:
| Header | Value |
|---|---|
GX-API-KEY | Your key |
GX-API-TIMESTAMP | The time of the request, in Unix milliseconds |
GX-API-SIGN | The request's signature |
The signature is an HMAC-SHA256 of four parts joined together: the timestamp, the method in capitals, the path with its query string, and the body exactly as sent (nothing for a request without one). Your secret is the key, and the result goes out in Base64.
GX-API-SIGN = Base64( HMAC-SHA256( secret, timestamp + method + path + body ) )
timestamp 1791994457757
method POST
path /api/v1/orders
body {"pair":"BTC-EUR","side":"buy","type":"limit","amount":"0.05","price":"70000"}The helper below signs and sends any request. The examples on the endpoint pages call it as signed().
import base64, hashlib, hmac, json, time
import requests
API_KEY = "your-api-key"
API_SECRET = "your-api-secret"
BASE = "https://reirex.com/api/v1"
def signed(method, path, body=None):
timestamp = str(int(time.time() * 1000))
payload = json.dumps(body, separators=(",", ":")) if body else ""
message = timestamp + method + "/api/v1" + path + payload
digest = hmac.new(API_SECRET.encode(), message.encode(), hashlib.sha256).digest()
headers = {
"GX-API-KEY": API_KEY,
"GX-API-TIMESTAMP": timestamp,
"GX-API-SIGN": base64.b64encode(digest).decode(),
"Content-Type": "application/json",
}
response = requests.request(method, BASE + path, headers=headers, data=payload or None)
return response.json()
print(signed("GET", "/account/balances"))Timestamps#
A timestamp more than 5 seconds from our clock is refused with expired_timestamp. That window is what stops a captured request being replayed later. Keep your servers in sync with NTP, or read our time from the Date header of any response.
Sub-account keys#
A company can give each sub-account keys of its own. Such a key works inside its sub-account alone, on its balances, orders, ledger, Earn, recurring buys and positions, with the company's verification and restrictions. It never reaches another sub-account, and what belongs to the main account (deposit addresses, the sub-accounts and the transfers between them, the watchlist and alerts) answers main_account_only.
When signing fails#
| Status | Error | What happened |
|---|---|---|
| 401 | missing_signature | One of the three headers is missing. |
| 401 | invalid_signature | The signature doesn't match. Check that you sign the path with /api/v1 and the body byte for byte. |
| 401 | expired_timestamp | The timestamp is more than 5 seconds off. |
| 403 | permission_denied | The key lacks the permission, the request came from an address not on its list, or the account is frozen or closed. |

