Getting Started
Connect to the WebSocket server for real-time market data streaming.
Listening assets
1
Step 1: Connect
wscat -c "wss://apollo-hml.penzack.com/ws"
On connection you will receive the following message:
{
"type": "handshake",
"data": {
"message": "Connected successfully! Your clientId is <CLIENT_ID>"
}
}
2
Step 2: Subscribe
Once authenticated, you can request a stream.
{
"action": "subscribe",
"topic": "BTC-USD"
}
You can also request a stream from multiple assets by separating them with a comma.
{
"action": "subscribe",
"topic": "AUD/CAD,AAPL,BTC-USD"
}
Once subscribed, you will receive the following message:
{
"type": "auth",
"data": "Successfully subscribed to topic \"BTC-USD\""
}
3
Step 3: Consume
We send two types of events: the aggregated data from the current second and the most recent ticker we have. This data can come in the following formats:
Quote (Ticker) event
{
"type": "quote",
"data": {
"sym": "BTC-USD",
"price": 50123.45,
"timestamp": 1623456789
},
}
Aggregated event
⚠️ Warning:
Aggregate event can be unstable
{
"type": "aggregate",
"data": {
"sym": "BTC-USD",
"open_price": 49500.00,
"close_price": 50200.00,
"highest_price": 50300.00,
"lowest_price": 49400.00,
"volume": 1234567.89,
"start_timestamp": 1623450000,
"end_timestamp": 1623459999,
"avg_trade_size": 5,
"avg_volume_weight_price": 50100.50
},
}
4
Step 4: Unsubscribe
You can also unsubscribe for one or multiple assets.
{
"action": "unsubscribe",
"topic": "BTC-USD"
}
{
"action": "unsubscribe",
"topic": "XRP-USD,AAPL"
}