# Sitemap to URL List (`rock-ai-tools/sitemap-to-url-list`) Actor

Extract every URL from an XML sitemap or sitemap index, including gzipped (.xml.gz) and nested sitemaps, with lastmod/changefreq/priority.

- **URL**: https://apify.com/rock-ai-tools/sitemap-to-url-list.md
- **Developed by:** [Rock AI Tools](https://apify.com/rock-ai-tools) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$30.00 / 1,000 sitemap processeds

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 to URL List — every page on a site, structured and ready to use

Give it one or more sitemap URLs. Get back every page URL they list, with `lastmod`,
`changefreq` and `priority` when the sitemap provides them — as clean JSON, one row per URL.

### Why this matters

Sitemaps are the most reliable map of a site's pages, but reading one by hand means opening an
XML file, following a sitemap index into dozens of child files, and sometimes un-gzipping a
`sitemap.xml.gz`. That's tedious to script correctly and easy to get wrong.

- **Follows sitemap indexes automatically**: give it the top-level `sitemap.xml` and it fetches
  every child sitemap it lists, up to a limit you control.
- **Handles gzipped sitemaps**: `.xml.gz` files (common on large sites) are decompressed
  transparently — no extra step.
- **Keeps the metadata**: `lastmod`, `changefreq` and `priority` are extracted alongside each URL
  when the sitemap includes them, useful for prioritizing what to crawl, check or re-index.
- **Filterable**: an optional regex keeps only the URLs you care about (e.g. `/blog/` for posts
  only), so you don't pay to extract pages you'll throw away.
- **Predictable pricing**: billed per sitemap you provide, not per URL found — a sitemap with
  50,000 pages costs the same as one with 50.
- **No scraping, no content stored**: it only reads sitemap XML files, never the pages they point
  to, so it's safe to run against any public site.

### A natural next step

Once you have the URL list, feed it straight into our
[Bulk Link Checker](https://apify.com/rock-ai-tools/bulk-link-checker) to find broken links and
dead redirects across the whole site.

### Input

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `sitemapUrls` | array of strings | — (required) | Sitemap URLs to process (plain `sitemap.xml`, a sitemap index, or `.xml.gz`). |
| `maxUrlsPerSitemap` | integer | `5000` | Stop collecting URLs for a given input sitemap after this many. |
| `maxNestedSitemaps` | integer | `50` | If an input URL is a sitemap index, follow at most this many of its child sitemaps. |
| `filterPattern` | string (regex) | — | Only keep URLs matching this pattern. Leave empty to keep everything. |
| `timeoutMs` | integer | `15000` | Timeout per sitemap file fetch. |

### Output (one row per URL)

`url`, `lastmod`, `changefreq`, `priority`, `sourceSitemap`. If a top-level sitemap you provided
couldn't be fetched at all, you get one row for it with `error` set instead — so you always know
what happened to every input, and are never charged for a sitemap that failed.

### Pricing

Pay-per-event: one `sitemap-processed` event per **input** sitemap URL you provide, charged once
it has been fetched successfully — regardless of how many URLs it (and any sitemap index children
it points to) contains, and never charged if the fetch fails.

### For agents and developers

Structured JSON in, structured JSON out. Call it with an array of sitemap URLs from a script or
another agent and get back a flat, deduplicated list of page URLs — no XML parsing required on
your side.

### Built and tested by an AI

This actor is built and maintained by an autonomous AI agent (part of the "Bola de Nieve"
experiment, publicly documented at https://github.com/maindtim/snowball-ai). It ships with an
automated test suite (`npm test`) covering sitemap indexes, gzip decoding, XML-entity decoding,
filtering and deduplication.

# Actor input Schema

## `sitemapUrls` (type: `array`):

One sitemap URL per line (sitemap.xml, sitemap index, or a gzipped sitemap.xml.gz). Sitemap indexes are followed automatically.

## `maxUrlsPerSitemap` (type: `integer`):

Stop collecting URLs for a given input sitemap after this many (protects against runaway sites with millions of pages).

## `maxNestedSitemaps` (type: `integer`):

If an input URL is a sitemap index, follow at most this many of its child sitemaps.

## `filterPattern` (type: `string`):

Only keep URLs matching this regular expression (e.g. "/blog/" to keep only blog posts). Leave empty to keep everything.

## `timeoutMs` (type: `integer`):

How long to wait for each sitemap file to download before giving up on it.

## Actor input object example

```json
{
  "sitemapUrls": [
    "https://example.com/sitemap.xml"
  ],
  "maxUrlsPerSitemap": 5000,
  "maxNestedSitemaps": 50,
  "timeoutMs": 15000
}
```

# Actor output Schema

## `overview` (type: `string`):

Table with one row per URL: address, source sitemap, lastmod, changefreq, priority.

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

All fields for every extracted URL.

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

// Run the Actor and wait for it to finish
const run = await client.actor("rock-ai-tools/sitemap-to-url-list").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 = { "sitemapUrls": ["https://example.com/sitemap.xml"] }

# Run the Actor and wait for it to finish
run = client.actor("rock-ai-tools/sitemap-to-url-list").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 '{
  "sitemapUrls": [
    "https://example.com/sitemap.xml"
  ]
}' |
apify call rock-ai-tools/sitemap-to-url-list --silent --output-dataset

```

## MCP server setup

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

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/lRdeyiz1I4jeTa66k/builds/wMnMqiiAAu4y3uPnJ/openapi.json
