How-To Guides: DETEQTIVE DNS API
Problem-oriented: Practical guides for accomplishing specific tasks with the DETEQTIVE DNS API.
Authentication
All API requests require a Bearer token. Set it once in your shell and all examples will work:
export DETEQTIVE_TOKEN="your-api-token-here"
Table of Contents
- Searching Domains
- Finding IP Addresses
- Reverse DNS Lookups
- CIDR Block Searches
- Time-Based Filtering
- Working with Large Result Sets
- Parsing Responses
- Generating API Clients
- Integration Examples
- Performance Optimization
Searching Domains
How to search for an exact domain
Task: Find all DNS records for a specific domain.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com
Returns all record types (A, AAAA, MX, NS, TXT, etc.) for exactly example.com.
How to find all subdomains
Task: Discover all subdomains of a given domain.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/rm/example.com?limit=1000"
This returns:
example.comwww.example.commail.example.comapi.example.com- etc.
Tip: Increase limit if you expect many subdomains.
How to check if a domain exists in passive DNS
Task: Quickly check if a domain has any historical DNS records.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/em/suspicious-domain.com?limit=1"
Check the status message:
{"eof":true,"count":0,"elapsed":0.102,"error":null} // Domain not found
{"eof":true,"count":1,"elapsed":0.102,"error":null} // Domain exists
How to find typosquatting domains
Task: Find domains similar to a target (potential typosquatting).
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/fm/google.com?fuzziness=1&limit=100"
Parameters:
fuzziness=1- Allow 1 character differencefuzziness=2- Allow 2 character differences (default)fuzziness=3- Allow 3 character differences (maximum)- Higher values return more but less precise results
Use case: Security research, brand protection
How to monitor a brand name
Task: Find all domains containing a brand or keyword.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/wm/paypal?limit=500"
Returns domains like:
paypal.comsecure-paypal.compaypal-verify.compaypal-support.net
Use case: Brand monitoring, phishing detection
How to search for internationalized domain names (IDN)
Task: Search domains with international characters.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/em/münchen.de?idn"
The idn flag enables internationalized domain name support.
Finding IP Addresses
How to get all IPv4 addresses for a domain
Task: Find all IPv4 addresses a domain has resolved to.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/A
Returns only A records (IPv4 addresses).
How to get all IPv6 addresses for a domain
Task: Find all IPv6 addresses a domain has resolved to.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/AAAA
Returns only AAAA records (IPv6 addresses).
How to get both IPv4 and IPv6 addresses
Task: Get all IP addresses (both v4 and v6) for a domain.
Option 1: Make two requests and combine
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/A
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/AAAA
Option 2: Get all record types and filter
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com | \
jq -c 'select(.rrtype == "A" or .rrtype == "AAAA")'
How to track IP changes over time
Task: Find all historical IP addresses for a domain.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/em/example.com/A?limit=10000&last_seen_after=0"
Sort by first_seen to see chronological order:
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/em/example.com/A?last_seen_after=0" | \
jq -s 'map(select(.rrname)) | sort_by(.first_seen)'
Note: Results are not sorted by default - use jq or similar tools to sort client-side.
Reverse DNS Lookups
How to find all domains on an IP address
Task: Discover what domains point to a specific IP.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rdata/93.184.216.34
Returns all DNS records where this IP appears in RDATA.
How to check if an IP is hosting multiple domains
Task: Identify shared hosting or CDN usage.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rdata/104.16.132.229/A | \
jq -c 'select(.rrname)' | wc -l
If the count is high, it’s likely shared hosting or a CDN.
How to find mail servers for a domain
Task: Get MX records and then look up their IPs.
Step 1: Get MX records
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/MX
Output: {"rrname":"example.com","rrtype":"MX","rdata":"10 mail.example.com",...}
Step 2: Get IP of mail server
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/mail.example.com/A
How to find name servers for a domain
Task: Get NS records to identify authoritative name servers.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/NS
Then find their IPs:
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/ns1.example.com/A
CIDR Block Searches
How to search an entire subnet
Task: Find all domains in a /24 network.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rdata/192.0.2.0%2F24?limit=5000"
Important: URL-encode the / as %2F!
How to map network infrastructure
Task: Discover all domains hosted in an organization’s IP range.
# Search their /16 network
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rdata/203.0.113.0%2F16/A?limit=10000"
Extract unique domains:
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rdata/203.0.113.0%2F16/A" | \
jq -r 'select(.rrname) | .rrname' | sort -u
How to search IPv6 networks
Task: Search IPv6 CIDR blocks.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rdata/2001:db8::%2F32/AAAA?limit=1000"
Note: IPv6 CIDR notation also requires %2F encoding.
How to find all IPs in a range used historically
Task: Get all unique IPs from a subnet that have DNS records.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rdata/192.0.2.0%2F24/A" | \
jq -r 'select(.rdata) | .rdata' | sort -u
Time-Based Filtering
Important: By default, queries return only records with last_seen in the last 14 days. To query all historical data, set last_seen_after=0.
How to query all historical data
Task: Search all records regardless of when they were last seen.
# Override the default 14-day window
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/em/example.com/A?last_seen_after=0"
How to find recently added domains
Task: Find DNS records first seen in the last 30 days.
# Calculate timestamp for 30 days ago
THIRTY_DAYS_AGO=$(date -u -d '30 days ago' +%s)
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/rm/example.com?first_seen_after=$THIRTY_DAYS_AGO"
On macOS:
THIRTY_DAYS_AGO=$(date -u -v-30d +%s)
How to find records in a specific time window
Task: Find records first seen between two dates.
# January 2024
START=$(date -u -d '2024-01-01' +%s) # 1704067200
END=$(date -u -d '2024-01-31' +%s) # 1706659199
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/em/example.com?first_seen_after=$START&first_seen_before=$END"
How to find records that are no longer active
Task: Find records last seen before a certain date (possibly expired).
# Records last seen before 2023
CUTOFF=$(date -u -d '2023-01-01' +%s)
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/em/example.com?last_seen_before=$CUTOFF"
How to find currently active records
Task: Find records seen recently (likely still active).
# Seen in the last 7 days
RECENT=$(date -u -d '7 days ago' +%s)
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/em/example.com?last_seen_after=$RECENT"
How to compare DNS changes between time periods
Task: Identify what changed between two time periods.
Important: Results are not sorted, so we must sort them before comparison.
# Records from Q1 2024
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/em/example.com/A?first_seen_after=1704067200&first_seen_before=1711929599" | \
jq -r 'select(.rdata) | .rdata' | sort > q1.txt
# Records from Q2 2024
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/em/example.com/A?first_seen_after=1711929600&first_seen_before=1719791999" | \
jq -r 'select(.rdata) | .rdata' | sort > q2.txt
# Compare sorted results
diff q1.txt q2.txt
Working with Large Result Sets
How to handle queries with many results
Task: Efficiently retrieve large datasets.
Strategy 1: Use limit to paginate
# Get first 1000
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/rm/example.com?limit=1000" > page1.json
# Note: API doesn't support offset, so use time-based pagination instead
Strategy 2: Use time windows
# Break into monthly chunks
for month in {1..12}; do
START=$(date -u -d "2024-${month}-01" +%s)
END=$(date -u -d "2024-${month}-01 +1 month -1 second" +%s)
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/rm/example.com?first_seen_after=$START&first_seen_before=$END" > "2024-${month}.json"
done
Strategy 3: Filter by record type
# Request only the record types you need
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/rm/example.com/A
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/rm/example.com/AAAA
How to avoid query timeouts
Task: Prevent timeout errors (120 second limit).
Solutions:
- Reduce limit:
?limit=100 - Add time filters:
?first_seen_after=1704067200 - Filter by record type:
/Ainstead of all types - Use more specific searches:
eminstead ofrmorwm - Use bailiwick filter:
/rrtype/bailiwick
How to stream large results efficiently
Task: Process results as they arrive without loading everything into memory.
Python example:
import requests
import json
response = requests.get(
'https://api.deteqtive.com/api/v3/rrset/rm/example.com',
stream=True,
verify=False
)
for line in response.iter_lines():
if line:
record = json.loads(line)
if 'rrname' in record:
print(f"{record['rrname']} -> {record['rdata']}")
Bash with jq:
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/rm/example.com | \
while IFS= read -r line; do
echo "$line" | jq -c 'select(.rrname)'
done
Parsing Responses
How to extract only DNS records (skip status)
Task: Get only the data records, ignore the status line.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/A | \
jq -c 'select(.rrname)'
How to check query status
Task: Get only the status message.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/A | \
jq -c 'select(.eof)'
Output: {"eof":true,"count":5,"elapsed":0.102,"error":null}
How to count results programmatically
Task: Get the count without parsing all records.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/A | \
tail -1 | jq '.count'
How to detect errors
Task: Check if the query had errors or was truncated.
STATUS=$(curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/A | tail -1)
# Check if status line exists
if ! echo "$STATUS" | jq -e '.eof' > /dev/null 2>&1; then
echo "Warning: Response was truncated (no status line)"
elif echo "$STATUS" | jq -e '.eof == false' > /dev/null; then
echo "Error occurred: $(echo $STATUS | jq -r '.error')"
else
echo "Success: $(echo $STATUS | jq '.count') records"
fi
How to convert NDJSON to JSON array
Task: Convert the streaming format to a standard JSON array.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/A | \
jq -s 'map(select(.rrname))'
How to export to CSV
Task: Convert results to CSV format.
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/A | \
jq -r 'select(.rrname) | [.rrname, .rrtype, .rdata, .first_seen, .last_seen, .sightings] | @csv'
With headers:
echo "rrname,rrtype,rdata,first_seen,last_seen,sightings"
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/rrset/em/example.com/A | \
jq -r 'select(.rrname) | [.rrname, .rrtype, .rdata, .first_seen, .last_seen, .sightings] | @csv'
Generating API Clients
Prerequisites
To generate client libraries, you need the OpenAPI Generator tool. Install it using one of these methods:
Using npm (recommended):
npm install -g @openapitools/openapi-generator-cli
Using Docker:
# No installation needed - use docker run
Using Homebrew (macOS):
brew install openapi-generator
Download the OpenAPI Specification
First, download the OpenAPI spec from your running API server:
# Download the spec
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" https://api.deteqtive.com/api/v3/openapi/pdns.yaml > deteqtive-api-spec.yaml
# Verify it downloaded correctly
head -5 deteqtive-api-spec.yaml
How to generate a Python client
Task: Create a Python SDK for the API.
Step 1: Generate the client
# Using npx (no installation needed)
npx @openapitools/openapi-generator-cli generate \
-i deteqtive-api-spec.yaml \
-g python \
-o ./deteqtive-python-client \
--package-name deteqtive_client
# Or using Docker
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
-i /local/deteqtive-api-spec.yaml \
-g python \
-o /local/deteqtive-python-client \
--package-name deteqtive_client
Step 2: Install the generated client
cd deteqtive-python-client
pip install -e .
Step 3: Use the client
import deteqtive_client
from deteqtive_client.rest import ApiException
from deteqtive_client.api import default_api
# Configure API client
configuration = deteqtive_client.Configuration()
configuration.host = "https://api.deteqtive.com/api/v3"
configuration.verify_ssl = False
# Create API instance
with deteqtive_client.ApiClient(configuration) as api_client:
api = default_api.DefaultApi(api_client)
try:
# Search for A records
result = api.search_rr_set_with_type(
type="em",
value="google.com",
rrtype="A",
limit=10
)
# Process NDJSON response
for line in result.splitlines():
print(line)
except ApiException as e:
print(f"API Error: {e}")
How to generate a Go client
Task: Create a Go SDK for the API.
Step 1: Generate the client
# Using npx
npx @openapitools/openapi-generator-cli generate \
-i deteqtive-api-spec.yaml \
-g go \
-o ./deteqtive-go-client \
--package-name deteqtiveclient \
--git-user-id yourorg \
--git-repo-id deteqtive-go-client
# Or using Docker
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
-i /local/deteqtive-api-spec.yaml \
-g go \
-o /local/deteqtive-go-client \
--package-name deteqtiveclient
Step 2: Initialize the Go module
cd deteqtive-go-client
go mod init github.com/yourorg/deteqtive-go-client
go mod tidy
Step 3: Use the client
package main
import (
"context"
"fmt"
"crypto/tls"
"net/http"
deteqtive "github.com/yourorg/deteqtive-go-client"
)
func main() {
// Configure API client
cfg := deteqtive.NewConfiguration()
cfg.Host = "api.deteqtive.com"
cfg.Scheme = "https"
// Skip SSL verification (for development)
cfg.HTTPClient = &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
// Create API client
client := deteqtive.NewAPIClient(cfg)
// Search for A records
resp, r, err := client.DefaultApi.SearchRRSetWithType(context.Background(), "em", "google.com", "A").
Limit(10).
Execute()
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
fmt.Printf("Response: %s\n", resp)
}
How to generate a TypeScript client
Task: Create a TypeScript/JavaScript SDK.
Step 1: Generate the client
# Using npx
npx @openapitools/openapi-generator-cli generate \
-i deteqtive-api-spec.yaml \
-g typescript-axios \
-o ./deteqtive-typescript-client \
--additional-properties=npmName=deteqtive-api-client
# Or using Docker
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
-i /local/deteqtive-api-spec.yaml \
-g typescript-axios \
-o /local/deteqtive-typescript-client \
--additional-properties=npmName=deteqtive-api-client
Step 2: Install dependencies
cd deteqtive-typescript-client
npm install
npm run build
Step 3: Use the client
import { DefaultApi, Configuration } from 'deteqtive-api-client';
import * as https from 'https';
// Configure API client
const config = new Configuration({
basePath: 'https://api.deteqtive.com/api/v3'
});
// Create API instance with SSL verification disabled (for development)
const api = new DefaultApi(
config,
undefined,
new (require('axios'))({
httpsAgent: new https.Agent({
rejectUnauthorized: false
})
})
);
// Search for A records
api.searchRRSetWithType('em', 'google.com', 'A', { limit: 10 })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
How to view all available generators
Task: See what language clients you can generate.
# Using npx
npx @openapitools/openapi-generator-cli list
# Or using Docker
docker run --rm openapitools/openapi-generator-cli list
Popular generator options:
python- Python clientgo- Go clienttypescript-axios- TypeScript with Axiostypescript-fetch- TypeScript with Fetch APIjavascript- JavaScript clientjava- Java clientcsharp- C# .NET clientrust- Rust clientphp- PHP clientruby- Ruby clientkotlin- Kotlin clientswift5- Swift 5 client
Advanced Generation Options
Customize package names:
npx @openapitools/openapi-generator-cli generate \
-i deteqtive-api-spec.yaml \
-g python \
-o ./my-client \
--package-name my_custom_name \
--additional-properties=projectName=MyDeteqtiveClient
Generate with documentation:
npx @openapitools/openapi-generator-cli generate \
-i deteqtive-api-spec.yaml \
-g python \
-o ./deteqtive-client \
--package-name deteqtive_client \
--additional-properties=generateSourceCodeOnly=false
See all options for a generator:
npx @openapitools/openapi-generator-cli config-help -g python
php- PHP clientruby- Ruby client
Integration Examples
How to integrate with Python
Task: Use the API in a Python application.
import requests
import json
def query_domain(domain, record_type='A'):
"""Query DETEQTIVE DNS API for domain records"""
url = f'https://api.deteqtive.com/api/v3/rrset/em/{domain}/{record_type}'
response = requests.get(url, verify=False, stream=True)
records = []
for line in response.iter_lines():
if line:
data = json.loads(line)
if 'rrname' in data:
records.append(data)
return records
# Usage
results = query_domain('google.com', 'A')
for record in results:
print(f"{record['rrname']} -> {record['rdata']}")
How to integrate with Go
Task: Use the API in a Go application.
package main
import (
"bufio"
"encoding/json"
"fmt"
"net/http"
)
type DNSRecord struct {
RRName string `json:"rrname"`
RRType string `json:"rrtype"`
RData string `json:"rdata"`
FirstSeen string `json:"first_seen"`
LastSeen string `json:"last_seen"`
Sightings int `json:"sightings"`
}
func queryDomain(domain, rrtype string) ([]DNSRecord, error) {
url := fmt.Sprintf("https://api.deteqtive.com/api/v3/rrset/em/%s/%s", domain, rrtype)
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var records []DNSRecord
scanner := bufio.NewScanner(resp.Body)
for scanner.Scan() {
var record DNSRecord
if err := json.Unmarshal(scanner.Bytes(), &record); err == nil {
if record.RRName != "" {
records = append(records, record)
}
}
}
return records, scanner.Err()
}
func main() {
records, err := queryDomain("google.com", "A")
if err != nil {
panic(err)
}
for _, record := range records {
fmt.Printf("%s -> %s\n", record.RRName, record.RData)
}
}
How to integrate with shell scripts
Task: Use the API in bash automation.
#!/bin/bash
# check-domain.sh - Monitor domain DNS changes
DOMAIN="$1"
API_BASE="${API_BASE:-https://api.deteqtive.com/api/v3}"
check_domain() {
local domain=$1
local current_ips=$(mktemp)
local previous_ips="./previous_${domain}.txt"
# Get current IPs
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" -s "$API_BASE/rrset/em/$domain/A" | \
jq -r 'select(.rdata) | .rdata' | sort > "$current_ips"
# Compare with previous
if [ -f "$previous_ips" ]; then
if ! diff -q "$current_ips" "$previous_ips" > /dev/null; then
echo " DNS changes detected for $domain"
diff "$previous_ips" "$current_ips"
else
echo " No changes for $domain"
fi
fi
# Save current as previous
cp "$current_ips" "$previous_ips"
rm "$current_ips"
}
check_domain "$DOMAIN"
Performance Optimization
How to make queries faster
Task: Optimize query performance.
Strategies:
- Be specific with record types - Request only what you need
- Use exact match when possible -
emis faster thanrmorfm - Add time filters - Limit the time range searched
- Set appropriate limits - Don’t request more than you need
- Filter by bailiwick - Use the bailiwick path parameter
Fast query:
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/em/example.com/A?limit=10&first_seen_after=1704067200"
Slow query:
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" "https://api.deteqtive.com/api/v3/rrset/wm/example?limit=50000"
How to reduce bandwidth usage
Task: Minimize data transfer.
- Use limit - Only fetch what you need
- Request specific record types - Don’t fetch all types
- Don’t include bailiwick - Skip
?withbailiwickif not needed - Use compression -
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" --compressed
curl -H "Authorization: Bearer $DETEQTIVE_TOKEN" --compressed "https://api.deteqtive.com/api/v3/rrset/em/example.com/A?limit=100"
How to cache results
Task: Implement client-side caching.
Python example with caching:
import requests
import json
from functools import lru_cache
from datetime import datetime, timedelta
@lru_cache(maxsize=128)
def query_domain_cached(domain, rrtype, ttl_seconds=3600):
"""Cached API query"""
url = f'https://api.deteqtive.com/api/v3/rrset/em/{domain}/{rrtype}'
response = requests.get(url, verify=False)
records = []
for line in response.iter_lines():
if line:
data = json.loads(line)
if 'rrname' in data:
records.append(data)
return records
# Results are cached for 1 hour
results = query_domain_cached('google.com', 'A')
Need more details? See Reference for complete API documentation