What is wink.sh?
wink.sh is a Winkdex bitcoin price script written in bash for use in your linux command-line environment.
wink.sh to get the most current price:
$ The price for one bitcoin as of 07:38:30 PM is $418.46. [WINKDEX.COM]
Build Process for
- Choose a Bitcoin price index to use. Options include:
- Consult its API documentation (WinkDex in this case).
- In Linux terminal do:
- Add bash shebang header:
- Pull down data:
curl (URL for API calls, from WinkDex get current 'cents' value of 1.0 BTC).
- Convert cents value to #dollars/BTC:
cut (with space delimiters, cents data only), use
($cents * 0.01).
- Add time, default message to print:
The price of one bitcoin is $[$dollars] as of [$time].
#!/bin/bash # Bitcoin price script using WINKDEX API (https://winkdex.com/) # WARNING: Run no more than once per minute. # get current BTC price in cents, log to wink.log curl -s -H “User-Agent: wink-sh” “https://winkdex.com/api/v0/price" > $HOME/bin/wink.log # cut and print BTC value in ‘cents’, log to cents.log cat $HOME/bin/wink.log | cut -d “:” -f 5 | cut -d “,” -f 1 > $HOME/bin/cents.log # set variable PRICE and calculate dollars and cents using ‘bc’ PRICE=$(echo “`cat $HOME/bin/cents.log` * .01” | bc) # print PRICE along with current time and attribution echo “The price for one bitcoin as of `date +\”%r\”` is \$$PRICE. [WINKDEX.COM]” rm $HOME/bin/wink.log && rm $HOME/bin/cents.log
See on GitHub.
- Replace log files with argument variables.
- Color the outputs/output text.
- Set to auto-refresh each minute in terminal while running.
- Request extra bandwidth from Winkdex to reduce refresh interval to 10 seconds.