Skip to content

Instantly share code, notes, and snippets.

/ticker Secret

Created May 5, 2014 23:50
Show Gist options
  • Save anonymous/b51025c4a01baaf71544 to your computer and use it in GitHub Desktop.
Save anonymous/b51025c4a01baaf71544 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'json'
require 'net/http'
require 'uri'
require 'pp'
def getjson(urlvar)
return JSON.parse(Net::HTTP.get_response(URI.parse(urlvar)).body) # Parse urlvar, send a request to it, and parse the response.
end
while true do
puts `clear`
File.open('coins', 'r').each_line do |coinname|
c = getjson("http://coinmarketcap.northpole.ro/api/#{coinname.gsub(/\s+/, "")}.json")
puts "#{c['name']}: $#{c['price']}"
puts "Volume (24h): #{c['volume24']} | Price change (24h): #{c['change24']}"
end
sleep 300 # 5 minutes.
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment