Skip to content

Instantly share code, notes, and snippets.

@ryandotsmith
Created July 10, 2014 05:34
Show Gist options
  • Save ryandotsmith/fd5f044544ba9954cd02 to your computer and use it in GitHub Desktop.
Save ryandotsmith/fd5f044544ba9954cd02 to your computer and use it in GitHub Desktop.
$ ruby x.rb
Address: 1FBVmnKtjgA676Xbatqx42dcGzaaPV4BU4 contains 4 transactions.
Address: 17j92xE73rEyexJSB4gwavd2YkpTKZWfAv contains 7 transactions.
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