Warning, it uses insecure http since curl has issues with self-signed certs. So be careful when using on anything other than l for localhost
Requires python and it's json.tool
Usage: ncli APIcmd server option1 option2...
where server is IP/DNS or use l to query localhost
and options are APIcmd specific
API commands:
sendMoney
getTransactionBytes
getTransaction
broadcastTransaction
decodeToken
getPeers
getPeer
getAccountId
getAccountBlockIds
getAccountPublicKey
getAccountTransactionIds
getBalance
getGuaranteedBalance
assignAlias
getAliasId
getAliasIds
getAliasURI
listAccountAliases
sendMessage
getBlock
getConstants
getMyInfo
getState
getTime
decodeHallmark
markHost
use 'ncli APIcmd help' for more help on a particular API command
# to update for additional API calls, enter the new command in the array API, but be sure to
# keep the case switch sections in the same order as in the API array
#
API=(sendMoney getTransactionBytes getTransaction broadcastTransaction decodeToken getPeers getPeer getAccountId getAccountBlockIds getAccountPublicKey getAccountTransactionIds getBalance getGuaranteedBalance assignAlias getAliasId getAliasIds getAliasURI listAccountAliases sendMessage getBlock getConstants getMyInfo getState getTime decodeHallmark markHost)
if [ "$2" = "l" ]; then
HOST="127.0.0.1"
else
HOST=$2
fi
case "$1" in
sendMoney)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&secretPhrase\=$3\&recipient\=$4\&amount\=$5\&fee=$6\&deadline\=$7 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server passphrase recipient amount fee deadline"
fi
;;
getTransactionBytes)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&transaction\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server transactionID"
fi
;;
getTransaction)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&transaction\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server transactionId"
fi
;;
broadcastTransaction)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&transactionBytes\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server bytecode"
fi
;;
decodeToken)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&website\=$3\&token\=$4 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server site.domain.tld 160characterToken"
fi
;;
getPeers)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server"
fi
;;
getPeer)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&peer\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server peerIPorDNS"
fi
;;
getAccountId)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&secretPhrase\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server passphrase"
fi
;;
getAccountBlockIds)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&account\=$3\×tamp\=$4 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server account timestamp"
fi
;;
getAccountPublicKey)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&account\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server account"
fi
;;
getAccountTransactionIds)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&account\=$3\×tamp\=$4 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server account timestamp"
fi
;;
getBalance)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&account\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server account"
fi
;;
getGuaranteedBalance)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&account\=$3\&numberOfConfirmations\=$4 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server account numberOfConfirmationsRequired"
fi
;;
assignAlias)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&secretPhrase\=$3\&alias\=$4\&uri\=$5\&fee\=$6\&deadline\=$7 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server passphrase alias uri fee deadline"
fi
;;
getAliasId)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&alias\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server alias"
fi
;;
getAliasIds)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\×tamp\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server timestamp"
fi
;;
getAliasURI)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&alias=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server alias"
fi
;;
listAccountAliases)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&account=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server account"
fi
;;
sendMessage)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&secretPhrase\=$3\&recipient\=$4\&fee=$5\&message\=$6\&deadline\=$7 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server passphrase recipient fee HEX deadline"
echo "note the message is sent encrypted. Encrypt yourself if required"
fi
;;
getBlock)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&block=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server blockID"
fi
;;
getConstants)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server"
fi
;;
getMyInfo)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server"
fi
;;
getState)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server"
fi
;;
getTime)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server"
fi
;;
decodeHallmark)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&hallmark=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server hallmarkString"
fi
;;
markHost)
if [ "$HOST" != "help" ]; then
curl -s http://$HOST:7874/nxt\?requestType\=$1\&secretPhrase=$3\&host\=$4\&weight\=$5\&date\=$6 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
else
echo "ncli $1 server passphrase IPaddressOrDNSname weight date"
echo "where date format is YYYY-MM-DD"
fi
;;
*) echo ""
echo "Usage: ncli APIcmd server option1 option2..."
echo ""
echo "where server is IP/DNS or use l to query localhost"
echo "and options are APIcmd specific"
echo "API commands:"
for item in ${API[*]}
do
printf " %s\n" $item
done
echo "use 'ncli APIcmd help' for more help on a particular API command"
;;
esac