# Sitemap Extractor: All URLs from XML Sitemaps & robots.txt (`forgeloop/sitemap-extractor`) Actor

Get every URL from a website's sitemaps. Finds sitemaps in robots.txt and the usual paths, follows sitemap indexes, reads gzip, text, RSS and Atom sitemaps, returns lastmod, priority, images and hreflang. For SEO audits, migrations and crawls. Pay per URL.

- **URL**: https://apify.com/forgeloop/sitemap-extractor.md
- **Developed by:** [Markus Heiß](https://apify.com/forgeloop) (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

from $1.00 / 1,000 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 Extractor: All URLs from XML Sitemaps & robots.txt

Get every URL a website lists in its sitemaps. Enter a domain, get back one row per URL with the last modified date, change frequency, priority, images and hreflang alternates.

Built for SEO audits, content inventories, migration checks, competitor research and as the first step of any crawl: you know which pages exist before you fetch a single one.

### What it does

- **Finds the sitemaps on its own.** Reads the `Sitemap:` lines in robots.txt, then tries `/sitemap.xml`, `/sitemap_index.xml` and `/wp-sitemap.xml`.
- **Follows sitemap indexes** up to 5 levels deep, so sites with hundreds of sitemap files work.
- **Reads every common format:** XML sitemaps, gzip files (`.xml.gz`), plain text sitemaps with one URL per line, RSS and Atom feeds.
- **Streams large files.** Sitemaps are parsed while they download, so a 50 MB file does not need 50 MB of memory, and reading stops as soon as your limit is reached.
- **Tolerates broken XML.** Missing closing tags, stray characters and HTML error pages do not end the run.
- **Removes duplicates** within a site, also across sitemap files.
- **Optional filter** with a regular expression, for example only `/blog/` or only product pages.
- Plain HTTP, no browser. Fast and cheap.
- Polite to servers: at most 2 parallel requests per host, a short pause between requests, and a User-Agent that names the tool.

### Use cases

- **SEO agencies:** full URL list for audits, find orphan pages, compare the sitemap with what is indexed, check `lastmod` freshness.
- **Site owners:** see what your CMS really puts in the sitemap, find test pages or old content that should not be there, check hreflang alternates after a relaunch.
- **Migrations:** export all old URLs to build the redirect map.
- **Sales and market research:** size a competitor's catalogue or blog, track new pages by `lastmod`.
- **Crawling and AI pipelines:** feed the URL list into a scraper or a Markdown converter instead of crawling link by link.

### Input

| Field | Description | Default |
|---|---|---|
| Sites | Domains (`apify.com`), home pages, or direct sitemap URLs (`https://example.com/sitemap.xml`) | |
| Max URLs per site | Stop after this many unique URLs per site, up to 1,000,000 | 10,000 |
| Include metadata | lastmod, changefreq, priority, images, hreflang alternates | on |
| URL filter | Regular expression, case insensitive. Only matching URLs are returned | empty |
| Follow sitemap indexes | Open the sitemaps listed in an index file | on |
| Timeout | Seconds without data before a sitemap file is given up | 30 |
| Parallel sites | Sites read at the same time, 1 to 10 | 3 |

### Output

One dataset item per URL:

```json
{
  "site": "https://www.ikea.com",
  "url": "https://www.ikea.com/ee/et/p/zebrasaev-laelamp-valge-plast-10522481/",
  "lastmod": "2026-11-10T11:54:20.095Z",
  "changefreq": "weekly",
  "priority": 1,
  "sitemapUrl": "https://www.ikea.com/sitemaps/prod-et-EE_1.xml",
  "images": ["https://www.ikea.com/ee/et/images/products/zebrasaev-laelamp-valge-plast__1286742_pe933703_s5.jpg"],
  "error": null
}
```

- `lastmod`, `changefreq` and `priority` are `null` when the sitemap does not set them. For RSS feeds `lastmod` is the publication date.
- `images` and `alternates` (`[{ "hreflang": "de", "url": "..." }]`) appear only when the sitemap lists them.
- `sitemapUrl` is the file the URL came from.

A site without any sitemap returns one item with `url: null` and an `error` that says what was checked, for example `No sitemap found. Checked robots.txt and /sitemap.xml, /sitemap_index.xml, /wp-sitemap.xml.` A summary per site (URLs, sitemap files read, files failed, time) is written to the run log.

Export as JSON, CSV or Excel, or read it through the Apify API.

### Pricing

Pay per extracted URL. Error items, duplicates and URLs removed by the filter are not charged. Set "Max URLs per site" and the maximum charge per run in Apify to keep the cost under control.

Each run also has a start fee of 0.00005 USD per GB of memory, which Apify shows as Actor Start.

### Limits

- Only sitemaps the site publishes. Pages that are not in any sitemap are not found, because this tool does not crawl links.
- Sitemap files larger than 50 MB (100 MB after unpacking) are read up to that size.
- Sitemap indexes are followed 5 levels deep.
- Sitemaps behind a login, a bot wall or a captcha return an error for that file.
- Only public `http` and `https` addresses. Local and private network addresses are refused, also after redirects.

### Data source, permitted use and legal

- **Data source:** robots.txt files and sitemaps the websites publish themselves. The Actor does not crawl pages.
- **Snapshot:** Results show the source at the time of the run. We do not guarantee that they are complete, current or correct.
- **For business use:** This Actor is offered to businesses only, not to consumers.
- **Permitted use:** Process only content you are allowed to access and use, for example your own websites and documents or public pages you have a legitimate reason to process. Respect the terms of the websites and the rights in the content.
- **Your responsibility:** You choose the URLs and decide what happens with the results. If results contain personal data, you are the controller and need your own legal basis.
- **No circumvention:** The Actor does not log in, solve captchas or bypass paywalls, bot protection or other access restrictions. Do not use it for that.
- **Request volume:** At most 2 parallel requests per host with a short pause between requests. Do not use it to put excessive load on a website.
- **Provider:** forgeloop, Markus Heiss, Austria. [Imprint](https://devhem.github.io/forgeloop-legal/imprint.html), [Privacy Notice](https://devhem.github.io/forgeloop-legal/privacy.html), [Terms of Use](https://devhem.github.io/forgeloop-legal/terms.html).

### Questions and issues

Open an issue on the Actor page.

# Actor input Schema

## `sites` (type: `array`):

Domains or URLs. A domain or home page (apify.com) means: find the sitemaps through robots.txt and the usual locations. A URL of a sitemap file (https://example.com/sitemap.xml) is read directly. A missing https:// is added automatically. Format: a list of strings like \["example.com", "https://example.com/sitemap.xml"].

## `maxUrlsPerSite` (type: `integer`):

Stop reading the sitemaps of a site after this many unique URLs. Every URL is one charged result.

## `includeMeta` (type: `boolean`):

Add lastmod, changefreq and priority, plus image URLs and hreflang alternates when the sitemap lists them. Off returns only the URL and the sitemap it came from.

## `filterRegex` (type: `string`):

Keep only URLs that match this regular expression, case insensitive. Example: /blog/ or /products/ . Empty keeps all URLs. Filtered URLs are not charged.

## `followSitemapIndex` (type: `boolean`):

Open the sitemaps listed in a sitemap index file, up to 5 levels deep. Off reads only URL lists that are given or found directly.

## `timeoutSeconds` (type: `integer`):

Give up on a sitemap file when no data arrives for this many seconds.

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

How many sites are read at the same time. Each site gets at most 2 parallel requests, so the target servers are not stressed.

## Actor input object example

```json
{
  "sites": [
    "apify.com",
    "https://www.python.org"
  ],
  "maxUrlsPerSite": 10000,
  "includeMeta": true,
  "followSitemapIndex": true,
  "timeoutSeconds": 30,
  "maxConcurrency": 3
}
```

# Actor output Schema

## `results` (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 = {
    "sites": [
        "apify.com",
        "https://www.python.org"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("forgeloop/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 = { "sites": [
        "apify.com",
        "https://www.python.org",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("forgeloop/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 '{
  "sites": [
    "apify.com",
    "https://www.python.org"
  ]
}' |
apify call forgeloop/sitemap-extractor --silent --output-dataset

```

## MCP server setup

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