Overview

This guide walks through a typical frontend integration: register a user, authenticate, call a protected endpoint, and subscribe to realtime data.

Prerequisites

  • HTTP client (fetch, axios, or similar)
  • RcoinX API base URL (production or development)
  • Optional: WebSocket client for market data

Base URLs

EnvironmentREST APIWebSocket
Productionhttps://api.rcoinx.comwss://ws.poolthewool.com/ws
Developmenthttp://localhost:8080Check your local config

Step 1: Register or Log In

Register a new account:
curl -X POST https://api.rcoinx.com/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "SecurePass123!",
    "username": "trader1"
  }'
Or log in with existing credentials:
curl -X POST https://api.rcoinx.com/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "SecurePass123!"
  }'
The response includes access_token and refresh_token. Store them securely (memory or httpOnly cookies — never localStorage for production).

Step 2: Call Protected Endpoints

Attach the access token to subsequent requests:
curl https://api.rcoinx.com/api/profile \
  -H "Authorization: Bearer <access_token>"
See Authentication for token refresh and session handling.

Step 3: Handle MFA When Required

Some actions require a second factor. When MFA is needed, the API returns a challenge response. Complete verification using the flow in MFA and MFA Client Handlers.

Step 4: Connect to WebSocket

For realtime market data, open a WebSocket connection and subscribe to channels:
const ws = new WebSocket('wss://ws.poolthewool.com/ws');

ws.onopen = () => {
  ws.send(JSON.stringify({
    type: 'subscribe',
    channel: 'ticker:BTCUSDT',
    id: 1
  }));
};

ws.onmessage = (event) => {
  const message = JSON.parse(event.data);
  // handle ticker, kline, or trade updates
};
See the WebSocket Quickstart and Channels Guide for full details.

Error Handling

All API responses use a consistent envelope:
{
  "code": 400,
  "message": "Validation failed",
  "error": "email is required"
}
Handle common status codes:
CodeMeaningAction
401UnauthorizedRefresh token or redirect to login
403ForbiddenCheck permissions or MFA status
429Rate limitedBack off and retry
500Server errorRetry with exponential backoff

Next Steps

User Management

Auth, profile, MFA, and sessions

Asset & Balance

Balances and asset operations

WebSocket API

Realtime market data

Quickstart

Make your first API call