Skip to main content

DNS Lookup API

DNS Lookup retrieves published DNS records for any domain, including IPv4 (A), IPv6 (AAAA), and mail exchange (MX) servers. It provides hostnames, priorities, and dual-stack status flags, while paid plans add TXT, CNAME, and nameserver records.

PyPI version

This is a Python wrapper for the DNS Lookup API


Installation

Using pip:

pip install apiverve-dnslookup

Using pip3:

pip3 install apiverve-dnslookup

Configuration

Before using the dnslookup API client, you have to setup your account and obtain your API Key. You can get it by signing up at https://apiverve.com


Quick Start

Here's a simple example to get you started quickly:

from apiverve_dnslookup.apiClient import DnslookupAPIClient

# Initialize the client with your APIVerve API key
api = DnslookupAPIClient("[YOUR_API_KEY]")

query = { "domain": "myspace.com" }

try:
    # Make the API call
    result = api.execute(query)

    # Print the result
    print(result)
except Exception as e:
    print(f"Error: {e}")

Usage

The DNS Lookup API documentation is found here: https://docs.apiverve.com/ref/dnslookup. You can find parameters, example responses, and status codes documented here.

Setup

# Import the client module
from apiverve_dnslookup.apiClient import DnslookupAPIClient

# Initialize the client with your APIVerve API key
api = DnslookupAPIClient("[YOUR_API_KEY]")

Perform Request

Using the API client, you can perform requests to the API.

Define Query
query = { "domain": "myspace.com" }
Simple Request
# Make a request to the API
result = api.execute(query)

# Print the result
print(result)
Example Response
{
  "status": "ok",
  "error": null,
  "data": {
    "domain": "myspace.com",
    "records": {
      "A": [
        "34.111.176.156"
      ],
      "AAAA": null,
      "CNAME": null,
      "MX": [
        {
          "exchange": "us-smtp-inbound-1.mimecast.com",
          "priority": 10
        },
        {
          "exchange": "us-smtp-inbound-2.mimecast.com",
          "priority": 10
        }
      ],
      "NS": [
        "ns-cloud-a4.googledomains.com",
        "ns-cloud-a1.googledomains.com",
        "ns-cloud-a2.googledomains.com",
        "ns-cloud-a3.googledomains.com"
      ],
      "PTR": null,
      "SRV": null,
      "SOA": {
        "nsname": "ns-cloud-a1.googledomains.com",
        "hostmaster": "cloud-dns-hostmaster.google.com",
        "serial": 2,
        "refresh": 21600,
        "retry": 3600,
        "expire": 259200,
        "minttl": 300
      },
      "TXT": [
        "cr40m536tje9on1slld9bi81bg",
        "qpdYoeakhlmAxsnmxgAVFmJgUSibqb/y+Eu6GGn8pdmLf+mFGIB3jhRAxIC5KObsPMES9MW2c+oOrpOo/lCQVw==",
        "oZ19a+EOIwWVDPJ7POj14UAGBfzk9xcJMmsTUAMUy7H82sDuVCxvw9rZqdg3znFrdTH04+49zd1djhEAt0ooiA==",
        "MS=ms89904786",
        "google-site-verification=eu-3gW1JePvsGRRCaEvH17YUOTFJNofm4lnz2Pk0LTc",
        "google-site-verification=q0iWqpcfOBclAJaCeWh83v62QQ4uCgbWObQ08p37qgU",
        "al4upe6q5cl13sg4srvfivflvg",
        "v=spf1 mx ip4:63.208.226.34 ip4:204.16.32.0/22 ip4:67.134.143.0/24 ip4:216.205.243.0/24 ip4:34.85.156.5/32 ip4:35.245.108.108/32 ip4:34.86.129.193/32 ip4:34.86.134.94/32 ip4:34.85.222.234/32 ip4:34.86.176.234/32 ip4:34.86.125.212/32 ip4:34.85.224.60/32 ip4:34.86.160.49/32 ip4:35.245.64.166/32 ip4:35.188.226.11/32 ip4:34.86.208.228/32 ip4:34.85.216.144/32 ip4:35.221.22.153/32 ip4:34.86.137.108/32 ip4:34.86.51.35/32 ip4:34.150.221.40/32 ip4:34.85.216.70/32 ip4:34.86.37.191/32 ip4:34.85.214.215/32 ip4:35.236.234.82/32 ip4:34.86.161.241/32 ip4:216.32.181.16 ip4:216.178.32.0/20 ip4:168.235.224.0/24 include:_netblocks.mimecast.com -all",
        "cj65vjpq0s1v9u7vfo020c6rel"
      ],
      "CAA": null
    },
    "summary": {
      "hasIPv6": false,
      "hasMailServers": true,
      "hasSPF": true
    }
  }
}

