MX Lookup API

The MX Lookup API retrieves mail exchange (MX) records for any given domain.

/v1/mxlookup GET

https://api.api-ninjas.com/v1/mxlookup

Returns a list of MX records associated with a particular domain. Free users receive only data from the first MX record, while premium users get access to all MX records.


Parameters

  • domain  required

    Valid domain to check (e.g. x.com). All top-level domains are supported.

Headers

  • X-Api-Key  required

    API Key associated with your account.

Sample Request Live Demo!

domain
https://api.api-ninjas.com/v1/mxlookup?domain=x.com

Headers

X-Api-KeyLog in or sign up to get your API Key

Sample Response

JSON
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 [ { "priority": 5, "value": "alt2.aspmx.l.google.com." }, { "priority": 1, "value": "aspmx.l.google.com." }, { "priority": 10, "value": "alt3.aspmx.l.google.com." }, { "priority": 10, "value": "alt4.aspmx.l.google.com." }, { "priority": 5, "value": "alt1.aspmx.l.google.com." } ]

Code Examples

1 2 3 4 5 6 7 8 9 import requests domain = 'x.com' api_url = 'https://api.api-ninjas.com/v1/mxlookup?domain={}'.format(domain) response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'}) if response.status_code == requests.codes.ok: print(response.text) else: print("Error:", response.status_code, response.text)

If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.