API Overview
Understanding the Deriv API ecosystem and its core capabilities.
Introduction
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.
Key features
- Options account creation and management (REST)
- Real-time market data streaming (WebSocket)
- Contract trading (buy, sell, update) (WebSocket)
- Portfolio and account monitoring (WebSocket)
- Historical data access (WebSocket)
- Subscription-based real-time updates (WebSocket)
- Secured access via OAuth 2.0 or Personal Access Token (PAT)
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-IDheader +Authorization: Bearertoken (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
Typical workflow
- REST: Get an authenticated WebSocket URL via the OTP endpoint (requires your Bearer token)
- WebSocket: Connect using the authenticated URL returned in the OTP response
- WebSocket: Perform real-time trading operations
Note: Users receive a default demo account upon signup — you do not need to create one via the API before trading.
API Endpoints
REST base URL:
1https://api.derivws.comWebSocket 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_OTPThe 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-IDand Bearer token for REST calls and OTP generation
Download API schemas
All API schemas are published with every production release as schemas.zip. The archive contains all WebSocket JSON Schema files and the REST API OpenAPI 3.1.0 spec — ready for offline use, SDK generators, or client tooling.
https://github.com/deriv-com/deriv-api-schemas/releases/latest/download/schemas.zip
Need a specific version? Each release has a versioned URL in the format …/releases/download/{tag}/schemas.zip. Browse all releases at github.com/deriv-com/deriv-api-schemas/releases.
Next steps
Continue with these guides to start building with the Deriv API:
Authentication
Compare OAuth 2.0 and PAT authentication methods and choose the right one for your use case.
OAuth 2.0
Step-by-step guide to the OAuth 2.0 Authorization Code flow with PKCE.
Complete Workflows
End-to-end examples combining REST and WebSocket APIs for common trading scenarios.
Options REST API
Full reference for all REST endpoints: accounts, OTP, WebSocket setup, and more.
Any other questions? Get in touch