bestofama /lib/api/duckduckgo.com.rb

Language Ruby Lines 12
MD5 Hash a121a8c9f253a04917c7c5359c9c1cbe
Repository https://bitbucket.org/andey/bestofama.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#== DuckDuckGo Stats API library

class DuckDuckGo
  include HTTParty
  base_uri 'api.duckduckgo.com'

  def search(text)
    options = {:query => {:q => text.gsub(/-/, '+'), :format => 'json'}}
    response = self.class.get('/', options)
    return response.code == 200 ? JSON.parse(response.body) : nil
  end
end
Back to Top