Ruby library for SHODAN
Switch branches/tags
Nothing to show
Latest commit fe73170 Apr 7, 2016 @achillean Merge pull request #8 from asafschers/master
Remove puts

Visit the official Shodan API documentation at:


To install the library use rubygems:

gem install shodan


Before you can use the API, you need to have an API key.

Get your API key here

Setup the Shodan wrapper object:

require 'shodan'

api =

Print a list of cisco-ios devices:

result ="cisco-ios")
result['matches'].each{ |host|
	puts host['ip_str']

Print the 2nd page of results for the cisco-ios query:

result ="cisco-ios", :page => 2)
result['matches'].each{ |host|
	puts host['ip_str']

Find out how many results there are for "apache" and also return the top 5 organizations for the results:

result = api.count("apache", :facets => 'org:5')
puts "Total number of results: #{result['total']}"
puts result['facets']

Get all the information SHODAN has on the IP

host ='')
puts host.to_s

To properly handle potential errors, you should wrap all requests in a try/except block:

rescue Exception => e
	puts "Error: #{e.to_s}"
	puts "Unknown error"