WebSocket
Real-time WebSocket for trading events
Upgrades to a WebSocket connection for streaming real-time trading events.
Authentication: pass JWT via query parameter ?token=YOUR_JWT or via Authorization header.
Optional filter: add &account_id=UUID to receive events for a single account only.
Events received:
Welcome— connection confirmed with account list (each with its markets)OrderSubmitted/OrderFilled/OrderCancelled— order lifecyclePositionUpdate— real-time P&L changes on every tickAccountUpdate— balance, equity, drawdown changesRuleViolation— trading rule breach with reasonNotification— system/copy-trade alerts
Commands you can send:
{"action": "subscribe", "account_id": "uuid"}— filter to one account{"action": "subscribe", "account_id": "*"}— receive all (default){"action": "ping"}— keep-alive
GET
/
trade
/
ws
WebSocket Client
// Connect to WebSocket
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const ws = new WebSocket(`${protocol}//${location.host}/trade/ws?token=${token}`);
ws.onopen = () => console.log('Connected');
ws.onmessage = (e) => {
const msg = JSON.parse(e.data);
switch (msg.type) {
case 'Welcome':
console.log('Accounts:', msg.accounts);
break;
case 'OrderFilled':
console.log(`Filled: ${msg.order.side} ${msg.order.quantity} @ ${msg.trade.price}`);
break;
case 'PositionUpdate':
console.log(`P&L: $${msg.position.unrealized_pnl}`);
break;
case 'RuleViolation':
alert(`⚠️ ${msg.reason}`);
break;
}
};
// Subscribe to specific account
ws.send(JSON.stringify({ action: 'subscribe', account_id: 'account-uuid' }));curl --request GET \
--url https://api.hyperprop.com/trade/wsimport requests
url = "https://api.hyperprop.com/trade/ws"
response = requests.get(url)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hyperprop.com/trade/ws",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.hyperprop.com/trade/ws"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.hyperprop.com/trade/ws")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hyperprop.com/trade/ws")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"code": "ERROR_CODE",
"data": null,
"error": "Error message describing what went wrong",
"success": false
}{
"code": "ERROR_CODE",
"data": null,
"error": "Error message describing what went wrong",
"success": false
}⌘I
WebSocket Client
// Connect to WebSocket
const protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const ws = new WebSocket(`${protocol}//${location.host}/trade/ws?token=${token}`);
ws.onopen = () => console.log('Connected');
ws.onmessage = (e) => {
const msg = JSON.parse(e.data);
switch (msg.type) {
case 'Welcome':
console.log('Accounts:', msg.accounts);
break;
case 'OrderFilled':
console.log(`Filled: ${msg.order.side} ${msg.order.quantity} @ ${msg.trade.price}`);
break;
case 'PositionUpdate':
console.log(`P&L: $${msg.position.unrealized_pnl}`);
break;
case 'RuleViolation':
alert(`⚠️ ${msg.reason}`);
break;
}
};
// Subscribe to specific account
ws.send(JSON.stringify({ action: 'subscribe', account_id: 'account-uuid' }));curl --request GET \
--url https://api.hyperprop.com/trade/wsimport requests
url = "https://api.hyperprop.com/trade/ws"
response = requests.get(url)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.hyperprop.com/trade/ws",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.hyperprop.com/trade/ws"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.hyperprop.com/trade/ws")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.hyperprop.com/trade/ws")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"code": "ERROR_CODE",
"data": null,
"error": "Error message describing what went wrong",
"success": false
}{
"code": "ERROR_CODE",
"data": null,
"error": "Error message describing what went wrong",
"success": false
}