# dnsrobot

Python client for the [DNS Robot](https://dnsrobot.net) API — 53 free online DNS and network tools.

No API key required. Zero external dependencies.

## Install

```bash
pip install dnsrobot
```

## Quick Start

```python
from dnsrobot import DNSRobot

dr = DNSRobot()

# DNS lookup
result = dr.dns_lookup("example.com")
for ip in result["resolvedIPs"]:
    print(ip)

# WHOIS lookup
whois = dr.whois_lookup("example.com")
print(f"Registrar: {whois['registrar']['name']}")
print(f"Expires: {whois['expiresOn']}")

# SSL certificate check
ssl = dr.ssl_check("github.com")
print(f"Valid: {ssl['leafCertificate']['isValid']}")
print(f"Days left: {ssl['leafCertificate']['daysToExpire']}")
```

## Available Methods

| Method | Description | Tool Page |
|--------|-------------|-----------|
| `dns_lookup(domain)` | DNS record lookup (A, AAAA, MX, TXT, etc.) | [DNS Lookup](https://dnsrobot.net/dns-lookup) |
| `whois_lookup(domain)` | WHOIS registration data | [WHOIS Lookup](https://dnsrobot.net/whois-lookup) |
| `ssl_check(domain)` | SSL/TLS certificate check | [SSL Checker](https://dnsrobot.net/ssl-checker) |
| `spf_check(domain)` | SPF record validation | [SPF Checker](https://dnsrobot.net/spf-checker) |
| `dkim_check(domain)` | DKIM record check | [DKIM Checker](https://dnsrobot.net/dkim-checker) |
| `dmarc_check(domain)` | DMARC record validation | [DMARC Checker](https://dnsrobot.net/dmarc-checker) |
| `mx_lookup(domain)` | MX record lookup | [MX Lookup](https://dnsrobot.net/mx-lookup) |
| `ns_lookup(domain)` | Nameserver lookup | [NS Lookup](https://dnsrobot.net/ns-lookup) |
| `ip_lookup(ip)` | IP geolocation | [IP Lookup](https://dnsrobot.net/ip-lookup) |
| `http_headers(url)` | HTTP header analysis | [HTTP Headers](https://dnsrobot.net/http-headers) |
| `port_check(host, port)` | TCP port check | [Port Checker](https://dnsrobot.net/port-checker) |

## Examples

### Email authentication check

```python
dr = DNSRobot()

spf = dr.spf_check("gmail.com")
print(f"SPF: {spf['grade']} ({spf['score']}/100)")

dkim = dr.dkim_check("gmail.com", selector="google")
print(f"DKIM found: {dkim['found']}")

dmarc = dr.dmarc_check("gmail.com")
print(f"DMARC policy: {dmarc['policy']}")
```

### MX and NS records

```python
dr = DNSRobot()

mx = dr.mx_lookup("gmail.com")
for rec in mx["mxRecords"]:
    print(f"{rec['priority']} {rec['exchange']}")

ns = dr.ns_lookup("google.com")
for srv in ns["nameservers"]:
    print(srv["nameserver"])
```

### Port scanning

```python
dr = DNSRobot()

for port in [22, 80, 443, 8080]:
    result = dr.port_check("example.com", port)
    print(f"Port {port}: {result['status']}")
```

## Error Handling

```python
from dnsrobot import DNSRobot

dr = DNSRobot()

try:
    result = dr.dns_lookup("example.com")
except RuntimeError as e:
    print(f"API error: {e}")
except ValueError as e:
    print(f"Invalid input: {e}")
```

## Links

- **Homepage**: [dnsrobot.net](https://dnsrobot.net)
- **DNS Lookup**: [dnsrobot.net/dns-lookup](https://dnsrobot.net/dns-lookup)
- **SSL Checker**: [dnsrobot.net/ssl-checker](https://dnsrobot.net/ssl-checker)
- **WHOIS Lookup**: [dnsrobot.net/whois-lookup](https://dnsrobot.net/whois-lookup)
- **All 53 Tools**: [dnsrobot.net/all-tools](https://dnsrobot.net/all-tools)
