Examples

Practical, copy-pasteable recipes for the Validin Python SDK. Each example assumes you've installed the SDK and setup your API key in the environment.

pip install validin-sdk
validin setup        # or: export VALIDIN_API_KEY="your_api_key_here"
from validin import Client

client = Client()

1. Pull DNS history for a domain

results = client.dns_history("example.com", limit=100, lookback=90)

print(f"{results.records_returned} records (limited={results.limited})")
for record in results:
    print(f"{record.type:6} {record.key} -> {record.value}")
    print(f"       first {record.first_seen}  last {record.last_seen}")

2. Find every IP a domain has resolved to

records = client.dns_history("example.com", lookback=365)

a_records = {
    str(r.value)
    for r in records
    if r.type in ("A", "AAAA") and r.value is not None
}
print(sorted(a_records))

3. Reverse the pivot: what domains point at an IP

records = client.dns_history("8.8.8.8", lookback=90)

for r in records:
    print(r.type, r.key, "->", r.value)

For reverse-DNS / PTR data specifically:

for r in client.ptr_history("8.8.8.8", lookback=90):
    print(r.value)

4. Check a domain's or IP's reputation

result = client.enrich("suspicious-domain.com")
enriched = result[0]

print("score:  ", enriched.score)
print("verdict:", enriched.verdict)

for ann in enriched.annotations:
    print(f"  [{ann.category}] {ann.title}: {ann.description}")

Quick "is this bad?" gate:

def is_flagged(indicator: str) -> bool:
    enriched = client.enrich(indicator)[0]
    return (enriched.verdict or "").lower() in {"malicious", "suspicious"}

print(is_flagged("example.com"))

5. Enrich a whole list of indicators (bulk)

indicators = ["example.com", "8.8.8.8", "test.org"]

results = client.enrich(indicators)        # returns a nested ResultSet

for child in results:                      # one child ResultSet per indicator
    enriched = child[0]
    print(enriched.value, "->", enriched.verdict, enriched.score)

Flatten and de-duplicate across all indicators with .aggregate():

flat = client.dns_history(["a.com", "b.com", "c.com"]).aggregate()
print(len(flat), "unique records across all three domains")

6. Inspect crawled HTTP responses

results = client.host_responses("example.com", limit=10, annotate=True)

for record in results:
    resp = record.value
    print(f"{resp.scheme}://{resp.host}:{resp.port}  [{resp.ip}]")
    print(f"  title:     {resp.title}")
    print(f"  body sha1: {resp.body_hash}")
    print(f"  favicon:   {resp.favicon_hash}")

7. Fetch the captured HTML of a page

# Grab the most recent response, then fetch its stored HTML body
record = client.host_responses("example.com", limit=1)[0]
content = client.fetch_content(record.value)   # pass the HostResponse directly

html = content.html()
print(len(html), "bytes of HTML")

for resource in content.resources:
    print(resource.type, resource.url)

You can also fetch by hash directly:

content = client.fetch_content("da39a3ee5e6b4b0d3255bfef95601890afd80709")

8. List certificates for a domain (and its subdomains)

results = client.certificates("example.com", wildcard=True, lookback=180)

for record in results:
    print(record.common_name)
    print("  issuer SHA-256:", record.fingerprint_sha256)
    print("  SANs:", ", ".join(record.domains))

Collect every unique subject-alt-name seen across all certs:

sans = set()
for record in client.certificates("example.com", wildcard=True):
    sans.update(record.domains)
print(sorted(sans))

9. Track a domain's registration / WHOIS history

results = client.registration_history("example.com", lookback=730)

for record in results:
    reg = record.value
    print("registrar: ", record.registrar)
    print("protocol:  ", reg.protocol)            # WHOIS or RDAP
    print("nameserver:", [ns.value for ns in reg.nameservers])
    print("expires:   ", reg.expires)

10. Hunt for lookalike / typosquat domains

# Similarity-based, around a brand domain
hits = client.lookalikes("example.com", similarity=2, depth="fqdns", limit=200)

for hit in hits:
    print(f"{hit.key}  (matched '{hit.match}', similarity {hit.similarity})")

Regex-based hunting (wrap the pattern in slashes):

hits = client.lookalikes(r"/exampl[e3]-(secure|login|verify)/")
for hit in hits:
    print(hit.key)

11. Run a live scan and read the results

# Blocks until the scan finishes, then returns the crawl results
results = client.scan("example.com", countries=["US"])

for record in results:
    resp = record.response
    print(resp.host, resp.ip, resp.title)
    print("  JARM:", resp.jarm, "| JA4X:", resp.ja4x_fingerprint)

Fire-and-poll if you'd rather not block:

job = client.scan("example.com", wait=False)
print("started scan", job.scan_id)

# ... do other work ...

job.wait(timeout=180)
if job.succeeded:
    for record in job.crawl_results():
        print(record.response.title)
else:
    print("scan ended with status:", job.status)

12. Pull YARA rule matches from a project

# Auto-paginates through every page
matches = client.yara_matches(project_id="<uuid>", rule_id="<rule-id>")

print(f"{len(matches)} matches")
for m in matches:
    print(m.host or m.ip, "-", m.title, "-", m.hash)

Filter by date and grab one page at a time:

matches = client.yara_matches(
    project_id="<uuid>",
    rule_id="<rule-id>",
    page=0,
    page_size=250,
    first_seen="2024-01-01",
)

13. Add findings to a project

iocs = ["evil-login.com", "1.2.3.4", "5.6.7.8"]

client.add_to_project(
    "<project-uuid>",
    iocs,
    note="Phishing infra discovered 2024-06-14",
    tags=["phishing", "campaign-x"],
)

The SDK sorts each indicator into the right bucket (domain / IP / hash / raw)
automatically.


14. Export results to CSV

import csv

results = client.dns_history("example.com", lookback=365)
rows = results.to_rows()

with open("dns_history.csv", "w", newline="") as fh:
    writer = csv.DictWriter(fh, fieldnames=rows[0].keys())
    writer.writeheader()
    writer.writerows(rows)

to_rows() works on the results of any query method, so the same pattern
exports certificates, host responses, registration history, and so on.


15. Export to JSON

import json

results = client.certificates("example.com", wildcard=True, lookback=90)
with open("certs.json", "w") as fh:
    json.dump(results.to_rows(), fh, indent=2)

16. Robust error handling

from validin import ApiError, ValidinError

try:
    results = client.dns_history("example.com")
except ApiError as exc:
    if exc.status_code == 401:
        print("Bad or missing API key")
    elif exc.status_code == 429:
        print("Rate limited — slow down")
    else:
        print(f"API error {exc.status_code}: {exc.message}")
except ValidinError as exc:
    print("SDK error:", exc)

17. A small investigation pipeline

Tie several calls together: start from one domain, check its reputation, pull
its current IPs, and enrich those too.

from validin import Client

client = Client()
domain = "suspicious-domain.com"

# 1. Reputation of the domain
rep = client.enrich(domain)[0]
print(f"{domain}: {rep.verdict} (score {rep.score})")

# 2. Current resolutions
ips = sorted({
    str(r.value)
    for r in client.dns_history(domain, lookback=30)
    if r.type == "A" and r.value is not None
})
print("resolves to:", ips)

# 3. Reputation of each IP (bulk)
if ips:
    for child in client.enrich(ips):
        ip_rep = child[0]
        print(f"  {ip_rep.value}: {ip_rep.verdict}")

# 4. Look for typosquats of the domain
for hit in client.lookalikes(domain, similarity=2, limit=50):
    print("  lookalike:", hit.key)

Did this page help you?