# Sitemap Extractor & Sitemap URL Checker (`cellwright/sitemap-extractor`) Actor

Finds and parses all sitemaps of a website (robots.txt, sitemap indexes, gzip, text, RSS/Atom) and returns every URL with lastmod, hreflang and images. Optional check: status codes, redirects, noindex, canonical, robots.txt blocks.

- **URL**: https://apify.com/cellwright/sitemap-extractor.md
- **Developed by:** [Cellwright](https://apify.com/cellwright) (community)
- **Categories:** SEO tools, Developer tools
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.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/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 Extractor & Sitemap URL Checker

Get **every URL from a website's sitemaps** – in seconds, without crawling. Give it a homepage, a robots.txt or a sitemap URL: the Actor finds the sitemaps (robots.txt `Sitemap:` lines, `/sitemap.xml`, `/sitemap_index.xml`, `/wp-sitemap.xml` …), follows **sitemap indexes**, reads **.xml.gz**, plain-text and **RSS/Atom** sitemaps and returns one clean record per unique URL with `lastmod`, `changefreq`, `priority`, **hreflang alternates**, image and video counts and Google News data.

Optionally, it **checks every URL** in the same run – status codes, redirects, `noindex` (meta and `X-Robots-Tag`), canonical mismatches and URLs your own robots.txt blocks. That is the classic *sitemap hygiene* audit: a sitemap should only list indexable 200 pages.

Plain HTTP, no browser: fast and cheap. Ideal for SEO audits, site migrations, crawl planning, content inventories, change monitoring (`modifiedAfter`) and as URL input for other Actors or AI agents.

### Why this Actor

- **Finds sitemaps for you** – robots.txt first, then the common paths; soft-404 HTML pages are not mistaken for sitemaps.
- **All formats:** XML urlset, sitemap index (nested too), gzip (by content, not only by file name), text, RSS 2.0 and Atom feeds.
- **Clean data:** URLs are de-duplicated across all sitemaps, dates are normalized to ISO 8601 UTC (`lastmodIso`), protocol problems are flagged per URL (`other-host`, `invalid-lastmod`, `lastmod-in-future`, …).
- **Sitemap report** in the key-value store (`OUTPUT`): every sitemap file with type, URL count, size, compression, parent index, errors and issues (`over-50000-urls`, `over-50mb`, `invalid-xml`, `redirected`, `http-error`, `empty`), plus issue and status code totals.
- **Only what you need:** `modifiedAfter` ("7 days", "2026-01-31"), include/exclude regex, URL and sitemap limits.
- **Safe and polite:** respects robots.txt by default, honest user agent, moderate parallelism, private/internal addresses blocked, hardened XML parser (no XML bombs / XXE), size limits.

### Input

| Field | Default | Description |
|---|---|---|
| `startUrls` | – | Homepages, robots.txt URLs or sitemap URLs (up to 1,000) |
| `checkMode` | `none` | `none` = extract only · `status` = HEAD per URL (status, redirects, X-Robots-Tag) · `indexability` = GET per page (status, redirects, noindex, canonical, title) |
| `maxUrls` | `10000` | Unique URLs per run (1–2,000,000) |
| `maxSitemaps` | `1000` | Sitemap files per run (indexes included) |
| `modifiedAfter` | – | Keep URLs with newer `lastmod` (date or period like `30 days`); URLs without lastmod are kept |
| `includeUrlPatterns` / `excludeUrlPatterns` | – | Regular expressions |
| `includeAlternates` | `true` | Return hreflang alternates |
| `includeImages` | `false` | Return image URLs (max 20 per URL); `imageCount` is always returned |
| `respectRobotsTxt` | `true` | Don't fetch disallowed sitemaps/URLs; flag them instead |
| `maxConcurrency` | `5` | Parallel requests (1–20) |
| `requestTimeoutSecs` | `30` | Per request |

Example – all blog posts changed in the last 30 days, with status check:

```json
{
  "startUrls": [{ "url": "https://www.example.com" }],
  "includeUrlPatterns": ["/blog/"],
  "modifiedAfter": "30 days",
  "checkMode": "status"
}
```

### Output (one record per unique URL)

| Field | Description |
|---|---|
| `url` | URL as listed in the sitemap |
| `lastmod`, `lastmodIso` | Raw lastmod and normalized ISO 8601 UTC (or `null`) |
| `changefreq`, `priority` | As listed (or `null`) |
| `imageCount`, `videoCount` | Number of image:image / video:video entries |
| `images` | Image URLs (only with `includeImages`) |
| `alternates` | `[{hreflang, url}]` (with `includeAlternates`) |
| `news` | `{title, publicationDate}` for Google News sitemaps |
| `title` | Item title (RSS/Atom) or page title (`indexability`) |
| `sitemapUrl`, `startUrl` | Sitemap file that listed the URL, and your input |
| `issues` | List of issue codes (see below) |

With `checkMode` = `status` or `indexability`, additionally:

| Field | Description |
|---|---|
| `checked` | `true` if the URL answered |
| `statusCode`, `finalUrl`, `redirectCount` | HTTP status, redirect target (or `null`), number of hops |
| `contentType`, `responseTimeMs` | Response metrics |
| `xRobotsTag`, `noindex` | X-Robots-Tag header; `true` if noindex via header or meta |
| `indexable` | `true` = 200, no redirect, no noindex, canonical matches |
| `canonical`, `metaRobots` | Only `indexability` |
| `checkError` | Network error message if the URL did not answer |

If a start URL yields no URLs at all, you get one free record with `url: null` and an `error` explaining why.

#### Issue codes

- Protocol: `invalid-url`, `other-host` (URL on a different host than the sitemap), `scheme-mismatch` (http vs https), `invalid-lastmod`, `lastmod-in-future`, `invalid-priority`, `invalid-changefreq`
- Check: `broken` (4xx/5xx), `redirects`, `noindex`, `canonical-mismatch`, `not-html`, `blocked-by-robots-txt`, `unreachable`, `blocked-address`, `slow-response` (> 2 s)

### Pricing (pay per event)

| Event | Price |
|---|---|
| URL extracted | $0.0002 |
| URL status checked (`status`) | $0.0003 |
| URL indexability checked (`indexability`) | $0.001 |

1,000 URLs: $0.20 extract only · $0.50 with status check · $1.20 with indexability check. Duplicates, filtered URLs, network errors and robots.txt-blocked URLs are **free**. Set a maximum charge per run in the run options to cap your cost.

### Limits

- Sitemap files larger than 60 MB (uncompressed) are refused (the protocol limit is 50 MB).
- Sitemap indexes are followed up to 5 levels deep; each sitemap file is downloaded once per run.
- Only public `http(s)` URLs; login-protected sitemaps are not supported.
- The Actor does not crawl pages for links – for that use a site crawler or a broken link checker.

### FAQ

**My site has no sitemap in robots.txt.** The Actor then tries `/sitemap.xml`, `/sitemap_index.xml`, `/sitemap-index.xml`, `/wp-sitemap.xml`, `/sitemap.xml.gz` and `/sitemap.txt`. You can always pass the sitemap URL directly.

**Can I use it for monitoring?** Yes – schedule it with `modifiedAfter: "1 day"` to get only new or changed URLs, or with `checkMode: "status"` to catch broken URLs in your sitemap early.

# Actor input Schema

## `startUrls` (type: `array`):

A homepage (sitemaps are found via robots.txt and common paths like /sitemap.xml), a robots.txt URL or a sitemap URL (XML, .xml.gz, .txt, RSS/Atom). Sitemap indexes are followed automatically. 'https://' is added if missing.

## `checkMode` (type: `string`):

none = only extract URLs (fastest, cheapest). status = one HEAD request per URL: status code, redirects, X-Robots-Tag. indexability = GET each page: status, redirects, noindex (meta + header), canonical mismatch, title.

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

Stop after this many unique URLs (all start URLs together).

## `maxSitemaps` (type: `integer`):

Maximum number of sitemap files to download (indexes count too).

## `modifiedAfter` (type: `string`):

Optional. Keep only URLs whose <lastmod> is newer: a date (2026-01-31) or a period ('7 days', '2 weeks', '6 months'). URLs without lastmod are kept.

## `includeUrlPatterns` (type: `array`):

Optional regular expressions. If set, only matching URLs are returned. Example: '/blog/'.

## `excludeUrlPatterns` (type: `array`):

Regular expressions for URLs to drop. Example: '/tag/|/author/'.

## `includeAlternates` (type: `boolean`):

Return the xhtml:link hreflang alternates of each URL (multilingual sites).

## `includeImages` (type: `boolean`):

Return the image:image URLs listed for each page (max 20 per URL). The image count is always returned.

## `respectRobotsTxt` (type: `boolean`):

Do not fetch sitemaps or check URLs disallowed by robots.txt. Disallowed URLs found in a sitemap are flagged 'blocked-by-robots-txt' (a common SEO mistake). Turn off only for sites you own or may audit.

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

Simultaneous requests for sitemap downloads and URL checks. Keep it low (≤ 5) for small or shared hosting; raise it for your own large site.

## `requestTimeoutSecs` (type: `integer`):

Timeout per request.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://crawlee.dev"
    }
  ],
  "checkMode": "none",
  "maxUrls": 1000,
  "maxSitemaps": 1000,
  "includeAlternates": true,
  "includeImages": false,
  "respectRobotsTxt": true,
  "maxConcurrency": 5,
  "requestTimeoutSecs": 30
}
```

# Actor output Schema

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

One item per processed input in the default dataset (JSON, CSV, Excel via the dataset export).

## `summary` (type: `string`):

Totals and statistics of the run (OUTPUT record).

# 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 = {
    "startUrls": [
        {
            "url": "https://crawlee.dev"
        }
    ],
    "maxUrls": 1000
};

// Run the Actor and wait for it to finish
const run = await client.actor("cellwright/sitemap-extractor").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 = {
    "startUrls": [{ "url": "https://crawlee.dev" }],
    "maxUrls": 1000,
}

# Run the Actor and wait for it to finish
run = client.actor("cellwright/sitemap-extractor").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 '{
  "startUrls": [
    {
      "url": "https://crawlee.dev"
    }
  ],
  "maxUrls": 1000
}' |
apify call cellwright/sitemap-extractor --silent --output-dataset

```

## MCP server setup

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

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/srP9c4X7ZtMkqawdq/builds/UYF7H3vzru0yKCjWV/openapi.json
