# Dns Records Lookup (`eichan/dns-records-lookup`) Actor

- **URL**: https://apify.com/eichan/dns-records-lookup.md
- **Developed by:** [Eichan Jolly](https://apify.com/eichan) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.01 / actor start

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

Look up the **A, AAAA, CNAME, MX, TXT, and NS** records of **one public domain**. It uses Cloudflare's public DNS-over-HTTPS JSON endpoint (`https://cloudflare-dns.com/dns-query`) and Python's standard library. No DNS account, login, or API key is needed.

### Who it is for

Developers, website owners, and support teams who want a small, structured snapshot of commonly used DNS records. You do not need to know DNS commands.

### Input

Enter a domain name **without** `https://`, a slash, or a path. The prefilled example is the real public domain `example.com`.

```json
{"domain":"example.com"}
```

### Output

The Actor makes six DoH requests and saves **one dataset item per returned record**, followed by **one summary item**. A type that has no records is represented by `[]` in the summary's `records_by_type`, **not as an error**. For example (illustrative records and TTL):

```json
{"kind":"record","domain":"example.com","record_type":"A","value":"93.184.215.14","ttl":300,"priority":null,"error":null}
```

Summary structure (illustrative excerpt; actual output always has all six record-type keys):

```json
{
  "kind":"summary",
  "domain":"example.com",
  "record_type":null,
  "value":null,
  "ttl":null,
  "priority":null,
  "error":null,
  "records_by_type":{"A":[{"value":"93.184.215.14","ttl":300,"priority":null}],"AAAA":[],"CNAME":[],"MX":[],"TXT":[],"NS":[]},
  "errors_by_type":{},
  "statuses_by_type":{"A":"NOERROR","AAAA":"NOERROR","CNAME":"NOERROR","MX":"NOERROR","TXT":"NOERROR","NS":"NOERROR"},
  "truncated_types":[]
}
```

- `MX` records have their preference in `priority`; all other types use `null`.
- `TXT` values retain their DNS JSON quoted-string formatting. The Actor does not assemble split strings.
- `statuses_by_type` distinguishes `NXDOMAIN` from `NOERROR` with an empty answer.
- `errors_by_type` contains friendly messages for individual lookup failures; `records_by_type` remains `[]` for those types. A failed query is therefore **not** the same as a successful empty response.

### Limits and cautions

- This is a **current resolver view**, not authoritative proof of all worldwide DNS propagation. DoH results may be cached; TTLs vary.
- The fixed resolver is Cloudflare; changing resolver, verifying DNSSEC, recursive tracing, SRV/CAA lookups and zone transfers are out of scope.
- Up to 100 returned records per type are emitted; `truncated_types` records any truncation. Individual responses are limited to 256 KiB; 8-second request timeouts apply.
- When an A/AAAA answer contains a CNAME alias, that alias is **not** emitted as an A/AAAA item; the separately requested CNAME type is used.
- All queries go only to the Cloudflare public DoH endpoint. The supplied domain is not contacted directly. No logins or private credentials.
- The Actor only accepts one domain; no batch input or automatic URL discovery.

### Run locally (Python 3.12+ recommended)

From this Actor folder:

```bash
ACTOR_INPUT_JSON='{"domain":"example.com"}' python src/main.py
```

Or place the input in `storage/key_value_stores/default/INPUT.json`. Locally, the output is saved as numbered JSON files under `storage/datasets/default/`. In Apify, the platform's run-provided storage access is used to write to its default dataset (no Apify SDK).

### Verification

Offline repeatable tests and a **real `python src/main.py` subprocess smoke run** are in `tests/`. The smoke uses a recorded **DNS-over-HTTPS fixture** because test execution should not depend on an external DNS service; its output is **not** a live Cloudflare lookup. Inspect `verification/script-mode-smoke.txt` and `verification/dataset-items.json`.

```bash
python tests/run_smoke.py
python -m unittest discover -s tests -p 'test_*.py' -v
```

### Apify Store metadata and pricing suggestion

- Store category: `DEVELOPER_TOOLS`.
- Suggested pricing: **$0.004 per run** (`PAY_PER_EVENT` recommendation). The dataset includes an extra summary row, so billing per row is not recommended.
- `store_metadata.json` is advisory; no Store publishing or billing is configured.

# Actor input Schema

## `domain` (type: `string`):

One publicly resolvable domain name. No scheme or path.

## Actor input object example

```json
{
  "domain": "example.com"
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing the Actor's result items

# 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 = {
    "domain": "example.com"
};

// Run the Actor and wait for it to finish
const run = await client.actor("eichan/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 = { "domain": "example.com" }

# Run the Actor and wait for it to finish
run = client.actor("eichan/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 '{
  "domain": "example.com"
}' |
apify call eichan/dns-records-lookup --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,eichan/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/2hTISKjh6k6IM8k58/builds/YZaJpoWReQb9PHvQt/openapi.json
