Sha256: 045482679ff76119d91c2ce2236b2ac15b7d0d418757353e91dde5280a60c2c0

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

# frozen_string_literal: true

module Mihari
  module Clients
    class BinaryEdge < Base
      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

1 entries across 1 versions & 1 rubygems

Version Path
mihari-5.1.1 lib/mihari/clients/binaryedge.rb