Skip to main content

viewdns

viewdns

CLI and Python library for every ViewDNS.info API endpoint

PyPI Version Python Versions License CI Status Coverage

GitHub Stars GitHub Issues Buy Me a Coffee


Overview

viewdns is a Python toolkit that covers every endpoint of the ViewDNS.info API — reverse IP, WHOIS, DNS records, port scanning, IP geolocation, spam-database lookups, and more. It works both as a command-line tool and as an importable library, prints readable tables by default, and also speaks JSON, TOON, and raw XML. The HTTP layer uses only the Python standard library.

Key Features

Feature Description
All 23 endpoints Complete coverage of the ViewDNS.info API from a single interface
Table by default Human-readable output rendered with prettytable
Multi-format table, json, toon (Token-Oriented Object Notation), and raw xml
CLI + Library Use as a command-line tool or a typed Python package
File downloads Streams the gzip-compressed Newly Registered Domains feed as raw bytes
Typed & tested Fully type-checked (mypy --strict), 100% test coverage, no mocks
Zero-dependency HTTP Transport built on http.client from the standard library

Supported Outputs

Structured data   table (prettytable), json, toon
Passthrough       xml (raw API payload)
File feeds        newly-registered -> gzip bytes (redirect to a file)
Errors            API errors rendered as a key/value table

Installation

From PyPI (Recommended)

pip install viewdns

Set your API key once (get one from your ViewDNS.info account):

export VIEWDNS=your_api_key

From Source

git clone https://github.com/seifreed/viewdns.git
cd viewdns
python3 -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -e ".[dev]"

Quick Start

# Reverse IP lookup (table by default)
viewdns reverse-ip --host google.com

# WHOIS for a domain
viewdns whois --domain example.com

# DNS records of a given type
viewdns dns-record --domain example.com --recordtype MX

# Your account balance
viewdns account --action balance

Usage

Command Line Interface

# JSON output
viewdns ip-location --ip 8.8.8.8 --format json

# TOON output
viewdns dns-record --domain google.com --recordtype A --format toon

# Raw XML from the API
viewdns whois --domain example.com --format xml

# Download the gzip Newly Registered Domains feed
viewdns newly-registered --date 2026-08-14 > nrd.txt.gz

--format selects the output (table default, json, toon, xml); --apikey overrides $VIEWDNS; --timeout sets the request timeout in seconds. Global options work before or after the subcommand. Run viewdns --help for the full command list.

Endpoints

Command API path Required Optional
abuse-contact abuselookup domain
account account action
chinese-firewall chinesefirewall domain
dns-propagation propagation domain
dns-record dnsrecord domain recordtype
free-email freeemail domain
http-headers httpheaders domain
ip-history iphistory domain
ip-location iplocation ip
iran-firewall iranfirewall siteurl
mac-lookup maclookup mac
newly-registered nrd date type
ping ping/v2 host
port-scan portscan host
reverse-dns reversedns ip
reverse-ip reverseip host page
reverse-mx reversemx mx page
reverse-ns reversens ns page
reverse-whois reversewhois q page
spam-db spamdblookup ip
subdomains subdomains domain
traceroute traceroute domain
whois whois/v2 domain

Format Flags

Option Description
--format table Human-readable tables (default)
--format json Pretty-printed JSON
--format toon Token-Oriented Object Notation
--format xml Raw XML payload from the API
--apikey <key> API key (defaults to $VIEWDNS)
--timeout <seconds> Request timeout

Python Library

Basic Usage

from viewdns import ViewDNSClient

client = ViewDNSClient("your_api_key")
data = client.request("reverse-ip", host="google.com")
whois = client.request("whois", domain="example.com")
xml = client.request("ip-location", ip="9.9.9.9", output="xml")

request returns parsed JSON (a dict) by default, the decoded text for output="xml", and raw bytes for endpoints that serve a downloadable file. Transport failures and unparseable responses raise ViewDNSError; invalid arguments raise ValueError. API-level problems (bad key, exhausted quota, missing subscription) come back inside the response payload.

Downloading a File Feed

gz = client.request("newly-registered", date="2026-08-14")  # bytes
with open("nrd.txt.gz", "wb") as f:
    f.write(gz)

Rendering Responses

from viewdns import render

print(render(data, "table"))  # or "json" / "toon"

Requirements

  • Python 3.14+
  • Runtime dependencies: prettytable, python-toon
  • See pyproject.toml for the full list and dev extras

Development

pip install -e ".[dev]"
black --check . && ruff check . && mypy .
bandit -r viewdns && pip-audit
pytest

Tests run real code against the live API (no mocks) and require $VIEWDNS.


Contributing

Contributions are welcome.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Support the Project

If this project is useful in your workflows, you can support development:

Buy Me A Coffee

License

This project is licensed under the MIT license. See LICENSE.

Attribution


Built for practical DNS/OSINT research and security automation

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

viewdns-1.0.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viewdns-1.0.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file viewdns-1.0.0.tar.gz.

File metadata

  • Download URL: viewdns-1.0.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for viewdns-1.0.0.tar.gz
Algorithm Hash digest
SHA256 38c8de0bd13428faee6f0904bfdf836c46923aa64d19d3ecf433931454428f29
MD5 b7a091b79340e936ec840e780137a036
BLAKE2b-256 21e82bbf7716ad22971479f55f57986ef0c880f68b821cff4e31883c4274b3bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for viewdns-1.0.0.tar.gz:

Publisher: release.yml on seifreed/viewdns

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file viewdns-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: viewdns-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for viewdns-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60131f02181348e7bf274c204db55d15216767fdb6dcc3eb528cf8ece589c5a0
MD5 0155c9c4f56f2c3e25901334863d29c2
BLAKE2b-256 8b7aad4797ccf8b589aaef97024ce154c8828536cee48132ea678865d47676df

See more details on using hashes here.

Provenance

The following attestation bundles were made for viewdns-1.0.0-py3-none-any.whl:

Publisher: release.yml on seifreed/viewdns

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page