Skip to main content

Authentication Flow

Authentication happens in two steps: connection-level authentication via query parameter and session-level authentication via WebSocket message.

Connection Authentication

Connect to the secure WebSocket endpoint without API key in URL:
Security Enhancement: API keys are no longer exposed in URLs for better security.

Session Authentication

After connecting, send an authentication message to establish your session: Request:
Success Response:

Authentication Errors

Invalid API Key

API Key Not Found

Account Suspended

User Tiers

Different tiers provide different access levels:

Session Management

Session State

After authentication, your session maintains:
  • User ID - Unique identifier for your account
  • Tier Information - Your current subscription tier
  • Usage Statistics - Real-time data consumption tracking
  • Active Subscriptions - Currently subscribed trading pairs
  • Connection Metadata - Connection time, IP, etc.

Session Persistence

Sessions are maintained as long as:
  • WebSocket connection remains active
  • API key remains valid
  • Account remains in good standing
  • Data limits are not exceeded

Multiple Connections

You can maintain multiple WebSocket connections up to your tier limit:
  • Each connection requires separate authentication
  • Data usage is shared across all connections
  • Rate limits apply per API key, not per connection

Security Best Practices

API Key Security

  • Never expose API keys in client-side code
  • Use environment variables for key storage
  • Rotate keys regularly
  • Monitor for unauthorized usage

Connection Security

  • Use secure WebSocket connections (WSS) in production
  • Implement proper error handling
  • Log authentication events
  • Monitor for suspicious activity

Code Examples

Python Authentication

JavaScript Authentication

Always handle authentication errors gracefully and implement retry logic with exponential backoff for temporary failures.