User:Forkedchain

From Nxt Wiki
Jump to: navigation, search
  1. !/bin/bash


  1. to update for additional API calls, enter the new command in the array API, but be sure to
  2. keep the case switch sections in the same order as in the API array

API=(getAccount cancelBidOrder cancelAskOrder getBidOrder getAskOrder getAccountCurrentBidOrderIds getAccountCurrentAskOrderIds getBidOrderIds getAskOrderIds placeBidOrder placeAskOrder transferAsset getAsset getAssetIds issueAsset 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

if [ "$HOST" = "holms.cloudapp.net" ]; then

       PORT="6874"

else

       PORT="7874"

fi

case "$1" in

getAccount) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&account\=$3\&timestamp=$4 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server account timestamp"

fi

       ;;

cancelBidOrder) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&secretPhrase\=$3\&order\=$4\&fee\=$5\&deadline\=$6 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server passphrase orderID fee deadline"

fi

       ;;

cancelAskOrder) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&secretPhrase\=$3\&order\=$4\&fee\=$5\&deadline\=$6 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server passphrase orderID fee deadline"

fi

       ;;

getBidOrder) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&order\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server orderID"

fi

       ;;

getAskOrder) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&order\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server orderID"

fi

       ;;

getAccountCurrentBidOrderIds) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&account\=$3\&asset\=$4 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server account asset(optional)"

fi

       ;;

getAccountCurrentAskOrderIds) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&account\=$3\&asset\=$4 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server account asset(optional)"

fi

       ;;

getBidOrderIds) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&asset\=$3\&timestamp\=$4 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server assetID timestamp"

fi

       ;;

getAskOrderIds) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&asset\=$3\&timestamp\=$4 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server assetID timestamp"

fi

       ;;

placeBidOrder) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&secretPhrase=$3\&asset\=$4\&quantity\=$5\&price\=$6\&fee\=$7\&deadline\=$8 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server passphrase asset quantity price fee deadline "

fi

       ;;

placeAskOrder) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&secretPhrase=$3\&asset\=$4\&quantity\=$5\&price\=$6\&fee\=$7\&deadline\=$8 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server passphrase asset quantity price fee deadline "

fi

       ;;

transferAsset) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&secretPhrase=$3\&recipient\=$4\&asset\=$5\&quantity\=$6\&fee\=$7\&deadline\=$8 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server passphrase recipient asset quantity fee deadline "

fi

       ;;

getAsset) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&asset\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server assetID "

fi

       ;;

getAssetIds) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server "

fi

       ;;

issueAsset) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&secretPhrase\=$3\&name\=$4\&description\=$5\&quantity\=$6\&fee\=$7 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server passphrase name description quantity fee "

fi

       ;;

sendMoney) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/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" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&transaction\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server transactionID"

fi

       ;;

getTransaction) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&transaction\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server transactionId"

fi

       ;;

broadcastTransaction) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&transactionBytes\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server bytecode"
       fi

decodeToken) if "$HOST" != "help" && "$HOST" != "" ; then

      curl -s http://$HOST:$PORT/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" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server"

fi

       ;;

getPeer) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&peer\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server peerIPorDNS"

fi

       ;;

getAccountId) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&secretPhrase\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server passphrase"

fi

       ;;

getAccountBlockIds) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&account\=$3\&timestamp\=$4 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server account timestamp"

fi

       ;;

getAccountPublicKey) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&account\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server account"

fi

       ;;

getAccountTransactionIds) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&account\=$3\&timestamp\=$4 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server account timestamp"

fi

       ;;

getBalance) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&account\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server account"

fi

       ;;

getGuaranteedBalance) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/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" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/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" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&alias\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server alias"

fi

       ;;

getAliasIds) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&timestamp\=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server timestamp"

fi

       ;;

getAliasURI) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&alias=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server alias"

fi

       ;;

listAccountAliases) if "$HOST" != "help" && "$HOST" != "" ; then

curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&account=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server account"

fi

       ;;

sendMessage) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/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" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&block=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server blockID"

fi

       ;;

getConstants) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server"

fi

       ;;

getMyInfo) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server"

fi

       ;;

getState) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'
      else
       echo "ncli $1 server"

fi

       ;;

getTime) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server"

fi

       ;;

decodeHallmark) if "$HOST" != "help" && "$HOST" != "" ; then

       curl -s http://$HOST:$PORT/nxt\?requestType\=$1\&hallmark=$3 | python -m json.tool | sed -e 's/\([]"{}[,]\)//g'

else

       echo "ncli $1 server hallmarkString"

fi

       ;;

markHost) if "$HOST" != "help" && "$HOST" != "" ; then

curl -s http://$HOST:$PORT/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