Here is the sample subscription message for get_actions endpoint:
{
"apikey":"test-api-key",
"event":"subscribe",
"type":"get_actions",
"data": {
"account":"eostribeprod",
“actions":[“transfer”,”buyram”]
}
}
Request message format for get_blocks endpoint:
{
"apikey":"test-api-key",
"event":"subscribe",
"type":"get_blocks"
}
Below is the sample subscription message for get_transaction endpoint:
{
"apikey":"test-api-key",
"event":"subscribe",
"type":"get_transaction",
"data": {"account":"eosio"}
}
<html>
<head><title>Spectrum Web Sockets</title>
<script>
let socket = new WebSocket("wss://api.telos.eostribe.io/streaming");
# pick one of declarations:
# 1. get_actions:
var messageBody = {
"apikey":"test-api-key",
"event":"subscribe",
"type":"get_actions",
"data": {"account":"eosio"}
};
#2. get_blocks:
var messageBody = {
"apikey":"test-api-key",
"event":"subscribe",
"type":"get_blocks"
};
#3. get_transaction:
var messageBody ={
"apikey":"test-api-key",
"event":"subscribe",
"type":"get_transaction",
"data": {"account":"eosio"}
};
socket.onopen = function(e) {
console.log("[open] Connection established");
console.log("Sending to server: "+JSON.stringify(messageBody));
socket.send(JSON.stringify(messageBody));
};
socket.onmessage = function(event) {
html_log("[message] Data received from server: "+event.data);
};
socket.onclose = function(event) {
if (event.wasClean) {
html_log("[close] Connection closed cleanly, code=${event.code} reason=${event.reason}");
} else {
html_log("[close] Connection died");
}
};
socket.onerror = function(error) {
html_log("[error] ${error.message}");
};
function html_log(data) {
var divLog = document.getElementById("log");
divLog.innerHTML += ""
+data+"";
}
</script>
</head>
<body>
<h2>Spectrum Web Sockets Test: Get Actions</h2>
<div id="log"></div>
</body></html>