Welcome to the NYXANCE API documentation. Our REST API provides programmatic access to market data, trading, and account management for crypto perpetual futures.
Quick Reference
Base URLhttps://api.nyxance.com
ProtocolHTTPS (TLS 1.2+)
Content Typeapplication/json
TimestampsMilliseconds (Unix epoch)
PrecisionPrices and sizes are strings in JSON responses
WebSocketwss://api.nyxance.com/ws
Rate Limits
Public API60 requests / minute per IP
Auth API10 requests / minute per IP
Trading API30 requests / minute per user
Rate limit headers are included in all responses: X-RateLimit-Limit, X-RateLimit-Remaining, Retry-After
Authentication
NYXANCE uses JWT (JSON Web Tokens) for authentication. Obtain a token via the Register or Login endpoints, then include it in the Authorization header for all authenticated requests.
Steps
Create account: POST /api/v1/register
Or log in: POST /api/v1/login
Include token in header: Authorization: Bearer <token>
Security Note: If 2FA is enabled on your account, you must provide a valid TOTP code in the totp_code field when logging in. Account locks after 5 failed login attempts for 15 minutes.
Public API
Market data endpoints. No authentication required. Rate limit: 60 req/min per IP.
Auth Endpoints
Registration and login. Rate limit: 10 req/min per IP (stricter to prevent brute force).
Trading API
Order and position management. Requires JWT authentication. Rate limit: 30 req/min per user.
Account API
2FA, notification settings, and referral system. Requires JWT authentication.
WebSocket API
Connection
Connect to the WebSocket endpoint to receive real-time market data. No authentication is required. The server automatically pushes ticker and orderbook updates for all trading pairs.
javascript
// WebSocket endpoint
wss://api.nyxance.com/ws
// JavaScript example
const ws = new WebSocket('wss://api.nyxance.com/ws');
ws.onopen = () => {
console.log('Connected to NYXANCE WebSocket');
// Subscribe to a specific trading pair
ws.send(JSON.stringify({ subscribe: 'BTC-USDT' }));
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log(data.type, data);
};
ws.onclose = () => {
console.log('Disconnected');
};
Subscribe / Unsubscribe
Send JSON messages to subscribe or unsubscribe from specific trading pairs.
json
// Subscribe to a pair
{ "subscribe": "BTC-USDT" }
// Unsubscribe from a pair
{ "unsubscribe": "BTC-USDT" }
Ticker Stream
Pushes real-time ticker updates for all subscribed trading pairs. Updates are sent whenever the price changes (typically every 100-500ms).
Pushes real-time order book snapshots for subscribed pairs. Asks are sorted ascending by price, bids are sorted descending by price. Each level includes price and quantity.
POST /order/*, DELETE /order/*, GET /positions, etc.
Status
Unlimited
-
GET /status
When you exceed the rate limit, the API returns HTTP 429 Too Many Requests. The Retry-After header indicates how many seconds to wait before retrying.
http
HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
Retry-After: 45
{ "error": "rate limit exceeded" }
Error Codes
All errors return a JSON object with an error field describing the issue.
HTTP Code
Meaning
Example
400
Bad Request
Invalid parameters, missing required fields
401
Unauthorized
Missing or expired JWT token
403
Forbidden
Account locked, insufficient permissions
404
Not Found
Endpoint or resource does not exist
409
Conflict
Duplicate registration, order already cancelled
422
Unprocessable
Insufficient balance, max leverage exceeded
429
Rate Limited
Too many requests, check Retry-After header
500
Server Error
Internal error, contact support
json
// Error response format
{
"error": "insufficient balance"
}
// With details
{
"error": "validation failed",
"details": "size must be between 1 and 1000000"
}