Last active
June 6, 2024 00:20
-
-
Save esmaeelE/b7f44e5c36093d4554491547375f9841 to your computer and use it in GitHub Desktop.
Get crypto prices in terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getdayname() ( | |
IFS=';' | |
set -o noglob | |
days=$(locale day) || exit | |
for day do | |
set -- $days $days | |
shift "$day" && | |
printf '%s\n' "$1" | |
done | |
) | |
day=$(curl -s "http://worldtimeapi.org/api/timezone/America/New_York" | python3 -c 'import sys, json; print (json.load(sys.stdin)["day_of_week"])') | |
# echo $day | |
getdayname $day | |
date +"%Y/%m/%d %T" | |
printf "TIME NEW_YORK\n" | |
time_newyork=$(curl -s "http://worldtimeapi.org/api/timezone/America/New_York" | python3 -c 'import sys, json; print (json.load(sys.stdin)["datetime"].split("T")[1].split(".")[0])') | |
echo $time_newyork | |
printf "BTC: " | |
curl -s https://api.coinbase.com/v2/prices/BTC-USD/sell -H 'Authorization: Bearer abd90df5f27a7b170cd775abf89d632b350b7c1c9d53e08b340cd9832ce52c2c' | python3 -c 'import sys, json; print (json.load(sys.stdin)["data"].get("amount"))' | |
printf "ETH: " | |
curl -s https://api.coinbase.com/v2/prices/ETH-USD/sell -H 'Authorization: Bearer abd90df5f27a7b170cd775abf89d632b350b7c1c9d53e08b340cd9832ce52c2c' | python3 -c 'import sys, json; print (json.load(sys.stdin)["data"].get("amount"))' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment