Advanced Features¶
Advanced capabilities including async/await support, CLI usage, pagination, and result manipulation.
Async/await support¶
The SDK automatically supports async usage for high-performance applications.
import asyncio
from domaintools import API
async def main():
api = API('your_username', 'your_api_key')
# Await first, then access
result = await api.iris_enrich('domaintools.com')
for domain in result:
print(domain['domain'])
asyncio.run(main())
For more async patterns including context managers, iteration, and mixed async/sync operations, see the async examples in the GitHub repository.
CLI usage¶
Access all API endpoints from the command line.
# With credentials
domaintools iris_investigate --domains example.com -u USERNAME -k API_KEY
# Using ~/.dtapi credentials file
domaintools iris_enrich domaintools.com google.com
Create ~/.dtapi with your credentials on separate lines:
All API endpoints are available via CLI. For complete CLI documentation, examples, and troubleshooting, see the CLI Usage guide (coming soon).
Pagination¶
Handle large result sets efficiently using search_hash.
# Get initial results with a well-scoped query
response = api.iris_investigate(
redirect_domain='domaintools.com', # Returns manageable result set
limit=50
)
# Get search_hash for pagination
search_hash = response.get('search_hash')
if search_hash:
all_results = response['results']
# Iterate through remaining pages
while response.get('has_more_results'):
response = api.iris_investigate(
search_hash=search_hash,
position=response['position']
)
all_results.extend(response['results'])
Pagination best practices¶
- Use
search_hashto maintain query context - Track
positionto resume from last result - Check
has_more_resultsto determine if more pages exist - Set reasonable
max_pageslimit to avoid excessive requests - Consider the 10,000 result limit for Iris Investigate
Response formats¶
Get responses in different formats.
JSON (default)¶
# JSON format (default)
# Note: Call json() on the response, not the result object
result = api.domain_search('google')
json_data = result.response() # Already returns JSON-compatible dict
XML¶
HTML¶
Note: Format conversion only works with synchronous results, not with feeds or async operations.
Filtering and manipulation¶
Filter and transform API results.
Filter by domain age¶
from datetime import datetime, timedelta
# Filter by domain age
results = api.iris_enrich(
'example.com',
younger_than_date=datetime.now() - timedelta(days=30)
)
Filter by field presence¶
# Filter by field presence
results = api.iris_enrich(
'example.com',
include_domains_with_missing_field='registrant_name'
)
Type casting¶
# Cast to native types
risk_score = float(api.reputation('google.com'))
risk_int = int(api.reputation('google.com'))
Next steps¶
- Configuration - Rate limits, proxies, SSL, and more
- Examples - Complete code examples
- Iris Platform - Deep domain analysis
- Threat Feeds - Real-time intelligence