Reya DEX Websocket API V2
Table of Contents
Overview
The Reya DEX Trading WebSocket API v2 provides real-time streaming data for decentralized exchange operations on the Reya Network. This version offers user-friendly data structures with human-readable formats, removing blockchain-specific details while maintaining comprehensive trading functionality.
Key Features
Real-time Updates: Live streaming of market data, positions, orders, and executions
User-Friendly Format: Simplified data structures without blockchain complexity
Comprehensive Coverage: Market summaries, wallet positions, order management, and price feeds
Standardized Protocol: AsyncAPI 2.6.0 compliant specification
Alphanumeric Symbol Support: Supports symbols like
BTCRUSDPERP,kBONKRUSDPERP,AI16ZRUSDPERP
Server Endpoints
Production Environment
URL:
wss://ws.reya.xyzProtocol: WSS
Description: Production WebSocket server for live trading
Test Environment
URL:
wss://websocket-testnet.reya.xyzProtocol: WSS
Description: Staging WebSocket server for testing and development
Channel Architecture
The API uses a hierarchical channel structure with clear separation between different data types:
Channel Categories
Market Data Channels
/v2/markets/summary- All market summaries/v2/market/{symbol}/summary- Individual market summary/v2/market/{symbol}/perpExecutions- Market-specific executions/v2/prices- All symbol prices/v2/prices/{symbol}- Individual symbol prices
Wallet Data Channels
/v2/wallet/{address}/positions- Position updates/v2/wallet/{address}/orderChanges- Order change updates/v2/wallet/{address}/perpExecutions- Wallet-specific executions
Parameter Validation
Symbol Parameter
Pattern:
^[A-Za-z0-9]+$Examples:
BTCRUSDPERP,ETHRUSD,kBONKRUSDPERP,AI16ZRUSDPERPDescription: Trading symbol supporting alphanumeric characters
Address Parameter
Pattern:
^0x[a-fA-F0-9]{40}$Example:
0x6c51275fd01d5dbd2da194e92f920f8598306df2Description: Ethereum wallet address (40 hexadecimal characters)
Message Structure
All WebSocket messages follow a standardized envelope structure:
Base Message Envelope
Message Components
type: Always
"channel_data"for data updatestimestamp: Server timestamp in milliseconds
channel: Specific channel identifier
data: Channel-specific payload (object or array)
Heartbeat Messages
Ping Message (Server → Client)
Pong Message (Client → Server)
Channels Reference
1. Market Data Channels
/v2/markets/summary
/v2/markets/summaryPurpose: Real-time updates for all market summaries
Subscription:
Message Structure:
Data Type - MarketSummary
symbol(string): Trading symbolupdatedAt(integer): Last calculation timestamp (milliseconds)longOiQty(string): Long open interest in lotsshortOiQty(string): Short open interest in lotsoiQty(string): Total open interest quantityfundingRate(string): Current hourly funding ratelongFundingValue(string): Current long funding valueshortFundingValue(string): Current short funding valuefundingRateVelocity(string): Funding rate velocityvolume24h(string): 24-hour trading volumepxChange24h(string, optional): 24-hour price changethrottledOraclePrice(string, optional): Last oracle price at summary updatethrottledPoolPrice(string, optional): Last pool price at summary updatepricesUpdatedAt(integer, optional): Last price update timestamp
/v2/market/{symbol}/summary
/v2/market/{symbol}/summaryPurpose: Real-time updates for a specific market's summary
Parameters:
symbol: Trading symbol (e.g.,BTCRUSDPERP,kBONKRUSDPERP)
Subscription:
Message Structure:
Data Type - MarketSummary
Same as above - see /v2/markets/summary channel for complete field definitions.
/v2/market/{symbol}/perpExecutions
/v2/market/{symbol}/perpExecutionsPurpose: Real-time perpetual executions for a specific market
Parameters:
symbol: Trading symbol (e.g.,BTCRUSDPERP,AI16ZRUSDPERP)
Subscription:
Message Structure:
Data Type - PerpExecution
exchangeId(integer): Exchange identifiersymbol(string): Trading symbolaccountId(integer): Account identifierqty(string): Execution quantityside(Side): Execution side (B=Buy, A=Sell)fee(string): Execution feeprice(string): Execution pricetype(ExecutionType): Execution type (ORDER_MATCH, LIQUIDATION, ADL)timestamp(integer): Execution timestamp (milliseconds)sequenceNumber(integer): Global sequence number
/v2/prices
/v2/pricesPurpose: Real-time price updates for all symbols
Subscription:
Message Structure:
Data Type - Price
symbol(string): Trading symbolupdatedAt(integer): Last update timestamp (milliseconds)oraclePrice(string, optional): Oracle/spot pricepoolPrice(string, optional): Pool price
/v2/prices/{symbol}
/v2/prices/{symbol}Purpose: Real-time price updates for a specific symbol
Parameters:
symbol: Trading symbol (e.g.,BTCRUSDPERP,kBONKRUSDPERP)
Subscription:
Message Structure:
2. Wallet Data Channels
/v2/wallet/{address}/positions
/v2/wallet/{address}/positionsPurpose: Real-time position updates for a wallet
Parameters:
address: Ethereum wallet address (e.g.,0x6c51275fd01d5dbd2da194e92f920f8598306df2)
Subscription:
Message Structure:
Data Type - Position
exchangeId(integer): Exchange identifiersymbol(string): Trading symbolaccountId(integer): Account identifierqty(string): Position quantityside(Side): Position side (B=Buy, A=Sell)avgEntryPrice(string): Average entry priceavgEntryFundingValue(string): Average entry funding valuelastTradeSequenceNumber(integer): Last execution sequence number
/v2/wallet/{address}/orderChanges
/v2/wallet/{address}/orderChangesPurpose: Real-time order change updates for wallet
Parameters:
address: Ethereum wallet address
Subscription:
Message Structure:
Data Type - Order
exchangeId(integer): Exchange identifiersymbol(string): Trading symbolaccountId(integer): Account identifierside(Side): Order side (B=Buy, A=Sell)limitPx(string): Limit priceorderType(OrderType): Order type (LIMIT, TP, SL)status(OrderStatus): Order status (OPEN, FILLED, CANCELLED, REJECTED)createdAt(integer): Creation timestamp (milliseconds)lastUpdateAt(integer): Last update timestamp (milliseconds)orderId(string, optional): Order identifierqty(string, optional): Order quantityexecQty(string, optional): Executed quantitytriggerPx(string, optional): Trigger price for TP/SL orderstimeInForce(TimeInForce, optional): Time in force (IOC, GTC)reduceOnly(boolean, optional): Reduce-only flag
/v2/wallet/{address}/perpExecutions
/v2/wallet/{address}/perpExecutionsPurpose: Real-time perpetual execution updates for a wallet
Parameters:
address: Ethereum wallet address
Subscription:
Message Structure:
Data Type - PerpExecution
Same as above - see /v2/market/{symbol}/perpExecutions channel for complete field definitions.
Data Types & Schemas
Enumeration Types
ExecutionType - Type of execution that occurred
ORDER_MATCH: Regular order matchingLIQUIDATION: Liquidation executionADL: Auto-deleveraging execution
OrderStatus - Current status of an order
OPEN: Order is active and can be filledFILLED: Order has been completely filledCANCELLED: Order has been cancelledREJECTED: Order was rejected
Heartbeat Management
The API implements a ping/pong heartbeat mechanism:
Server Ping: Server sends periodic ping messages
Client Pong: Client must respond with pong messages
Connection Health: Failure to respond may result in disconnection
Connection Best Practices
Implement Reconnection Logic: Handle connection drops gracefully
Manage Subscriptions: Track active subscriptions for reconnection
Handle Backpressure: Process messages efficiently to avoid buffer overflow
Monitor Latency: Track message timestamps for performance monitoring
Validate Messages: Verify message structure and required fields