Skip to content
Trade

API overview

HTTP and WebSocket interface for the Nexus chain. Sessions are signed by your MAIN wallet directly, or — for programmatic trading — by an API key (a delegate signing key derived from your wallet via a one-time signature). No Bearer tokens, no shared secrets, no HMAC. The same interface powers the web UI, programmatic trading bots, indexers, and admin tooling.

Base URL: https://api.bitnxs.com · WebSocket: wss://api.bitnxs.com/ws

  1. Connect your wallet (MetaMask or any EIP-1193 provider) in the web UI to derive your on-chain address (0xABC).
  2. Open the “More → API Keys” page and create an API key for programmatic trading. Copy the value shown in the one-time modal.
  3. Open a session: POST /session/start → sign the returned challenge with the API key → POST /session/complete → receive a sessionId.
  4. Submit orders, cancels, leverage updates and TP/SL triggers using the sessionId.
import requests
from eth_account import Account
from eth_utils import keccak
USER = "0xABC..." # MAIN wallet address — the session is bound to this
API_KEY = "0x..." # API key from "More → API Keys" (shown once)
BASE = "https://api.bitnxs.com" # Nexus API base URL
# 1. Open session
chal = requests.post(f"{BASE}/session/start", json={"user": USER}).json()
# 2. Sign challenge with the API key (raw keccak, NOT EIP-191 / personal_sign)
sig = Account.unsafe_sign_hash(
keccak(chal["challenge"].encode()),
private_key=API_KEY,
)
ses = requests.post(f"{BASE}/session/complete", json={
"challengeId": chal["challengeId"],
"signature": {"r": hex(sig.r), "s": hex(sig.s), "v": sig.v - 27},
}).json()
SESSION_ID = ses["sessionId"]
# 3. Submit a limit order
print(requests.post(f"{BASE}/session/order", json={
"sessionId": SESSION_ID,
"asset": 1,
"isBuy": True,
"limitPx": "65000.00",
"sz": "0.01",
"reduceOnly": False,
"orderType": {"type": "limit", "tif": "Gtc"},
}).json())