# Robots.txt & Sitemap Analyzer - Crawl Rules and URL Audit (`psx/sitemap-robots-analyzer`) Actor

Parse robots.txt and XML sitemaps for many domains: blocked crawlers (incl. GPTBot), sitemap errors, dead URLs, lastmod stats.

- **URL**: https://apify.com/psx/sitemap-robots-analyzer.md
- **Developed by:** [psx](https://apify.com/psx) (community)
- **Categories:** SEO tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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

## Sitemap + robots.txt Analyzer

Find the crawl problems that quietly cost you traffic. Give it a site; it lints **robots.txt**, validates every **XML sitemap** (index files, .gz and nesting supported) and samples the listed URLs live to catch dead pages, redirects and indexing conflicts. HTTP only, no browser, fast and cheap. Built for SEO freelancers, agencies, site owners and AI agents.

### What is checked

- **robots.txt**: missing / 5xx / HTML-instead-of-rules, >500 KiB, wrong content type, syntax errors, unknown directives, rules before any `User-agent`, patterns without a leading `/`, relative `Sitemap:` URLs, unsupported `noindex:` directive, `Disallow: /` for all crawlers, blocked CSS/JS, duplicate agent groups, missing Sitemap directive.
- **Blocked important pages**: home page blocked, and every sitemap URL tested against the robots rules (reported as a sitemap/robots conflict).
- **Sitemaps**: not found, HTTP errors, redirects, invalid XML, empty, >50,000 URLs, >50 MB, relative or cross-host `<loc>`, http URLs in https sitemaps, duplicates, over-long URLs.
- **lastmod sanity**: invalid W3C datetime, future dates, pre-1995 dates, missing everywhere, all identical.
- **Live URL sample** (evenly spread, default 30/site): 4xx/5xx, redirects (301/302 to a different URL), `noindex` via meta or X-Robots-Tag, canonical pointing elsewhere, unreachable.
- **AI crawler access**: allowed/blocked for GPTBot, ClaudeBot, PerplexityBot, Google-Extended, CCBot and others.

### Input

| Field | Default | Description |
|---|---|---|
| `urls` | required | Up to 100 sites or domains. |
| `sitemapUrls` | none | Extra sitemap URLs to analyze. |
| `checkUrls` | `true` | Live-check a sample of sitemap URLs. |
| `maxUrlChecksPerSite` | `30` | Sample size (max 500). Billed per URL. |
| `robotsToken` | `Googlebot` | Agent used for the blocked-pages test. |
| `delayMs` / `concurrency` | `300` / `3` | Politeness controls. |

```json
{ "urls": ["https://example.com"], "maxUrlChecksPerSite": 50 }
```

### Output

`"type": "issue"` items (one per finding, sorted high to low; identical findings across many sitemap files are merged with `occurrences`) and one `"type": "site-summary"` per site with score, sitemap list, AI crawler access, status counts.

```json
{ "type": "issue", "siteOrigin": "https://www.bbc.com", "scope": "sitemap", "severity": "high", "id": "sitemap-cross-host", "occurrences": 13,
  "message": "100 URL(s) are on a different host than the sitemap (search engines ignore them)." }
{ "type": "site-summary", "siteOrigin": "https://htmx.org", "score": 100, "sitemapUrlsTotal": 188, "urlsChecked": 15, "statusCounts": { "200": 15 } }
```

Score: 100 minus 20/8/3 per high/medium/low issue (heuristic).

### Pricing (pay per event; set in Apify Console)

| Event | When | Planned price |
|---|---|---|
| `apify-actor-start` | once per run | ~$0.03 |
| `site-analyzed` | each site | ~$0.02 |
| `url-checked` | each sitemap URL fetched live | ~$0.002 |

Charging only happens on the Apify platform.

### Politeness and safety

Identifies as `SitemapRobotsAnalyzer`; at most 2 requests in flight per host with `delayMs` spacing; URLs disallowed by robots.txt are not fetched (reported as conflicts); only http/https; localhost, internal hosts and private/reserved IPs refused (connect time and every redirect hop). Sitemap-listed URLs on other hosts are only flagged, never requested beyond the same SSRF checks. Public pages only.

### Run locally

```
npm install && npm test
mkdir -p storage/key_value_stores/default
echo '{"urls":["https://example.com"]}' > storage/key_value_stores/default/INPUT.json
npm start     # results in storage/datasets/default/
```

Tested on htmx.org (188 URLs, clean), bbc.com (25 sitemap files, cross-host and http URLs, redirects, AI bots blocked), python.org, w3.org, sqlite.org, github.com (no sitemap). Docker: `docker build -t sitemap-robots-analyzer . && docker run --user 996 -v <dir>:/usr/src/app/storage sitemap-robots-analyzer`.

# Actor input Schema

## `urls` (type: `array`):

Sites to analyze (up to 100). Bare domains accepted; the robots.txt and sitemaps of the site origin are analyzed.

## `sitemapUrls` (type: `array`):

Optional sitemap URLs to analyze in addition to those declared in robots.txt.

## `checkUrls` (type: `boolean`):

Request a sample of sitemap URLs to find 4xx/5xx, redirects, noindex and canonical conflicts (each billed).

## `maxUrlChecksPerSite` (type: `integer`):

Evenly spread sample of the sitemap URLs.

## `robotsToken` (type: `string`):

User-agent token used for the blocked-pages test.

## `delayMs` (type: `integer`):

Delay between requests to one host (ms).

## `concurrency` (type: `integer`):

Sites in parallel.

## Actor input object example

```json
{
  "urls": [
    "https://example.com"
  ],
  "checkUrls": true,
  "maxUrlChecksPerSite": 30,
  "robotsToken": "Googlebot",
  "delayMs": 300,
  "concurrency": 3
}
```

# Actor output Schema

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

No description

# 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 = {
    "urls": [
        "https://example.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("psx/sitemap-robots-analyzer").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 = { "urls": ["https://example.com"] }

# Run the Actor and wait for it to finish
run = client.actor("psx/sitemap-robots-analyzer").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 '{
  "urls": [
    "https://example.com"
  ]
}' |
apify call psx/sitemap-robots-analyzer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,psx/sitemap-robots-analyzer"
        }
    }
}
```

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/cyVhK7wAcaX2BvkVh/builds/NXcyE6LoTdZ1bKOr7/openapi.json
