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 options trading platform. The API enables developers to integrate Deriv's robust trading infrastructure into their applications with comprehensive endpoints.
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 powered by OAuth 2.0
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
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
- Authentication via session tokens or OTP
When to use REST vs WebSocket
| Feature | REST API | WebSocket API |
|---|---|---|
| Use Case | Account setup and management | Real-time trading and market data |
| Connection Type | Stateless HTTP requests | Persistent connection |
| Authentication | Deriv-App-ID header | Session token or OTP |
| Real-time Updates | No (request-response only) | Yes (subscriptions) |
| Examples | Create account, Get OTP, Health check | Buy contract, Stream ticks, Get balance |
Typical workflow
- REST: Create an Options account
- REST: Get OTP token for WebSocket authentication
- WebSocket: Connect using the OTP token
- WebSocket: Perform real-time trading operations
WebSocket connection
Endpoint:
1wss://ws.binaryws.com/websockets/v3Connection Requirements:
- WebSocket-capable client (browser or server-side)
- Stable internet connection
- Valid authentication credentials for protected endpoints