Working Nodes - The Simplest Method

in Synergy Builders5 days ago

Alright, sometimes you just need a quick list of working Hive nodes, maybe for a script or just to check endpoints, and you don't want to write a full program in JS, Go, Rust, or whatever. If you're comfortable on the command line and have basic tools like curl and jq installed (most Linux/Mac systems do, Windows users might need WSL or equivalent), there's actually a really straightforward way to grab them.

We can leverage the awesome work done by @nectarflower (for main Hive nodes) and @flowerengine (for Hive-Engine nodes). As I've mentioned in previous posts about my libraries, they keep updated node lists right in their account's JSON metadata. So, we can just query the blockchain directly for that metadata!

Here’s a dead-simple bash script that does exactly that. It uses curl to call the database_api.find_accounts method for each account name via a public API node, and then pipes the JSON result through jq twice – first to extract the json_metadata field and parse it (fromjson), and then again to pull out the actual node list (.nodes[]).

#!/bin/bash

printf "nectarflower - Hive Nodes\n"
# Fetch nectarflower account data and parse metadata for nodes
curl -s --data '{"jsonrpc":"2.0", "method":"database_api.find_accounts", "params": {"accounts":["nectarflower"]}, "id":1}' https://api.hive.blog |
  jq '.result.accounts[0].json_metadata | fromjson' |
  jq '.nodes[]'

printf "\nflowerengine - Hive-Engine Nodes\n"
# Fetch flowerengine account data and parse metadata for nodes
curl -s --data '{"jsonrpc":"2.0", "method":"database_api.find_accounts", "params": {"accounts":["flowerengine"]}, "id":1}' https://api.hive.blog |
  jq '.result.accounts[0].json_metadata | fromjson' |
  jq '.nodes[]'

Run that script (make sure it's executable: chmod +x your_script_name.sh), and you get a nice, clean list of nodes spat out right on your terminal, like this:

Node Lists

Of course, if you're like me, simple isn't always the only way! You can definitely get more extravagant even sticking purely with bash scripting. I've been tinkering with my own, more advanced bash script for node checking – it's still a work-in-progress, and I'll probably share it when I feel like it's in a better place, but check out this much prettier (and informative) output it can generate:

Much Pretty!

What can I say? I have a unique sense of fun when it comes to building tools like this. Hope the simple script helps someone out there who just needs a quick node list!

As always,
Michael Garcia a.k.a. TheCrazyGM