class Shodanz::API::Streaming
The REST
API
provides methods to search Shodan, look up hosts, get summary information on queries and a variety of other utilities. This requires you to have an API
key which you can get from Shodan.
Note: Only 1-5% of the data is currently provided to subscription-based API
plans. If your company is interested in large-scale, real-time access to all of the Shodan data please contact us for pricing information (sales@shodan.io).
@author Kent 'picat' Gruber
Constants
Attributes
@return [String]
Public Class Methods
@param key [String] SHODAN API
key, defaulted to the SHODAN_API_KEY enviroment variable.
# File lib/shodanz/apis/streaming.rb, line 29 def initialize(key: ENV['SHODAN_API_KEY']) @url = URL @client = Async::HTTP::Client.new(Async::HTTP::Endpoint.parse(@url)) self.key = key warn 'No key has been found or provided!' unless key? end
Public Instance Methods
Subscribe to banners discovered on the IP range defined in a specific network alert.
# File lib/shodanz/apis/streaming.rb, line 142 def alert(id) slurp_stream("alert/#{id}") do |data| yield data end end
Subscribe to banners discovered on all IP ranges described in the network alerts. Use the REST
API
methods to create/ delete/ manage your network alerts and use the Streaming
API
to subscribe to them.
# File lib/shodanz/apis/streaming.rb, line 135 def alerts slurp_stream('alert') do |data| yield data end end
Check if there's an API
key.
# File lib/shodanz/apis/streaming.rb, line 38 def key? return true if @key; false end