MX Lookup API - Ruby Gem

MX Lookup is a simple tool for getting MX records for a domain. It returns the MX records for the given domain.

Installation

Add this line to your application's Gemfile:

gem 'apiverve_mxlookup'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install apiverve_mxlookup

Getting Started

Get your API key at APIVerve

Basic Usage

require 'apiverve_mxlookup'

# Initialize the client
client = APIVerve::Mxlookup::Client.new(api_key: "YOUR_API_KEY")

# Make a request
response = client.execute({ domain: "yahoo.com" })

# Print the response
puts response

Error Handling

begin
  response = client.execute({ domain: "yahoo.com" })
  puts response["data"]
rescue APIVerve::Mxlookup::ValidationError => e
  puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Mxlookup::APIError => e
  puts "API error: #{e.message}"
  puts "Status code: #{e.status_code}"
end

Debug Mode

# Enable debug logging
client = APIVerve::Mxlookup::Client.new(
  api_key: "YOUR_API_KEY",
  debug: true
)

Example Response

{
  "status": "ok",
  "error": null,
  "data": {
    "domain": "yahoo.com",
    "mx": [
      {
        "priority": 1,
        "exchange": "mta7.am0.yahoodns.net"
      },
      {
        "priority": 1,
        "exchange": "mta6.am0.yahoodns.net"
      },
      {
        "priority": 1,
        "exchange": "mta5.am0.yahoodns.net"
      }
    ]
  }
}

Documentation

For more information, visit the API Documentation.

Support

License

This gem is available under the MIT License.