Spectrum API running on Telos Testnet

in #eosio5 years ago (edited)

spectrum.jpeg

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

Telos Testnet Spectrum API web-socket endpoint: wss://testnet.telos.eostribe.io

This version currently supports subscriptions for get_actions and get_blocks endpoints.

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:

  • event - type of events, there are two variants: “subscribe” and “unsubscribe”. Required [String].
  • type - type of endpoint. Required [String].
  • data - Contents of this object depends on type argument. Required for get_actions.
  • account - name of account. Required [String].
  • actions - List of actions name. [Object]. If actions are not specified - all actions will be matched.

Sample client in Python for get_actions:

import json
from websocket import create_connection

path="streaming"
url = "wss://testnet.telos.eostribe.io/"+path

actionsList = ["transfer","buyram"]
data = {"account":"eostribeprod"}
messageBody = {
   "apikey":"test-api-key",
   "event":"subscribe",
   "type":"get_actions",
    "data": data
 }
ws = create_connection(url)
messageJson = json.dumps(messageBody)
ws.send(messageJson)

while True:
   response = ws.recv()
   print(response)
ws.close()

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:

  • apikey - key for access and accounting, not using on testnet.[String]
  • event - type of event, there are two variants “subscribe” and “unsubscribe”. To subscribe necessary using "subscribe" * value - this field is mandatory. [String].
  • type - type of endpoint. Required [String].

Sample Python client for get_blocks subscription:

import json
import pprint
from websocket import create_connection

path="streaming"
url = "wss://testnet.telos.eostribe.io/"+path

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

ws = create_connection(url)
ws.send(json.dumps(messageBody))

while True:
   pprint.pprint(json.loads(ws.recv()))
ws.close()

JavaScript client is coming soon.

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.

Sort:  

Updated: added get_blocks endpoint description.

Congratulations @eostribe! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You distributed more than 200 upvotes. Your next target is to reach 300 upvotes.

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Do not miss the last post from @steemitboard:

The new SteemFest⁴ badge is ready
Vote for @Steemitboard as a witness to get one more award and increased upvotes!