The NetAPI “Domain API v2” allows you to fetch various domain datasets, perform lookups, and download CSV data. The API is entirely driven by HTTP GET requests, and the token is passed as a query parameter named token.
Below is a concise guide to using it in Python.
Example: Download Domain List Dataset
------------------
import requests
import gzip
import io
API_TOKEN = "YOUR_TOKEN"
ZONE = "com"
params = {
"method": "download",
"token": API_TOKEN,
"zone_tld": ZONE,
"dataset_type": "dataset", # or "list"
"filter_type": "active", # or "new"
# optionally: "format": "plain"
}
resp = requests.get("https://netapi.com/api2/", params=params)
if resp.status_code == 200:
data = resp.content
# Usually compressed .gz
try:
plain = gzip.decompress(data).decode("utf-8")
except OSError:
plain = data.decode("utf-8")
# Now `plain` has CSV content
print(plain[:500])
else:
print("Error:", resp.status_code, resp.text)
------------------
Caveats & Tips
- These datasets (especially for big zones like .com) are huge. Be careful with memory and bandwidth.
- Use the compressed (.gz) default format. Only request format=plain if you truly need uncompressed data.
- Always include the token parameter, else you’ll get 401 errors.
Because responses are CSV (not JSON), you’ll need to parse them manually or convert to JSON after fetching.
