# Sitemap URL Extractor: Index, Gzip and robots.txt Sitemaps (`praise-most-high/sitemap-urls`) Actor

Sitemap URL extractor: list the URLs a site publishes in its XML sitemaps. Finds sitemaps through robots.txt, follows sitemap index files and reads gzip. One flat row per URL with lastmod, changefreq, priority and the sitemap it came from. Reads sitemap files only, never the pages they list.

- **URL**: https://apify.com/praise-most-high/sitemap-urls.md
- **Developed by:** [angel nguyen](https://apify.com/praise-most-high) (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 $0.50 / 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: Index, Gzip and robots.txt Sitemaps

This sitemap URL extractor returns every URL a website lists in its XML sitemaps, one row per URL. Give it a domain and it reads the site's robots.txt, finds the sitemap files named there, follows sitemap index files down to three levels and reads gzip-compressed sitemaps. Each row carries the site's own lastmod, changefreq and priority hints and the sitemap file the URL came from.

### What you get

- One flat row per URL, in the order the sitemaps list them.
- The sitemap file and nesting depth behind every row, so you can see where each URL was published.
- Each URL once per site, even when two sitemaps list it.
- A typed error row for every input or file that could not be read, at no charge.
- A `SUMMARY` record in the run's key-value store with per-file counts, robots.txt status per host and request counts.

The Actor reads robots.txt and sitemap files only. It never fetches the pages the sitemaps list.

### Input

The one required idea is `sites`. This is a complete input:

```json
{"sites": ["crawlee.dev"]}
```

The example input below is the one we measured (see "Measured run"):

```json
{"sites": ["crawlee.dev", "nodejs.org", "developer.mozilla.org"], "maxUrls": 20}
```

| Field | Type | What it does |
|---|---|---|
| `sites` | array of strings | A domain (`crawlee.dev`), a site URL (reduced to its origin), or the URL of one sitemap file (ending in `.xml` or `.xml.gz`, or with `sitemap` in its last path segment). At most 100 per run. |
| `includePattern` | string, optional | Keep only URLs containing this text, for example `/docs/`. Plain text, case ignored, not a regular expression. |
| `lastmodAfter` | string, optional | A date `YYYY-MM-DD`, for example `2025-01-01`. Keep only URLs whose lastmod is on or after that date. URLs with no lastmod are left out when you set this. |
| `maxUrls` | integer | Most URL rows per site, 1 to 50,000. Default 1000. Once a site reaches it, no further sitemap file of that site is read. |

How a site's sitemaps are found: first the `Sitemap:` lines of its robots.txt, in file order. When robots.txt names none, the Actor tries `/sitemap.xml` and then `/sitemap_index.xml`.

### Output fields

URL rows:

| Field | Type | Meaning |
|---|---|---|
| `site` | string | Origin of the site, e.g. `https://crawlee.dev` |
| `url` | string | The URL exactly as the sitemap lists it. Use it as the dedupe key. |
| `lastmod` | string | lastmod as published; empty string when absent |
| `lastmodIso` | string or null | lastmod as an ISO 8601 UTC time; null when absent or not a valid date |
| `changefreq` | string | changefreq as published; empty string when absent |
| `priority` | number or null | priority from 0 to 1; null when absent or out of range |
| `sitemapUrl` | string | The sitemap file this URL was read from |
| `sourceUrl` | string | Same as `sitemapUrl`: the one source of the row |
| `position` | integer | 1-based place of the URL in its sitemap file |
| `depth` | integer | 0 for a sitemap named by robots.txt, a default path or your input; plus one per index level |
| `isIndexChild` | boolean | true when the file was listed by a sitemap index |
| `discoveredVia` | string | `robots`, `default-path` or `input` |
| `checkedAt` | string | ISO 8601 UTC time the sitemap file was read |

Error rows add these fields and keep `sitemapUrl`:

| Field | Type | Meaning |
|---|---|---|
| `error` | boolean | Always true |
| `errorCode` | string | One of the codes below |
| `input` | string | The input entry the error belongs to |
| `httpStatus` | integer or null | The HTTP status, when there was one |
| `errorMessage` | string | What went wrong |

lastmod, changefreq and priority are hints the site chooses to publish, and many sites leave them out. In our measured run, 20 of 60 rows carried a lastmod, 40 of 60 a changefreq and 20 of 60 a priority.

A real row from the measured run:

```json
{"site": "https://crawlee.dev", "url": "https://crawlee.dev/blog", "lastmod": "", "lastmodIso": null, "changefreq": "weekly", "priority": 0.5, "sitemapUrl": "https://crawlee.dev/sitemap.xml", "sourceUrl": "https://crawlee.dev/sitemap.xml", "position": 1, "depth": 0, "isIndexChild": false, "discoveredVia": "robots", "checkedAt": "2026-11-20T17:34:36.100Z"}
```

### Measured run

On 2026-11-20 we ran the example input above from our own machine (a local run of this code, not on the Apify platform). It returned 60 URL rows, 20 per site, and 0 error rows in 4.6 seconds. For developer.mozilla.org the rows came from the first child of its sitemap index, a file of 14,895 entries.

### How the Actor honours robots.txt

Before any other request to a host, the Actor reads that host's robots.txt with its own User-Agent:

`sitemap-urls/0.1 (+https://apify.com/praise-most-high/sitemap-urls)`

Its product token is `sitemap-urls`. A robots.txt group for `sitemap-urls` wins over the group for every agent. The longest matching rule wins, and Allow wins a tie. A sitemap file whose path is disallowed is not read and gives a `ROBOTS_DISALLOWED` row.

- robots.txt answers 200: its rules apply, and its `Sitemap:` lines are used.
- robots.txt answers 400 to 499: every path is allowed. RFC 9309 (https://www.rfc-editor.org/rfc/rfc9309.html), section 2.3.1.3: "If a server status code indicates that the robots.txt file is unavailable to the crawler, then the crawler MAY access any resources on the server."
- robots.txt answers 429 or 500 to 599, times out or gives no answer: nothing on that host is read. RFC 9309, section 2.3.1.4: "If the robots.txt file is unreachable due to server or network errors, this means the robots.txt file is undefined and the crawler MUST assume complete disallow."
- A redirect to another host is checked against that host's robots.txt first.

Only point the Actor at sites you have the right to read. URLs are returned exactly as each site publishes them. If a site puts personal names in its URLs, handling that data lawfully is your responsibility.

### Limits

- One request at a time, and at least 1 second between two requests to the same host.
- A `Crawl-delay` in robots.txt is honoured up to 10 seconds.
- At most 100 sites per run and at most 50,000 URLs per site.
- Sitemap files follow the sitemaps.org limits: at most 50,000 entries and 50 MB uncompressed per file. A larger file gives a `SITEMAP_TOO_LARGE` row.
- Sitemap index files are followed to depth 3.
- XML sitemaps only. HTML sitemaps, RSS or Atom feeds and plain-text URL lists give a `SITEMAP_PARSE_ERROR` row.
- No proxy, no cookies, no login.

### Error codes

Each failed input or file gives one error row in the dataset. Error rows are never charged.

| Code | When |
|---|---|
| `NO_INPUT` | `sites` is empty |
| `INVALID_SITE` | An entry is not an http or https URL or domain |
| `ROBOTS_DISALLOWED` | robots.txt disallows the file, or could not be read (429, 5xx, no answer) |
| `SITEMAP_NOT_FOUND` | robots.txt names no sitemap and neither default path holds one |
| `SITEMAP_HTTP_ERROR` | A sitemap answered 404, 410, a second 429, a 5xx after one retry, or another error |
| `SITEMAP_PARSE_ERROR` | The file is not an XML urlset or sitemapindex |
| `SITEMAP_TOO_LARGE` | Over 50,000 entries or over 50 MB after gunzip |

A run that delivers at least one URL row ends SUCCEEDED. A run with no URL row ends FAILED, and its status message names the error codes.

### Pricing

- **0.0005 USD per URL** delivered (0.50 USD per 1,000 URLs).
- **0.00005 USD per run start**, charged by the Apify platform.

Error rows, duplicate URLs and URLs past `maxUrls` are free. If you set a maximum charge for a run, the Actor stops delivering rows when it is reached.

### For AI agents and the Apify MCP server

- One field is enough: `{"sites": ["example.com"]}`.
- Field names are flat, typed and stable. `url` is the dedupe key.
- Branch on `error`: a row with `error: true` carries `errorCode` and `input`, so an agent can retry or drop that one input.
- Use `maxUrls` to cap cost before the run: the most a run can charge for URL rows is sites times `maxUrls` times 0.0005 USD.

Example request body for a run:

```json
{"sites": ["nodejs.org"], "includePattern": "/learn/", "maxUrls": 50}
```

### Support and feedback

Questions, bugs and feature requests go to the Issues tab of this Actor's page. We answer issues within 14 days.

# Actor input Schema

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

One entry per line: a domain (crawlee.dev), a site URL (https://crawlee.dev/blog, reduced to its origin), or the URL of a sitemap file (ending in .xml or .xml.gz, or with sitemap in its last path segment). At most 100 sites per run.

## `includePattern` (type: `string`):

Optional. Keep only URLs that contain this text, for example /docs/. A plain substring, case ignored, never a regular expression.

## `lastmodAfter` (type: `string`):

Optional. A date YYYY-MM-DD, for example 2025-01-01. Keep only URLs whose lastmod is on or after it. A URL with no lastmod is left out when this is set.

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

Most URL rows to return for each site. Once reached, no further sitemap file of that site is read.

## Actor input object example

```json
{
  "sites": [
    "crawlee.dev"
  ],
  "maxUrls": 20
}
```

# Actor output Schema

## `rows` (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 = {
    "sites": [
        "crawlee.dev"
    ],
    "maxUrls": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("praise-most-high/sitemap-urls").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": ["crawlee.dev"],
    "maxUrls": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("praise-most-high/sitemap-urls").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": [
    "crawlee.dev"
  ],
  "maxUrls": 20
}' |
apify call praise-most-high/sitemap-urls --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,praise-most-high/sitemap-urls"
        }
    }
}
```

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/uIX02frglEsBt67E0/builds/8uFhM3O0oRR27BL5Q/openapi.json
