Skip to content

Instantly share code, notes, and snippets.

@michael
Created March 27, 2009 20:26
Show Gist options
  • Save michael/86876 to your computer and use it in GitHub Desktop.
Save michael/86876 to your computer and use it in GitHub Desktop.
class Freebase
include HTTParty
format :json
base_uri 'http://www.freebase.com/api'
def self.read(q)
return get('/service/mqlread?', :query => {:query => '{"query":' + q + '}'})['result']
end
end
query = '{"id":"/en/peru","capital":null,"type":"/location/country"}'
puts Freebase.read(query)['capital']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment