Code Examples: Ruby

Our code examples use the Trstrank API, the most popular API on Infochimps.

infochimps-trstrank.rb

  require 'open-uri'
require 'rubygems'
require 'json'                            

apikey = 'api_test-W1cipwpcdu9Cbd9pmm8D4Cjc469'
screen_name = 'infochimps'

url = 'http://api.infochimps.com/soc/net/tw/trstrank.json?' + 'apikey=' + apikey + '&screen_name=' + screen_name                                        
buffer = open(url, "UserAgent" => "Ruby-Wget").read
result = JSON.parse(buffer)

puts result['screen_name'].to_s + ': ' + result['trstrank'].to_s

Usage

Enter the following command into the command line to run.

  ruby infochimps-trstrank.rb
# => infochimps: 3.69686