Skip to content

Instantly share code, notes, and snippets.

@paulfarino
Created February 27, 2018 06:36
Show Gist options
  • Save paulfarino/4c929c394323c09bc9ce489fd35eebe1 to your computer and use it in GitHub Desktop.
Save paulfarino/4c929c394323c09bc9ce489fd35eebe1 to your computer and use it in GitHub Desktop.
Check crypto prices from the command line
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