Skip to content

Instantly share code, notes, and snippets.

@teklordz
Last active July 7, 2020 16:22
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save teklordz/1851b5693b338d4365d8 to your computer and use it in GitHub Desktop.
Save teklordz/1851b5693b338d4365d8 to your computer and use it in GitHub Desktop.
Bitcoin prices in real time from the coindesk website api (bash script)
#!/bin/bash
# Credit to David Walsh for the original script <https://davidwalsh.name/bitcoin>
# The improved version of David's script doesn't go back to prompt. It keeps refreshing the prices every 5 seconds.
# Prices are in USD, EUR & GBP (in real time)
# curl must be installed in terminal
clear
echo "Coindesk BTC: "
echo " USD EUR GBP "
while [ 1 ]
do
curl -s http://api.coindesk.com/v1/bpi/currentprice.json | python -c "import json, sys; bitcoin=json.load(sys.stdin); print bitcoin['bpi']['USD']['rate'] + '\t' + bitcoin['bpi']['EUR']['rate'] + '\t' + bitcoin['bpi']['GBP']['rate']"
printf "\033[A"
sleep 5
done
Copy link

ghost commented Jul 7, 2020

hey, nice one! check my scripts, some of them have websockets or curl loop to keep fetching the latest rate of bitcoin and other cryptos..
https://github.com/mountaineerbr/markets
cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment