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.
A Violentmonkey userscript is available that allows you to select domains or IPs on any webpage and retrieve DNS information through this API service.
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
- Python 3.7+
- FastAPI
- dnspython
- requests
- Clone this repository
- Install the required packages:
pip install -r requirements.txt
-
Start the API server:
python main.py
-
The API will be available at
http://localhost:8000 -
Access the API documentation at
http://localhost:8000/docs
Returns a welcome message and basic API information.
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"
}
}
]
}
}The API will return appropriate HTTP status codes and error messages for invalid domains or DNS lookup failures.
The API uses:
dnspythonfor DNS record lookupsMaxMind GeoLite2databases for IP geolocation data ( https://github.com/P3TERX/GeoLite.mmdb )FastAPIfor the web framework