create account

Spectrum API running on Telos Mainnet by eostribe

View this thread on: hive.blogpeakd.comecency.com
· @eostribe ·
Spectrum API running on Telos Mainnet
![spectrum.jpeg](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:
* **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.

#### 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].

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:
* **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].
* **data** - Contents of this object depends on type argument. Required for get_transaction.
* **account**  - name of account. Required [String].

### Sample JS web-socket client to subscribe for events:
```
<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 += "<p>"+data+"</p>";
}

</script>
</head>
<body>
<h2>Spectrum Web Sockets Test: Get Actions</h2>
<div id="log"></div>
</body></html>
```

#### 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.
👍  ,
properties (23)
authoreostribe
permlinkspectrum-api-running-on-telos-mainnet
categoryspectrum
json_metadata{"tags":["spectrum","api","telos","mainnet"],"image":["https://cdn.steemitimages.com/DQmYjiC4VYNHRm6tRcaNiSr6Hzx3ZUJdMgzSBGv1sgSRyaf/spectrum.jpeg"],"links":["https://www.telosfoundation.io/","https://t.me/EOSTribe","https://steemit.com/eosio/@eostribe/introducing-spectrum-streaming-api-for-eosio"],"app":"steemit/0.1","format":"markdown"}
created2019-10-24 15:36:03
last_update2019-10-24 15:36:03
depth0
children2
last_payout2019-10-31 15:36:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length4,140
author_reputation2,660,491,410,996
root_title"Spectrum API running on Telos Mainnet"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id91,865,342
net_rshares554,636,955
author_curate_reward""
vote details (2)
@bodget ·
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
properties (22)
authorbodget
permlinkpzw009
categoryspectrum
json_metadata{"app":"steemit/0.1"}
created2019-10-24 16:20:15
last_update2019-10-24 16:20:15
depth1
children0
last_payout2019-10-31 16:20:15
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length307
author_reputation84,435,500,752
root_title"Spectrum API running on Telos Mainnet"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id91,866,621
net_rshares0
@concorde ·
Yeah, needed this. Nice job.
properties (22)
authorconcorde
permlinkpzzwsl
categoryspectrum
json_metadata{"app":"steemit/0.1"}
created2019-10-26 19:00:51
last_update2019-10-26 19:00:51
depth1
children0
last_payout2019-11-02 19:00:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length28
author_reputation169,904,466,612
root_title"Spectrum API running on Telos Mainnet"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id91,930,549
net_rshares0