Deriv API
K

API Overview

Understanding the Deriv API ecosystem and its core capabilities.

Deriv API provides programmatic access to trading services, account management, and market data for the Options trading platform. The API enables developers to integrate Deriv's robust trading infrastructure into their applications using REST endpoints for account setup and WebSocket connections for real-time trading.

API architecture

The Deriv API consists of two complementary components designed to work together seamlessly:

REST APIs
  • Account creation and management
  • OTP generation for WebSocket authentication
  • System health monitoring
  • Standard HTTP methods (GET, POST)
  • Stateless requests
  • Authentication via Deriv-App-ID header + Authorization: Bearer token (OAuth 2.0 or PAT)
WebSocket APIs
  • Real-time trading operations (buy, sell, proposals)
  • Live market data streaming (ticks, symbols)
  • Account data subscriptions (balance, portfolio)
  • Persistent bidirectional connection
  • Real-time push notifications
  • Three endpoint types: public (no auth), demo, and real (both authenticated via OTP)

When to use REST vs WebSocket

FeatureREST APIWebSocket API
Use CaseAccount setup and managementReal-time trading and market data
Connection TypeStateless HTTP requestsPersistent connection
AuthenticationDeriv-App-ID header + Bearer token (OAuth 2.0 or PAT)OTP-based (obtained via REST API); public endpoint requires no auth
Real-time UpdatesNo (request-response only)Yes (subscriptions)
ExamplesPOST /trading/v1/options/accounts, POST .../{accountId}/otp, GET /v1/healthBuy contract, stream ticks, get balance

API endpoints

REST base URL:

1https://api.derivws.com

WebSocket endpoints:

1# Public (no authentication required)
2wss://api.derivws.com/trading/v1/options/ws/public
3
4# Demo account (authenticated via OTP)
5wss://api.derivws.com/trading/v1/options/ws/demo?otp=YOUR_OTP
6
7# Real account (authenticated via OTP)
8wss://api.derivws.com/trading/v1/options/ws/real?otp=YOUR_OTP

The OTP is obtained by calling POST /trading/v1/options/accounts/{accountId}/otp — the response contains a ready-to-use WebSocket URL with the OTP already embedded.

Connection requirements:

  • WebSocket-capable client (browser or server-side)
  • Stable internet connection
  • Valid Deriv-App-ID and Bearer token for REST calls and OTP generation

Next steps

Continue with these guides to start building with the Deriv API:

Click to open live chat support. Get instant help from our support team.