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

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

Spectrum API - JS Client library with samples

BY: @eostribe | CREATED: Nov. 3, 2019, 12:07 a.m. | VOTES: 2 | PAYOUT: $0.02 | [ VOTE ]

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

EOS Tribe published JS Client library for Telos and Worbli Spectrum API endpoints:

Telos JS libraries:

Worbli JS libraries:

JS method signatures for both JS libraries:

Below is the sample use JS code for get_blocks method:






  Spectrum Demo


    var onMessageHandler = function (data) {
      console.log("Message: "+data);
    };
    var onCloseHandler = function(data) {
      console.log("Connection closed: "+data);
    };
    var onErrorHandler = function(error) {
      console.log("Error: "+error);
    };
    var websocket = get_blocks(onMessageHandler, onCloseHandler, onErrorHandler);




View console for messages



Sample JS code for get_transaction method:






  Spectrum Demo


    var onMessageHandler = function (data) {
      console.log("Message: "+data);
    };
    var onCloseHandler = function(data) {
      console.log("Connection closed: "+data);
    };
    var onErrorHandler = function(error) {
      console.log("Error: "+error);
    };
    var account = "eosio";
    var websocket = get_transaction(account, onMessageHandler, onCloseHandler, onErrorHandler);




View console for messages


Sample JS code for get_actions method:






  Spectrum Demo


    var onMessageHandler = function (data) {
      console.log("Message: "+data);
    };
    var onCloseHandler = function(data) {
      console.log("Connection closed: "+data);
    };
    var onErrorHandler = function(error) {
      console.log("Error: "+error);
    };
    var account = "eosio";
    var actions = ["transfer","buyram"];
    var websocket = get_actions(account, actions, onMessageHandler, onCloseHandler, onErrorHandler);




View console for messages


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: [ #eosio ] [ #js ] [ #client ] [ #sample ]

Replies

NO REPLIES FOUND.

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