# Sitemap Extractor & Broken URL Checker (`1stbtln/sitemap-url-checker`) Actor

Get every URL of a website from its sitemaps: auto-finds them via robots.txt, follows sitemap indexes, reads .gz, lastmod, priority, hreflang. Optionally checks each URL's HTTP status and redirects to find broken pages. From $0.20 per 1,000 URLs.

- **URL**: https://apify.com/1stbtln/sitemap-url-checker.md
- **Developed by:** [Ethan Wagner](https://apify.com/1stbtln) (community)
- **Categories:** SEO tools, Developer tools, Marketing
- **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 url extracteds

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 Extractor & Broken URL Checker

Get **every URL of a website** in one run, straight from its XML sitemaps, and optionally **check each one for broken pages and redirects**. Good for SEO audits, site migrations, content inventories, crawl planning, and feeding page lists to scrapers or AI pipelines.

**$0.20 per 1,000 URLs** (extract only) · **$0.70 per 1,000 URLs** (extract + status check). Missing or failed sitemaps are free.

### Features

- **Auto-discovery**: give it a homepage and it reads `robots.txt` `Sitemap:` lines, then tries `/sitemap.xml`, `/sitemap_index.xml`, `/wp-sitemap.xml` and others.
- **Sitemap indexes** followed recursively (up to 5 levels), **gzip** (`.xml.gz`) and **plain-text** sitemaps supported.
- Per URL: `lastmod`, `changefreq`, `priority`, image count and `hreflang` alternates.
- Duplicate URLs are removed automatically.
- **Status check (optional)**: HTTP status code, full **redirect chain** (301/302/307/308), final URL, response time, `isBroken` flag (4xx, 5xx, DNS and timeout errors). Uses HEAD with a GET fallback, at a polite concurrency you control.
- **Regex filter**: keep only `/blog/`, `.pdf`, a language folder, etc.

### Input example

```json
{
  "startUrls": [{ "url": "https://apify.com" }, { "url": "https://example.org/sitemap_index.xml" }],
  "checkStatus": true,
  "maxUrls": 5000,
  "urlFilter": "/blog/"
}
```

### Output example

```json
{
  "url": "https://apify.com/about",
  "statusCode": 200,
  "isBroken": false,
  "finalUrl": "https://apify.com/about",
  "redirectChain": [],
  "responseTimeMs": 46,
  "lastmod": null,
  "priority": null,
  "imageCount": 0,
  "hreflangs": [],
  "sitemapUrl": "https://apify.com/sitemap/pages.xml",
  "startUrl": "https://apify.com"
}
```

Export as CSV, Excel or JSON, or use it via the API, schedules, Make, Zapier, n8n or MCP. Schedule it weekly to get alerted to newly broken pages.

### Pricing

Pay per event:

- `url`: $0.0002 per unique URL extracted (status check off)
- `url-checked`: $0.0007 per unique URL extracted and checked

Rows that only report a problem ("no sitemap found", "sitemap returned 404") are not charged. Set a max spend per run in the run options and the Actor stops cleanly when it's reached.

### Notes

- Only public sitemap files and public pages are requested. No login, no personal data.
- Some sites block automated requests (403). Those show up as broken in the status check, with the status code shown.

# Actor input Schema

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

A homepage (sitemaps are discovered from robots.txt and common paths) or a direct sitemap / sitemap index URL (.xml, .xml.gz, .txt).

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

Request every URL (HEAD, GET fallback) and record status code, redirect chain, final URL and response time. Use it to find broken (4xx/5xx) and redirected pages.

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

Stop after this many unique URLs per start URL.

## `urlFilter` (type: `string`):

Only keep URLs matching this regular expression, e.g. /blog/ or .pdf$

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

Only used when status checking is on. Keep it low to be polite to the website.

## `timeoutSecs` (type: `integer`):

Per-URL timeout for status checks.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://apify.com"
    }
  ],
  "checkStatus": false,
  "maxUrls": 10000,
  "maxConcurrency": 10,
  "timeoutSecs": 20
}
```

# Actor output Schema

## `urls` (type: `string`):

One row per URL found in the sitemaps (with lastmod, priority, hreflang, images), plus status code, redirects and response time when status checking is on. Rows describing a missing or failed sitemap are not charged.

# 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://apify.com"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("1stbtln/sitemap-url-checker").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://apify.com" }] }

# Run the Actor and wait for it to finish
run = client.actor("1stbtln/sitemap-url-checker").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://apify.com"
    }
  ]
}' |
apify call 1stbtln/sitemap-url-checker --silent --output-dataset

```

## MCP server setup

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

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/1t7mv5bOxaF0KRIHb/builds/iy0TS9rRGqZ5PPT2K/openapi.json
