Created
July 10, 2014 05:34
-
-
Save ryandotsmith/fd5f044544ba9954cd02 to your computer and use it in GitHub Desktop.
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
$ ruby x.rb | |
Address: 1FBVmnKtjgA676Xbatqx42dcGzaaPV4BU4 contains 4 transactions. | |
Address: 17j92xE73rEyexJSB4gwavd2YkpTKZWfAv contains 7 transactions. |
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
require 'net/http' | |
require 'json' | |
require 'net/https' | |
require 'uri' | |
addrs = [ | |
'1FBVmnKtjgA676Xbatqx42dcGzaaPV4BU4', | |
'17j92xE73rEyexJSB4gwavd2YkpTKZWfAv' | |
] | |
url = URI.parse( | |
"http://chain-api-staging.herokuapp.com"+ | |
"/v1/bitcoin/addresses/#{addrs.join(',')}/transactions" | |
) | |
http = Net::HTTP.new(url.host, url.port) | |
req = Net::HTTP::Get.new(url.path) | |
req.basic_auth('GUEST-TOKEN', '') | |
res = http.request(req) | |
txns = JSON.parse(res.body) | |
addrs.each_with_index do |addr, idx| | |
puts("Address: #{addr} contains #{txns[idx].length} transactions.") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment