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: A core module of IOTA Javascript Library (!npm install @iota/core)
var iotalib = require('@iota/core'); // loading iota.js core module. More info:
// composerAPI initialization of the iota.js library
var iota = iotalib.composeAPI({
'provider': ''
// basic API call to double check health conditions
var promise = iota.getNodeInfo()
.then(info => {
// 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(info['latestMilestoneIndex'] - info['latestSolidSubtangleMilestoneIndex']) > 3) {
console.log('\r\nNode is probably not synced!');
} else {
console.log('\r\nNode is probably synced!');
.catch(error => {
console.log('Request error: ${error.message}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment