Created
February 27, 2018 06:36
-
-
Save paulfarino/4c929c394323c09bc9ce489fd35eebe1 to your computer and use it in GitHub Desktop.
Check crypto prices from the command line
This file contains hidden or 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
require 'json' | |
require 'net/http' | |
require 'colorize' | |
require 'colorized_string' | |
print ColorizedString["What coin do you want a price for? (BTC Base Pair): "].colorize(:blue) | |
coin_name = gets | |
API_URL = "https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=#{coin_name}" | |
url = URI.parse(format(API_URL)) | |
response = Net::HTTP.get(url) | |
json = JSON.parse(response) | |
json_values = json.values | |
link = "View Here: " + "#{API_URL}" | |
puts json_values | |
puts ColorizedString[link].colorize(:yellow) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment