A Simple BASH Script to Query to Cryptocurrency

in blurt •  2 years ago 

image.png

Here is a quick BASH script that allows you to do something like this:

./ticker
e.g. ././ticker steem usd
./ticker steem usd
"1 steem = 0.21412699896499998 usd"
./ticker 2 steem gbp
"2 steem = 0.3794 gbp"
./ticker eth 2 btc
"26.331085755738364 eth = 2 btc"

#!/bin/bash

check_json=$(echo "{ }" | jq)
if [ "$check_json" != "{}" ]; then
        echo "jq not installed"
        exit 1
fi

if [ "$1" == "" ]; then
        echo "e.g. ./$0 steem usd"
fi

API="https://price.justyy.workers.dev/query/"

curl -s -X POST -d "$*" $API | jq .result[0]

This requires the jq to parse the JSON output from the Crypto API made by @justyy (myself) on cloudflare workers serverless technology.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Thank you for reading ^^^^^^^^^^^^^^^

NEW! Following my Trail (Upvote or/and Downvote)

Follow me for topics of Algorithms, Blockchain and Cloud.
I am @justyy - a Steem Witness
https://steemyy.com

My contributions

Steem/Swap to USDT Swap

I also made this Super Easy/Handy Service to Convert your STEEM or SBD to USDT (TRC-20)

Delegation Service

Voting Power Considered in Voting Schema and Important Update of Delegation Service!

  • Delegate 1000 to justyy: Link
  • Delegate 5000 to justyy: Link
  • Delegate 10000 to justyy: Link

Support me

If you like my work, please:

  1. Delegate SP: https://steemyy.com/sp-delegate-form/?delegatee=justyy
  2. Vote @justyy as Witness: https://steemyy.com/witness-voting/?witness=justyy&action=approve
  3. Set @justyy as Proxy: https://steemyy.com/witness-voting/?witness=justyy&action=proxy
    Alternatively, you can vote witness or set proxy here: https://steemit.com/~witnesses

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!