# Sitemap Validator (sitemaps.org rules + optional URL status) (`wrentools/sitemap-validator`) Actor

Validates XML sitemaps and sitemap indexes against the sitemaps.org protocol: namespace, 50,000-URL and 50 MB limits, absolute same-host locs, lastmod dates, changefreq and priority. Optionally checks each URL's HTTP status and redirects. Obeys robots.txt.

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

## Pricing

from $0.20 / 1,000 url entry validateds

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 Validator (sitemaps.org rules + optional URL status)

Find out whether your XML sitemaps are actually valid before a search engine tells you they are not. Give it a
sitemap, a sitemap index, or just your site (it reads the `Sitemap:` lines in robots.txt), and it checks every file
and every `<url>` entry against the sitemaps.org protocol. Optionally it requests each listed URL once and reports
the ones that are broken or redirect.

**Broken links in a scheduled job:** our [Python and Node example](https://github.com/WrenTools/apify-actor-examples/tree/main/check-a-sitemap-for-broken-links)
checks every page your sitemap lists, writes the problems to a CSV, and exits with 1 when there is any.

For the pages themselves (titles, meta descriptions, headings, image alt text), run
[Own-Site SEO Audit](https://apify.com/wrentools/own-site-seo-audit).

### What it checks

**Each sitemap file**

- Well-formed XML with a `urlset` or `sitemapindex` root in the `http://www.sitemaps.org/schemas/sitemap/0.9` namespace
- At most 50,000 entries and 50 MB uncompressed; `.gz` sitemaps are decompressed with a size guard
- An index that lists another index (not allowed by the protocol)
- Fetch failures, and files that robots.txt blocks

**Each `<url>` entry**

- `<loc>` present, absolute http(s), at most 2,048 characters, properly escaped, not duplicated
- `<loc>` on the same host as the sitemap (cross-host entries are ignored by search engines)
- `<lastmod>` in W3C datetime format, and not in the future
- `<changefreq>` one of the seven allowed values; `<priority>` between 0.0 and 1.0
- With status checking on: 4xx/5xx answers, network errors and redirects (a sitemap should list final URLs)

Robots.txt is obeyed for every request, and requests are spaced (500 ms by default).
Only public internet addresses are fetched: a URL or redirect into a private, loopback or link-local network is
refused.

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `sitemapUrls` | array | - | Sitemap or index URLs. |
| `siteUrl` | string | - | Used when `sitemapUrls` is empty: robots.txt `Sitemap:` lines, else `/sitemap.xml`. |
| `checkUrlStatus` | boolean | `false` | Request each listed URL once. |
| `maxUrls` | integer | `5000` | Across all files. |
| `maxSitemapFiles` | integer | `50` | Including children of an index. |
| `requestDelayMs` | integer | `500` | Pause between requests. |

### Output

Dataset items of two types.

```json
{"type": "sitemap-file", "url": "https://www.example.com/sitemap-pages.xml", "kind": "urlset",
 "httpStatus": 200, "gzipped": false, "sizeBytes": 18234, "entryCount": 120, "entriesWithIssues": 3,
 "errors": [], "warnings": [], "valid": false}
```

```json
{"type": "url-entry", "sitemap": "https://www.example.com/sitemap-pages.xml",
 "loc": "https://www.example.com/old", "lastmod": "2026-13-01", "changefreq": null, "priority": null,
 "httpStatus": 301, "redirectedTo": "https://www.example.com/new", "statusChecked": true,
 "issues": ["invalid-lastmod", "url-redirects"]}
```

A file's `valid` and `entriesWithIssues` count the sitemaps.org rules only: they are decided when the file is read,
before any page is requested. A broken or redirecting page is reported in its own `url-entry` item and counted in
`SUMMARY.urlEntriesWithIssues`.

Key-value store record `SUMMARY`: sitemaps checked, how many are valid, URL entries and how many have issues.

### Pricing

Pay per event, no start fee:

| Event | Price | Per 1,000 |
|---|---|---|
| `sitemap-file-validated` | $0.002 | $2.00 |
| `url-validated` (rules only) | $0.0002 | $0.20 |
| `url-validated-with-status` (rules + one HTTP request) | $0.0006 | $0.60 |

### Limits

- Image, video and news sitemap extensions are read as ordinary entries; their extra tags are not validated yet.
- Sitemaps with a DOCTYPE or XML entities are rejected (sitemaps never need them, and they are a parser risk).
- Memory: 1,024 MB by default (enough for 200,000 entries), 2,048 MB at most. Status checks wait on your server,
  so for a status-check run of a small sitemap 256 MB is enough.
- A run stops early, with the entries checked so far saved and the reason in `SUMMARY.stoppedReason`, when its
  timeout is near or when status checks answer very slowly (on average over about 4 s per URL at 1,024 MB, 17 s
  at 256 MB). Every entry it returns from a status-check run was checked.

### Support

Report problems in the **Issues** tab. We aim to respond within a few days.

# Actor input Schema

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

Sitemap or sitemap-index URLs (.xml or .xml.gz). Leave empty to discover them from the site's robots.txt.

## `siteUrl` (type: `string`):

Used when no sitemap URLs are given: the robots.txt Sitemap: lines are read, else /sitemap.xml is tried.

## `checkUrlStatus` (type: `boolean`):

Request every listed URL once and report errors and redirects. Charged at the higher per-URL price.

## `maxUrls` (type: `integer`):

Stop after this many URL entries across all sitemaps.

## `maxSitemapFiles` (type: `integer`):

Cap on sitemap files fetched, including children of an index.

## `requestDelayMs` (type: `integer`):

Pause between requests to keep load on your server low.

## Actor input object example

```json
{
  "sitemapUrls": [
    "https://api.apify.com/v2/key-value-stores/uM2zEXblvgf0s1cES/records/sitemap.xml"
  ],
  "checkUrlStatus": false,
  "maxUrls": 100,
  "maxSitemapFiles": 3,
  "requestDelayMs": 500
}
```

# Actor output Schema

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

No description

## `summary` (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 = {
    "sitemapUrls": [
        "https://api.apify.com/v2/key-value-stores/uM2zEXblvgf0s1cES/records/sitemap.xml"
    ],
    "maxUrls": 100,
    "maxSitemapFiles": 3
};

// Run the Actor and wait for it to finish
const run = await client.actor("wrentools/sitemap-validator").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 = {
    "sitemapUrls": ["https://api.apify.com/v2/key-value-stores/uM2zEXblvgf0s1cES/records/sitemap.xml"],
    "maxUrls": 100,
    "maxSitemapFiles": 3,
}

# Run the Actor and wait for it to finish
run = client.actor("wrentools/sitemap-validator").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 '{
  "sitemapUrls": [
    "https://api.apify.com/v2/key-value-stores/uM2zEXblvgf0s1cES/records/sitemap.xml"
  ],
  "maxUrls": 100,
  "maxSitemapFiles": 3
}' |
apify call wrentools/sitemap-validator --silent --output-dataset

```

## MCP server setup

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

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/dEgjjT9Yf5Yodfi4n/builds/iUT2oE0XZYW6g1Yb2/openapi.json
