# Sitemap URL Extractor — All URLs from robots.txt & XML Sitemaps (`openregistry/sitemap-url-extractor`) Actor

Get every URL a website lists in its sitemaps: reads robots.txt Sitemap lines, follows sitemap indexes recursively, unpacks .xml.gz, returns lastmod, changefreq and priority. Filter by pattern or date. Respects robots.txt. Pay per URL.

- **URL**: https://apify.com/openregistry/sitemap-url-extractor.md
- **Developed by:** [Mahé Perrin](https://apify.com/openregistry) (community)
- **Categories:** SEO tools, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.10 / 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 URL Extractor — All URLs from robots.txt & XML Sitemaps

Give it a domain and get back **every URL the site lists in its sitemaps**, with `lastmod`, `changefreq` and `priority`. No crawling page by page, no browser: the Actor reads the sitemaps the site publishes for search engines, so a 50,000-page site comes back in seconds.

What it handles for you:

- **Discovery**: `Sitemap:` lines in `robots.txt`, then the usual `/sitemap.xml` and `/sitemap_index.xml`.
- **Sitemap indexes**, followed recursively (up to 5 levels), each child read once.
- **Gzipped sitemaps** (`.xml.gz`), plain-text sitemaps, namespaced XML, CDATA and escaped `&amp;` in URLs.
- **Filters**: keep or drop URLs by wildcard (`/blog/*`, `*.pdf`) or regular expression, keep only pages modified since a date.
- **Duplicates** removed across all sitemaps of the run (optional).

### What it is for

- **SEO audits**: compare the sitemap with what is indexed, spot stale `lastmod`, count pages per section.
- **Seed lists for scrapers and crawlers**: feed product or article URLs to another Actor instead of crawling the whole site.
- **Content monitoring**: schedule it with "Modified since" to get only new or updated pages since the last run.
- **Migrations**: export the full URL inventory before a redesign to build redirect maps.
- **LLM / RAG pipelines**: list the pages to convert, then send them to a page-to-Markdown Actor.

### Input example

```json
{
  "startUrls": ["example.com", "https://apify.com/sitemap.xml"],
  "includePatterns": ["/blog/*"],
  "modifiedSince": "2025-01-01",
  "maxUrls": 10000
}
```

- `startUrls` — domains, homepages or direct sitemap URLs (`.xml`, `.xml.gz`, `.txt`).
- `includePatterns` / `excludePatterns` — wildcard text (case-insensitive) or `/regex/`.
- `modifiedSince`, `keepUrlsWithoutLastmod` — date filter on `lastmod`.
- `deduplicate`, `maxSitemapsPerSite`, `maxUrls` — limits; `maxUrls` caps the cost.

### Output example

One dataset row per URL:

```json
{
  "url": "https://www.example.com/blog/hello-world",
  "lastmod": "2025-06-02T08:00:00.000Z",
  "changefreq": "daily",
  "priority": 0.8,
  "sitemap": "https://www.example.com/sitemap-posts.xml.gz",
  "site": "https://www.example.com",
  "error": null
}
```

A per-site summary (sitemap files read, files that failed) is saved as `SUMMARY` in the run's key-value store. A site where no sitemap could be read returns one row with `url: null` and the reason in `error`; that row is **not charged**.

### Good to know

- **Polite by design**: the Actor identifies itself with its own User-Agent (`OpenRegistry-SitemapExtractor`), checks `robots.txt` before every request (and again after each redirect), waits between requests and never imitates a browser or uses proxies to get around blocks. If a site forbids access to its sitemap in `robots.txt`, or blocks automated clients, you get an error row, free of charge.
- A sitemap only contains what the site owner chose to publish; pages missing from it are not discovered (use a crawler for that).
- `lastmod` is returned exactly as written by the site; formats vary (`2025-06-02`, full timestamps).

### Pricing

**$0.0001 per URL** ($0.10 per 1,000 URLs). Duplicates removed by the Actor and error rows are free. Set a maximum charge per run in the Apify console and the Actor stops cleanly when it is reached.

# Actor input Schema

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

A domain (example.com) or homepage: sitemaps are found from robots.txt, then /sitemap.xml and /sitemap_index.xml. A sitemap URL (.xml, .xml.gz, .txt): read directly, indexes are followed.

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

Optional. Text or wildcard (/blog/\*, \*.pdf), case-insensitive; or a regular expression between slashes (//p/\d+$/). A URL is kept if it matches at least one.

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

Optional. Same syntax; applied after the include list.

## `modifiedSince` (type: `string`):

Optional date, e.g. 2025-01-31. Keeps URLs whose lastmod is on or after this date.

## `keepUrlsWithoutLastmod` (type: `boolean`):

Only used with "Modified since". Many sitemaps omit lastmod.

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

A URL listed in several sitemaps is returned (and charged) once.

## `maxSitemapsPerSite` (type: `integer`):

Safety limit for huge sitemap indexes.

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

The run stops once this many URLs are delivered, so you control the cost.

## Actor input object example

```json
{
  "startUrls": [
    "https://apify.com/sitemap.xml"
  ],
  "keepUrlsWithoutLastmod": true,
  "deduplicate": true,
  "maxSitemapsPerSite": 1000,
  "maxUrls": 100000
}
```

# 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 = {
    "startUrls": [
        "https://apify.com/sitemap.xml"
    ]
};

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

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

```

## MCP server setup

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