Published: 03 Nov 2019 › Updated: 03 Nov 2019
Spectrum API - JS Client library with samples
EOS Tribe published JS Client library for Telos and Worbli Spectrum API endpoints:
Telos JS libraries:
- https://spectrum-client.s3.amazonaws.com/telos.spectrum.min.js
- https://spectrum-client.s3.amazonaws.com/telos.spectrum.js
Worbli JS libraries:
- https://spectrum-client.s3.amazonaws.com/worbli.spectrum.min.js
- https://spectrum-client.s3.amazonaws.com/worbli.spectrum.js
JS method signatures for both JS libraries:
- get_blocks(onMessageHandler, onCloseHandler, onErrorHandler)
- get_transaction(account, onMessageHandler, onCloseHandler, onErrorHandler)
- get_actions(account, actions, onMessageHandler, onCloseHandler, onErrorHandler)
- get_table_rows(account, table, scope, onMessageHandler, onCloseHandler, onErrorHandler)
Below is the sample use JS code for get_blocks method:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Spectrum Demo</title>
<script type=text/javascript src="https://spectrum-client.s3.amazonaws.com/telos.spectrum.min.js"></script>
<script>
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);
</script>
</head>
<body>
<p>View console for messages</p>
</body>
</html>
Sample JS code for get_transaction method:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Spectrum Demo</title>
<script type=text/javascript src="https://spectrum-client.s3.amazonaws.com/telos.spectrum.min.js"></script>
<script>
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);
</script>
</head>
<body>
<p>View console for messages</p>
</body>
</html>
Sample JS code for get_actions method:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Spectrum Demo</title>
<script type=text/javascript src="https://spectrum-client.s3.amazonaws.com/telos.spectrum.min.js"></script>
<script>
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);
</script>
</head>
<body>
<p>View console for messages</p>
</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.
Leave Spectrum API - JS Client library with samples to:
Read more #eosio posts
Best Posts From EOS Tribe
We have not curated any of eostribe's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From EOS Tribe
- EOS Tribe joins the WAX Network
- EOS Tribe + EOS USA launch Spectrumeos.io
- EOS Tribe + EOS USA are bringing Spectrum API + Full History API to EOS
- Spectrum API - NodeJS client code example
- Spectrum API - JS Client library with samples
- Spectrum API - Added get_table_rows endpoint
- Spectrum API running on Telos Mainnet
- Spectrum API - get_transaction endpoint available
- Spectrum API - Client JS samples
- Spectrum API running on Telos Testnet
- Spectrum API running on Telos Testnet
- Introducing Spectrum Streaming API for EOSIO
- My reflection on EOS history and current state
- New way to create EOS accounts without any upfront cost
- Easy New Account Creation Process for EOS, BOS, Telos and Meet.One
- KIBISIS Wallet adds support for Meet.One chain
- Kibisis Wallet Update - June 2019
- EOS Tribe open source swift-ecc library
- EOS Tribe announces partnership with StrongBlock
- Kibisis Wallet now available on App Store