Skip to content

Terramoto/DNS-API

Repository files navigation

DNS Lookup API

A FastAPI-based REST API for retrieving DNS records and IP geolocation information for any domain. I did this for IT work, it helps find domains details without having to go to other websites or use tools.

Browser Extension

A Violentmonkey userscript is available that allows you to select domains or IPs on any webpage and retrieve DNS information through this API service.

Features

This API provides lookup capabilities for:

  • Nameservers (NS records) with IP addresses
  • MX records (Mail exchange) with IP addresses
  • A records (IPv4 addresses) with provider and location information
  • TXT records
  • www CNAME record with IP addresses
  • IP provider and location information for all IP addresses
  • PTR record for the A record IP

Requirements

  • Python 3.7+
  • FastAPI
  • dnspython
  • requests

Installation

  1. Clone this repository
  2. Install the required packages:
    pip install -r requirements.txt

Usage

  1. Start the API server:

    python main.py
  2. The API will be available at http://localhost:8000

  3. Access the API documentation at http://localhost:8000/docs

API Endpoints

GET /

Returns a welcome message and basic API information.

GET /dns-lookup/{domain}

Retrieves all DNS records for the specified domain.

Path Parameters:

  • domain (string, required): The domain name to look up

Response:

{
  "domain": "example.com",
  "records": {
    "NS": [
      {
        "nameserver": "a.iana-servers.net.",
        "ips": ["199.43.135.53"]
      },
      {
        "nameserver": "b.iana-servers.net.",
        "ips": ["199.43.133.53"]
      }
    ],
    "MX": [
      {
        "priority": 0,
        "mail_server": ".",
        "ips": [],
        "ip_info": []
      }
    ],
    "A": ["23.192.228.80"],
    "TXT": ["\"v=spf1 -all\""],
    "CNAME_WWW": [
      {
        "cname": "www.example.com-v4.edgesuite.net.",
        "ips": ["2.23.103.8", "2.23.103.24"]
      }
    ],
    "A_IP_Info": [
      {
        "ip": "23.192.228.80",
        "provider": "AS20940 Akamai International B.V.",
        "location": "San Jose, California, US",
        "coordinates": {
          "latitude": "37.3394",
          "longitude": "-121.8950"
        }
      }
    ]
  }
}

Error Handling

The API will return appropriate HTTP status codes and error messages for invalid domains or DNS lookup failures.

Implementation Details

The API uses:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published