# DNS Records Lookup: MX, SPF, DMARC & More (`ailu_studio/dns-records-lookup`) Actor

Look up DNS records and email-authentication signals in bulk. Export A, AAAA, MX, TXT, CAA, SPF and DMARC data for domain checks.

- **URL**: https://apify.com/ailu_studio/dns-records-lookup.md
- **Developed by:** [Ailu Studio](https://apify.com/ailu_studio) (community)
- **Categories:** Developer tools, Lead generation, SEO tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 dns result rows

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### DNS Records Lookup: MX, SPF, DMARC & More

Look up DNS records and email-authentication signals in bulk. Export A, AAAA, MX, TXT, CAA, SPF and DMARC data for domain checks.

### Try a small sample

Paste this into the Input JSON editor, run the Actor, then inspect its dataset. Export JSON or CSV from the dataset, or use the API tab for authenticated integration examples.

```json
{
  "domains": [
    "apify.com"
  ],
  "recordTypes": [
    "A",
    "MX",
    "TXT"
  ],
  "includeEmailAuth": true,
  "maxItems": 10
}
```

### Workflow example

Review mail-routing and authentication records before configuring a domain. A present MX record does not verify an individual mailbox.

```json
{
  "domains": [
    "apify.com",
    "github.com"
  ],
  "recordTypes": [
    "MX",
    "TXT"
  ],
  "includeEmailAuth": true,
  "maxItems": 10
}
```

Examples show supported inputs, not guaranteed result counts. Public sources and filters can produce fewer rows or zero rows. Check the run log and any summary/error records before treating the output as complete.

For recurring use, save the input as an Apify Task and schedule sequential runs. Export results to your own spreadsheet, database, n8n or Make workflow. Scheduling does not add stateful tracking to Actors that only return snapshots. Keep API credentials in environment variables.

### Related workflow

[Email Validator: Syntax, MX & Disposable Checks](https://apify.com/ailu_studio/email-validator) can complement this Actor. It runs separately and has its own price and input requirements.

### Detailed reference

### Bulk DNS Lookup: A, AAAA, MX, TXT, NS, CNAME, SOA, CAA, SPF, DMARC, DKIM

Look up DNS records for any list of domains in one run and get clean JSON: A and AAAA addresses, MX mail servers, NS, TXT, CNAME, SOA and CAA, plus a parsed SPF record (includes, ip4/ip6, `all` qualifier, lookup count), the DMARC policy (p, sp, pct, rua, ruf), optional DKIM selector discovery, a mail-provider guess from the MX hosts (Google Workspace, Microsoft 365, Zoho, Proton, Fastmail, Mimecast, Proofpoint and more) and the DNSSEC validation flag. Queries go over DNS-over-HTTPS to Cloudflare (`cloudflare-dns.com`) or Google Public DNS (`dns.google`), with automatic fallback to the other resolver. No API key. Compared with other DNS lookup Actors in the Store, this one returns SPF, DMARC and DKIM as structured fields next to the raw records, falls back to the organizational domain for DMARC, and offers both one row per domain and one row per record (flatten). Resolver errors are free rows.

### Use cases

- Email deliverability audits: check SPF, DMARC policy and DKIM selectors for a list of client or prospect domains.
- Lead enrichment: tag companies by mail provider (Google Workspace vs Microsoft 365 vs self-hosted) from their MX records.
- Domain portfolio and migration checks: verify A/AAAA, NS, CNAME and CAA records before and after a DNS change.
- Security reviews: spot domains without DMARC, with `+all` SPF, missing CAA or without DNSSEC validation.
- Feed DNS data into spreadsheets, AI agents or monitoring pipelines without running your own resolver.

### Input

| Field | Default | Meaning |
|---|---|---|
| `domains` | `["apify.com", "github.com", "python.org"]` | Domains or host names. URLs are accepted (scheme, path, port stripped); sub-domains are kept as given; IDNs are converted to punycode. |
| `recordTypes` | `["A","AAAA","MX","NS","TXT","CNAME","SOA","CAA"]` | Record types to query. Unsupported types are ignored and reported in the run summary. |
| `includeEmailAuth` | `true` | Also query `_dmarc.<domain>` and parse SPF and DMARC into structured fields. |
| `checkDkimSelectors` | `false` | Probe the selectors `google`, `selector1`, `selector2`, `k1`, `default`, `s1`, `s2` at `<selector>._domainkey.<domain>`. |
| `resolver` | `cloudflare` | Resolver asked first (`cloudflare` or `google`); the other is used when a query fails. |
| `flatten` | `false` | `false`: one row per domain. `true`: one row per DNS record. |
| `maxConcurrency` | `8` | Domains resolved in parallel (requests per resolver stay spaced at least 250 ms apart). |
| `maxItems` | `500` | Maximum charged rows (domains, or records when flattened). |

Example input:

```json
{ "domains": ["stripe.com", "https://www.notion.so/pricing", "example.org"], "checkDkimSelectors": true, "maxItems": 1000 }
```

### Output

| Field | Type | Meaning |
|---|---|---|
| `id` | string | `dns:<domain>` (flatten: `dns:<domain>:<name>:<type>:<hash>`). |
| `domain`, `inputDomain` | string | Queried name and cleaned input. |
| `rcode` | string | null | `NOERROR`, `NXDOMAIN` (name does not exist), `SERVFAIL`, `REFUSED`. |
| `a`, `aaaa`, `ns`, `txt` | string\[] | null | Record values; `null` when that type was not requested. |
| `mx` | object\[] | null | `[{priority, host}]` sorted by priority. |
| `cname` | string | null | Alias target. |
| `soa` | object | null | `{mname, rname, serial, refresh, retry, expire, minimumTtl}`. |
| `caa` | object\[] | null | `[{flags, tag, value}]`. |
| `spf` | object | null | `{raw, includes, ip4, ip6, all, redirect, dnsLookups, recordCount, valid}`. |
| `dmarc` | object | null | `{raw, recordName, policy, subdomainPolicy, pct, rua, ruf, adkim, aspf}`. |
| `dkimSelectorsFound` | string\[] | null | Selectors that publish a DKIM key (when enabled). |
| `hasMx`, `mailProvider` | boolean, string | Mail setup summary from MX. |
| `dnssecAd` | boolean | null | Resolver's Authenticated Data flag (DNSSEC-validated answer). |
| `queriedTypes`, `resolver`, `error`, `fetchedAt` | | Lookup metadata. |

Flatten rows carry `domain, name, type, ttl, data, priority, target, caaTag, caaValue, purpose (spf/dmarc/dkim), rcode, dnssecAd, resolver, error, fetchedAt`.

Sample row (TXT and AAAA shortened):

```json
{
  "id": "dns:python.org", "domain": "python.org", "inputDomain": "python.org", "rcode": "NOERROR",
  "a": ["151.101.192.223", "151.101.128.223", "151.101.64.223", "151.101.0.223"], "aaaa": ["2a04:4e42:400::223", "2a04:4e42::223"],
  "mx": [{ "priority": 50, "host": "mail.python.org" }],
  "ns": ["ns-1134.awsdns-13.org", "ns-2046.awsdns-63.co.uk", "ns-484.awsdns-60.com", "ns-981.awsdns-58.net"],
  "txt": ["888acb5757da46ad83b7e341ec544c64", "MS=73147F1EC0843C399CF17F586EC6B8EAF8C57961"], "cname": null,
  "soa": { "mname": "ns-2046.awsdns-63.co.uk", "rname": "awsdns-hostmaster.amazon.com", "serial": 1, "refresh": 7200, "retry": 900, "expire": 1209600, "minimumTtl": 86400 },
  "caa": [],
  "spf": { "raw": "v=spf1 mx ip4:188.166.95.178/32 ip6:2a03:b0c0:2:d0::71:1 include:stspg-customer.com include:_spf.google.com include:mailgun.org ~all", "includes": ["stspg-customer.com", "_spf.google.com", "mailgun.org"], "ip4": ["188.166.95.178/32"], "ip6": ["2a03:b0c0:2:d0::71:1"], "all": "~all", "redirect": null, "dnsLookups": 4, "recordCount": 1, "valid": true },
  "dmarc": { "raw": "v=DMARC1; p=none; pct=100; rua=mailto:re+shb8ybr70a3@dmarc.postmarkapp.com; sp=none; aspf=r;", "recordName": "_dmarc.python.org", "policy": "none", "subdomainPolicy": "none", "pct": 100, "rua": ["mailto:re+shb8ybr70a3@dmarc.postmarkapp.com"], "ruf": [], "adkim": null, "aspf": "r" },
  "dkimSelectorsFound": null, "hasMx": true, "mailProvider": "Self-hosted / other", "dnssecAd": false,
  "queriedTypes": ["A", "AAAA", "MX", "NS", "TXT", "CNAME", "SOA", "CAA"], "resolver": "cloudflare", "error": null,
  "fetchedAt": "2026-11-04T11:28:53.848Z"
}
```

The run summary (domains resolved, NXDOMAIN count, failures, errors, request count) is stored in the `OUTPUT` record of the default key-value store.

### How it works and limits

- Each record type is one DoH JSON request (`application/dns-json`). With default settings a domain needs 9 requests (8 types + `_dmarc`), 16 with DKIM selectors. If the first type answers NXDOMAIN, the remaining queries for that domain are skipped.
- Politeness: requests to each resolver are spaced at least 250 ms apart and 429/5xx responses are retried with backoff, so expect roughly 25 domains per minute with all 8 types. Ask only the record types you need for large lists.
- Answers come from a public recursive resolver and reflect its cache (TTL), not necessarily the authoritative server at this second. Propagation checks across many resolvers are not covered.
- DMARC is looked up at `_dmarc.<host>` and, when absent, at the organizational domain (last two labels, or three for common ccTLD suffixes such as `co.uk`). `spf.dnsLookups` counts top-level terms only; nested includes are not expanded.
- DKIM can only be checked for known selector names; there is no way to list all selectors of a domain via DNS.
- `mailProvider` is a guess from MX host names; custom gateways in front of a provider show the gateway (e.g. Proofpoint).
- Not covered: PTR/reverse DNS, SRV, DNSKEY/DS records, zone transfers, WHOIS/RDAP data, historical DNS.

### Pricing

Pay per result: **$2.00 per 1,000 rows** (`result` event). Platform usage is billed separately by Apify. Removed/free rows are not charged.

A row is one domain (or one record in flatten mode). NXDOMAIN answers are valid results and are charged; rows for invalid names and resolver or network errors (including SERVFAIL for every type) are free.

### Legal

Not affiliated with Cloudflare or Google. Uses the public Cloudflare DNS-over-HTTPS JSON API and Google Public DNS JSON API only. Data licence/terms: https://developers.cloudflare.com/1.1.1.1/privacy/public-dns-resolver/ and https://developers.google.com/speed/public-dns/terms. DNS records are public by design; use the results lawfully.

### FAQ

**Why is `txt` null although SPF is filled?** You removed `TXT` from `recordTypes` but kept `includeEmailAuth`; the TXT query is still made to parse SPF, but the raw TXT list is only returned when requested.

**What does `dnssecAd: false` mean?** The resolver did not validate the answer with DNSSEC, usually because the zone is not signed. `true` means the answer was DNSSEC-validated by the resolver.

**Is an NXDOMAIN row charged?** Yes, "this name does not exist" is a valid lookup result. Only rows where the resolver could not be reached or gave no usable answer are free.

**Can I check thousands of domains?** Yes, set `maxItems` accordingly. At the polite request rate 1,000 domains with all types take about 40 minutes; with only `MX` and `includeEmailAuth` (3 requests per domain) about 13 minutes.

**Which resolver should I pick?** Both return the same data for almost all domains. Cloudflare is the default; Google is used automatically when Cloudflare fails for a query.

# Actor input Schema

## `domains` (type: `array`):

Domains or host names to look up, one per line, e.g. "apify.com" or "www.github.com". URLs are accepted: scheme, path and port are stripped. Sub-domains are kept as given. Duplicates are looked up once.

## `recordTypes` (type: `array`):

DNS record types to query for each domain. Supported: A, AAAA, MX, NS, TXT, CNAME, SOA, CAA. Fewer types make large lists faster.

## `includeEmailAuth` (type: `boolean`):

Also query \_dmarc.<domain> and parse the SPF record (includes, ip4/ip6, all qualifier, lookup count) and the DMARC policy (p, sp, pct, rua, ruf) into structured fields.

## `checkDkimSelectors` (type: `boolean`):

Also probe the DKIM selectors google, selector1, selector2, k1, default, s1 and s2 at <selector>.\_domainkey.<domain> and list the ones that publish a key. Adds 7 queries per domain.

## `resolver` (type: `string`):

Public DNS-over-HTTPS resolver to ask first. If it fails for a query (HTTP or network error), the other one is tried automatically.

## `flatten` (type: `boolean`):

Off: one row per domain with all record types grouped. On: one row per DNS record (name, type, TTL, data), which is easier to filter in spreadsheets. Each row is billed.

## `maxConcurrency` (type: `integer`):

How many domains are resolved at the same time. Requests to each resolver are still spaced at least 250 ms apart.

## `maxItems` (type: `integer`):

Upper limit on charged rows (domains, or records in flatten mode). Free error rows do not count. Lookups stop once the limit is reached.

## Actor input object example

```json
{
  "domains": [
    "apify.com",
    "github.com",
    "python.org"
  ],
  "recordTypes": [
    "A",
    "AAAA",
    "MX",
    "NS",
    "TXT",
    "CNAME",
    "SOA",
    "CAA"
  ],
  "includeEmailAuth": true,
  "checkDkimSelectors": false,
  "resolver": "cloudflare",
  "flatten": false,
  "maxConcurrency": 8,
  "maxItems": 500
}
```

# Actor output Schema

## `results` (type: `string`):

All rows in the default dataset.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "domains": [
        "apify.com",
        "github.com",
        "python.org"
    ],
    "recordTypes": [
        "A",
        "AAAA",
        "MX",
        "NS",
        "TXT",
        "CNAME",
        "SOA",
        "CAA"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ailu_studio/dns-records-lookup").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "domains": [
        "apify.com",
        "github.com",
        "python.org",
    ],
    "recordTypes": [
        "A",
        "AAAA",
        "MX",
        "NS",
        "TXT",
        "CNAME",
        "SOA",
        "CAA",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("ailu_studio/dns-records-lookup").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "domains": [
    "apify.com",
    "github.com",
    "python.org"
  ],
  "recordTypes": [
    "A",
    "AAAA",
    "MX",
    "NS",
    "TXT",
    "CNAME",
    "SOA",
    "CAA"
  ]
}' |
apify call ailu_studio/dns-records-lookup --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ailu_studio/dns-records-lookup"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/6cgfRB82gd1ysJUcs/builds/0NKPHe5obmwGJN697/openapi.json
