Sha256: 213cd77e87476a50d1b4f4252580355bac404cf297983194717103a36ba8baa6

Contents?: true

Size: 995 Bytes

Versions: 14

Compression:

Stored size: 995 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Clients
    class BinaryEdge < Base
      #
      # @param [String] base_url
      # @param [String, nil] api_key
      # @param [Hash] headers
      #
      def initialize(base_url = "https://api.binaryedge.io/v2", api_key:, headers: {})
        raise(ArgumentError, "'api_key' argument is required") unless api_key

        headers["x-key"] = api_key

        super(base_url, headers: headers)
      end

      #
      # @param [String] query String used to query our data
      # @param [Integer] page Default 1, Maximum: 500
      # @param [Integer, nil] only_ips If selected, only output IP addresses, ports and protocols.
      #
      # @return [Hash]
      #
      def search(query, page: 1, only_ips: nil)
        params = {
          query: query,
          page: page,
          only_ips: only_ips
        }.compact

        res = get("/query/search", params: params)
        JSON.parse(res.body.to_s)
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mihari-5.4.2 lib/mihari/clients/binaryedge.rb
mihari-5.4.1 lib/mihari/clients/binaryedge.rb
mihari-5.4.0 lib/mihari/clients/binaryedge.rb
mihari-5.3.2 lib/mihari/clients/binaryedge.rb
mihari-5.3.1 lib/mihari/clients/binaryedge.rb
mihari-5.3.0 lib/mihari/clients/binaryedge.rb
mihari-5.2.4 lib/mihari/clients/binaryedge.rb
mihari-5.2.3 lib/mihari/clients/binaryedge.rb
mihari-5.2.2 lib/mihari/clients/binaryedge.rb
mihari-5.2.1 lib/mihari/clients/binaryedge.rb
mihari-5.2.0 lib/mihari/clients/binaryedge.rb
mihari-5.1.4 lib/mihari/clients/binaryedge.rb
mihari-5.1.3 lib/mihari/clients/binaryedge.rb
mihari-5.1.2 lib/mihari/clients/binaryedge.rb