# Sitemap URL Extractor – All URLs, Hreflang & Status Check (`adamplaenitz/sitemap-url-extractor`) Actor

Get every URL from a website's sitemaps: auto-discovery via robots.txt, nested indexes, .xml.gz and text sitemaps. Per URL: lastmod, changefreq, priority, source sitemap, hreflang alternates, image count, optional HTTP status check to find 404s and redirects.

- **URL**: https://apify.com/adamplaenitz/sitemap-url-extractor.md
- **Developed by:** [Adam Plänitz](https://apify.com/adamplaenitz) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.20 / 1,000 sitemap urls

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 URL Extractor – All URLs, Hreflang & Status Check

**Get every URL listed in a website's sitemaps – with `lastmod`, `changefreq`, `priority`, the sitemap each URL came from, hreflang alternates and image counts – and optionally check the HTTP status of every URL to find 404s and redirects in your sitemaps.** Export as JSON, CSV or Excel, or connect to Google Sheets, Make, Zapier, n8n or webhooks.

### What does it do?

- **Finds the sitemaps for you:** enter a website (e.g. `https://example.com`) and the Actor reads the `Sitemap:` lines in robots.txt. If there are none, it tries the usual locations (`/sitemap.xml`, `/sitemap_index.xml`, `/sitemap-index.xml`, `/wp-sitemap.xml`, `/sitemap.xml.gz`, `/sitemaps.xml`, `/sitemap.txt`). You can also enter sitemap URLs directly.
- **Reads every common format:** sitemap indexes (nested up to 6 levels), `urlset` sitemaps, gzip-compressed `.xml.gz` files, plain-text sitemaps (one URL per line), RSS and Atom feeds. Large files (up to 100 MB) are fine.
- **Keeps the details:** `lastmod`, `changefreq`, `priority`, the **source sitemap** of every URL, **hreflang alternates** (`xhtml:link rel="alternate"`), **image count** (and optionally the image URLs), video count and titles, and Google News data (title, publication, date) where present.
- **Filters and limits:** include / exclude patterns (globs like `/blog/*` or regular expressions), maximum number of URLs, duplicate removal across sitemaps.
- **Optional status check:** one HEAD request per URL (GET as fallback when a server refuses HEAD), redirects followed manually, one retry for timeouts and server errors. You get the status code, the final status and the redirect target – exactly what you need to clean up a sitemap.
- **Transparent run summary:** every sitemap file with its HTTP status, type, compression, size and URL count is listed in the `RUN-SUMMARY` record, so you can see which sitemap is broken.

### Who is it for?

- **SEO agencies and site owners** auditing sitemaps: URLs that return 404, redirect, or are blocked; sitemaps that fail to load; missing hreflang alternates.
- **Developers and data teams** who need a clean list of a site's pages before crawling, migrating or monitoring it.
- **Content teams** building a content inventory with last-modified dates.

### Input

| Field | Example |
|---|---|
| Websites or sitemap URLs | `https://crawlee.dev`, `https://example.com/sitemap_index.xml` |
| Maximum URLs | `1000` (0 = no limit) |
| Include only URLs matching | `/blog/*`, `https://example.com/de/*`, `/20(24\|25)/` |
| Exclude URLs matching | `*/tag/*`, `/[.]pdf$/i` |
| Check HTTP status of every URL | on / off |
| Parallel status checks | `10` |
| Remove duplicate URLs | on |
| Discover sitemaps automatically | on |
| Include image URLs | off |

**Pattern syntax:** `*` matches any characters. Patterns starting with `/` are matched against the path (and query), other patterns against the full URL. Regular expressions are written between slashes, e.g. `/(news|blog)/`.

### Output example (shortened)

```json
{
  "url": "https://example.com/en/pricing",
  "lastmod": "2026-10-01T10:00:00+00:00",
  "changefreq": "weekly",
  "priority": 0.8,
  "sitemapUrl": "https://example.com/page-sitemap.xml",
  "alternates": [
    { "hreflang": "de", "href": "https://example.com/de/preise" },
    { "hreflang": "x-default", "href": "https://example.com/pricing" }
  ],
  "hreflangCount": 2,
  "imageCount": 3,
  "statusCode": 301,
  "finalStatusCode": 200,
  "finalUrl": "https://example.com/en/pricing/",
  "redirectCount": 1,
  "urlStatus": "redirect",
  "errorType": null
}
```

The status fields (`statusCode`, `finalStatusCode`, `finalUrl`, `redirectCount`, `urlStatus`, `errorType`, `errorMessage`) are only present when the status check is switched on. `urlStatus` is `ok`, `redirect`, `broken` or `blocked` (401/403/429 – the server refused automated requests). `errorType` is `4xx`, `5xx`, `dns`, `timeout`, `ssl`, `connection`, `redirect-loop` or `too-many-redirects`.

With duplicate removal on, a URL listed in several sitemaps (e.g. a page sitemap and an image sitemap) is output once, with the data of the first sitemap that was read. Switch it off to get every occurrence.

### Pricing and speed

See the **Pricing** tab. You pay per URL in the dataset; URLs removed by your filters, duplicates and limits are not charged. URLs with the status check switched on are billed as a separate, slightly higher event because every URL needs its own request.

Speed in our tests: without status check, sitemaps with tens of thousands of URLs are read in seconds (100 URLs from crawlee.dev in about 4 seconds including start-up). With status check about 15–20 URLs per second at the default of 10 parallel requests (3,000 URLs from two websites in 2 min 40 s).

### Data source, robots.txt and privacy

- The Actor reads the public sitemaps that website owners publish for search engines. **Only use it on websites you own or are allowed to analyse**, and respect their terms.
- Sitemaps are meant for crawlers, so they are read even if robots.txt disallows other paths. The optional status check sends one lightweight request per URL listed in the sitemap; keep the number of parallel checks low for small servers.
- The Actor identifies itself with the User-Agent `sitemap-url-extractor/0.1 (Apify Actor)`.
- **No personal data** is extracted – only URLs and the metadata in the sitemap.

### Limits

- robots.txt applies to a whole host: for `https://example.com/blog/` the sitemaps of the entire host are read. Use an include pattern such as `/blog/*` to keep only one section.
- Sitemaps that are generated by JavaScript or hidden behind a login cannot be read. Sitemap files that take longer than the request timeout (default 30 s) to start or stall during download are reported as failed in the run summary – raise the timeout for very slow servers.
- At most 2,000 sitemap files per run and index nesting up to 6 levels.
- Some servers answer HEAD and GET differently or block cloud IP addresses; a `blocked` status (401/403/429) is not necessarily a broken page. You can use a proxy in the input.

Questions or feature requests? Please open an issue in the **Issues** tab.

# Actor input Schema

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

A website (e.g. https://example.com) – its sitemaps are found via robots.txt and common locations – or a direct sitemap URL (sitemap.xml, sitemap index, .xml.gz, .txt, RSS/Atom feed).

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

Stop after this many URLs (after filters and de-duplication). 0 = no limit.

## `includePatterns` (type: `array`):

Optional. Glob patterns (`*` = any characters) matched against the full URL, e.g. `https://example.com/blog/*`, or against the path if they start with `/`, e.g. `/products/*`. Regular expressions go between slashes, e.g. `/20(24|25)/`. A URL is kept if it matches any pattern.

## `excludePatterns` (type: `array`):

Optional. Same syntax as the include patterns, e.g. `*/tag/*` or `/[.]pdf$/i`. Excluded URLs are not output and not charged.

## `checkStatus` (type: `boolean`):

Sends a HEAD request (GET as fallback) to each URL and reports status code, redirect target and errors – finds 404s, redirects and server errors listed in your sitemaps. Slower, and billed as a separate, slightly higher event.

## `statusCheckConcurrency` (type: `integer`):

How many URLs are checked at the same time (1–50). Keep it low for small servers.

## `deduplicate` (type: `boolean`):

Output each URL only once, even if it appears in several sitemaps (the first sitemap is reported as source).

## `discoverSitemaps` (type: `boolean`):

For website URLs, read the Sitemap lines in robots.txt; if there are none, try common locations (/sitemap.xml, /sitemap_index.xml, /wp-sitemap.xml, /sitemap.xml.gz, /sitemap.txt …). Turn off to treat every start URL as a sitemap.

## `includeImageUrls` (type: `boolean`):

Adds the list of image URLs from image sitemap extensions (image:loc) to each item. The image count is always included.

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

Timeout for downloading one sitemap file (status checks use at most 20 seconds).

## `proxyConfiguration` (type: `object`):

Optional. Only needed if the website blocks requests from cloud servers.

## Actor input object example

```json
{
  "startUrls": [
    "https://crawlee.dev"
  ],
  "maxUrls": 100,
  "checkStatus": false,
  "statusCheckConcurrency": 10,
  "deduplicate": true,
  "discoverSitemaps": true,
  "includeImageUrls": false,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

One item per URL found in the sitemaps.

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

Sitemaps found (with status, type and URL count), duplicates, filtered URLs and status-check counts.

# 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": [
        "https://crawlee.dev"
    ],
    "maxUrls": 100
};

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

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

```

## MCP server setup

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