Skip to content

Instantly share code, notes, and snippets.

@44uk
Created September 23, 2018 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 44uk/744c74c5f95a524f5888d501fd0117f4 to your computer and use it in GitHub Desktop.
Save 44uk/744c74c5f95a524f5888d501fd0117f4 to your computer and use it in GitHub Desktop.
Get all nem namespace from Node
#!/bin/bash
nodeUrl=http://88.99.192.82:7890 # huge alice
# nodeUrl=http://176.9.68.110:7890 # huge alice 2
# nodeUrl=http://176.9.20.180:7890 # huge alice 3
tempDir=/tmp/_get_all_nem_namespace
lastId=99999
[ -d $tempDir ] || mkdir -p $tempDir
while [ "$lastId" != "null" ]; do
result=$(curl -s "$nodeUrl/namespace/root/page?pageSize=100&id=$lastId")
firstId=$(echo $result | jq .data[0].meta.id)
lastId=$(echo $result | jq .data[-1].meta.id)
[ "$lastId" = "null" ] && break
echo $result | jq '.data[].namespace' > "$tempDir/$firstId.json"
sleep 1
done
jq --slurp '.' $tempDir/*.json > namespaces.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment