__________     __ __     __  _______    ________
  / ____/ __ \   / // /    / / / /  _/ |  / / ____/
 / / __/ / / /  / // /_   / /_/ // / | | / / __/
/ /_/ / /_/ /  /__  __/  / __  // /  | |/ / /___
\____/\____/     /_/    /_/ /_/___/  |___/_____/

 --- A GOPHER-LIKE INTERFACE FOR HIVE BLOCKCHAIN ---

Spectrum API running on Telos Mainnet

BY: @eostribe | CREATED: Oct. 24, 2019, 3:36 p.m. | VOTES: 2 | PAYOUT: $0.00 | [ VOTE ]

[IMAGE: https://cdn.steemitimages.com/DQmYjiC4VYNHRm6tRcaNiSr6Hzx3ZUJdMgzSBGv1sgSRyaf/spectrum.jpeg]

EOS Tribe launched a beta version of it's web-socket streaming Spectrum API on Telos Mainnet (https://www.telosfoundation.io/).

Telos Mainnet Spectrum API web-socket endpoint: wss://api.telos.eostribe.io

This version currently supports subscriptions for get_actions, get_transaction and get_blocks streams.

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”]
   }
}

Fields description for get_actions:

Endpoint get_blocks - subscribe on new block events:

Request message format for get_blocks endpoint:

{
  "apikey":"test-api-key",
  "event":"subscribe",
  "type":"get_blocks"
}

Fields description:

Below is the sample subscription message for get_transaction endpoint:

{
  "apikey":"test-api-key",
  "event":"subscribe",
  "type":"get_transaction",
  "data": {"account":"eosio"}
}

Fields description for get_transaction:

Sample JS web-socket client to subscribe for events:


Spectrum Web Sockets

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+"";
}





Spectrum Web Sockets Test: Get Actions



Feel free to give it a try and provide your feedback at out Telegram channel: https://t.me/EOSTribe

Original post describing Spectrum API architecture: https://steemit.com/eosio/@eostribe/introducing-spectrum-streaming-api-for-eosio

EOS Tribe is committed to continue work on creating innovative solutions for EOSIO.

TAGS: [ #spectrum ] [ #api ] [ #telos ] [ #mainnet ]

Replies

@bodget | Oct. 24, 2019, 4:20 p.m. | Votes: 0 | [ VOTE ]

Wow looks awesome you guys, looking forward to trying this out. Generally we found that with more traditional methods we got problems processing data for accounts having more than 2 million transactions like eosio.bpay or eosio.trail so this will no doubt breeze through those, will let you know!
Cheers
Rog

@concorde | Oct. 26, 2019, 7 p.m. | Votes: 0 | [ VOTE ]

Yeah, needed this. Nice job.

[ BACK TO TRENDING ] [ BACK TO MENU ]
CMD>