SecurityTrails
SecurityTrails API wrapper for Ruby.
Installation
Add this line to your application's Gemfile:
gem 'securitytrails'
And then execute:
$ bundle
Or install it yourself as:
$ gem install securitytrails
Usage
require "securitytrails"
# When given nothing, it tries to load your API key from ENV["SECURITYTRAILS_API_KEY"]
api = SecurityTrails::API.new
# or you can pass your API key as an argument
api = SecurityTrails::API.new(YOUR_API_KEY)
# Domain details
# https://docs.securitytrails.com/v1.0/reference#domains
api.domain.get_by_hostname("github.com")
api.domain.get_subdomains("github.com")
api.domain.("github.com")
api.domain.get_associated_domains("github.com")
api.domain.get_whois("github.com")
# Domain search
# https://docs.securitytrails.com/v1.0/reference#domain-search
api.domains.search(
filter: {
ipv4: "1.1.1.1"
})
api.domains.stats(
filter: {
ipv4: "1.1.1.1"
}
)
# History
# https://docs.securitytrails.com/v1.0/reference#history
api.history.get_dns_history("github.com", "a")
api.history.get_all_dns_history("github.com", "a")
api.history.get_whois_history("github.com")
# IPs
# https://docs.securitytrails.com/v1.0/reference#ips
api.ips.explore("8.8.8.8")
api.ips.search("ptr_part = 'ns1'")
api.ips.stats("ptr_part = 'amazon.com'")
# Feeds
# https://docs.securitytrails.com/v1.0/reference#feeds
api.feeds.domain("new")
api.feeds.domain("new", tld: "jp")
All the API response (JSON / Hash) is wrapped by OpenStruct.
It means you can access to a response through a property-like syntax.
res = api.domain.get_by_hostname("github.com")
puts res.hostname # => "github.com"
puts res.current_dns.a.first_seen # => "2018-09-12"
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/ninoseki/securitytrails.
License
The gem is available as open source under the terms of the MIT License.