Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Basic node interaction: API call Get_node_info()
// The snippet is a part of the IOTA Developer Essentials project. You can reach it at
// Complete description and story behind the snippet is available at:
// Requirement: IOTA Javascript Library (!npm install iota.lib.js)
var IOTA = require('../../node_modules/iota.lib.js/lib/iota'); // load iota.lib.js
// # ctor initialization of the iota.lib.js library
var iota = new IOTA({
'provider': ''
// basic API call to double check health conditions
iota.api.getNodeInfo(function (error, success) {
if (error) {
// unable to perform getNodeInfo call
} else {
// result is printed out
// Basic check whether node is in sync or not
// Elementary rule is that "latestMilestoneIndex" should equal to "latestSolidSubtangleMilestoneIndex" or be very close
if (Math.abs(success['latestMilestoneIndex'] - success['latestSolidSubtangleMilestoneIndex']) > 3) {
console.log('\r\nNode is probably not synced!');
} else {
console.log('\r\nNode is probably synced!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.