Error Handling

The API client provides comprehensive error handling through the DnslookupAPIClientError exception. Here are some examples:

Basic Error Handling

from apiverve_dnslookup.apiClient import DnslookupAPIClient, DnslookupAPIClientError

api = DnslookupAPIClient("[YOUR_API_KEY]")

query = { "domain": "myspace.com" }

try:
    result = api.execute(query)
    print("Success!")
    print(result)
except DnslookupAPIClientError as e:
    print(f"API Error: {e.message}")
    if e.status_code:
        print(f"Status Code: {e.status_code}")
    if e.response:
        print(f"Response: {e.response}")

Handling Specific Error Types

from apiverve_dnslookup.apiClient import DnslookupAPIClient, DnslookupAPIClientError

api = DnslookupAPIClient("[YOUR_API_KEY]")

query = { "domain": "myspace.com" }

try:
    result = api.execute(query)

    # Check for successful response
    if result.get('status') == 'success':
        print("Request successful!")
        print(result.get('data'))
    else:
        print(f"API returned an error: {result.get('error')}")

except DnslookupAPIClientError as e:
    # Handle API client errors
    if e.status_code == 401:
        print("Unauthorized: Invalid API key")
    elif e.status_code == 429:
        print("Rate limit exceeded")
    elif e.status_code >= 500:
        print("Server error - please try again later")
    else:
        print(f"API error: {e.message}")
except Exception as e:
    # Handle unexpected errors
    print(f"Unexpected error: {str(e)}")

The client supports the context manager protocol for automatic resource cleanup:

from apiverve_dnslookup.apiClient import DnslookupAPIClient, DnslookupAPIClientError

query = { "domain": "myspace.com" }

# Using context manager ensures proper cleanup
with DnslookupAPIClient("[YOUR_API_KEY]") as api:
    try:
        result = api.execute(query)
        print(result)
    except DnslookupAPIClientError as e:
        print(f"Error: {e.message}")
# Session is automatically closed here

Advanced Features

Debug Mode

Enable debug logging to see detailed request and response information:

from apiverve_dnslookup.apiClient import DnslookupAPIClient

# Enable debug mode
api = DnslookupAPIClient("[YOUR_API_KEY]", debug=True)

query = { "domain": "myspace.com" }

# Debug information will be printed to console
result = api.execute(query)

Manual Session Management

If you need to manually manage the session lifecycle:

from apiverve_dnslookup.apiClient import DnslookupAPIClient

api = DnslookupAPIClient("[YOUR_API_KEY]")

query = { "domain": "myspace.com" }

try:
    result = api.execute(query)
    print(result)
finally:
    # Manually close the session when done
    api.close()

Customer Support

Need any assistance? Get in touch with Customer Support.


Updates

Stay up to date by following @apiverveHQ on Twitter.


All usage of the APIVerve website, API, and services is subject to the APIVerve Terms of Service and all legal documents and agreements.


License

Licensed under the MIT License (MIT)

Copyright (©) 2026 APIVerve, and EvlarSoft LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for apiverve-dnslookup 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for apiverve-dnslookup 1.2.1
File Size Uploaded Provenance
apiverve_dnslookup-1.2.1.tar.gz 12.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for apiverve-dnslookup 1.2.1
File Interpreter ABI Platform
apiverve_dnslookup-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.1 kB

Release files / apiverve_dnslookup-1.2.1.tar.gz

Download URL apiverve_dnslookup-1.2.1.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
cee9e19df572d9a0a8077082f503773e41f567e78441f38031652a44fa0db2b4
BLAKE2b-256 checksum
How to use checksums
8fd9f12b9de0b0614e2ed7338029fbfed6d36eb7cc2d1fc64336878df98620f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / apiverve_dnslookup-1.2.1-py3-none-any.whl

Download URL apiverve_dnslookup-1.2.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbe0ef312a799b2f5b1bd2442939ff1d3fad5de77108ad0a665a36d88e3d4441
BLAKE2b-256 checksum
How to use checksums
4d72fcaf62a3c1e285054048a7495ceaefacbd3cecb8525743d81707a77e2c94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for apiverve-dnslookup 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page