# Sitemap URL Extractor - XML Sitemap to URL List (`uszatki/sitemap-url-extractor`) Actor

Every URL from a site's sitemaps: give a domain or a sitemap URL and get each URL with its last-modified date, change frequency, priority and image, video, news and hreflang data. Follows sitemap indexes, reads gzipped and plain-text sitemaps and RSS or Atom feeds.

- **URL**: https://apify.com/uszatki/sitemap-url-extractor.md
- **Developed by:** [Uszatki Ltd](https://apify.com/uszatki) (community)
- **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 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 URL Extractor

Get every URL a site lists in its sitemaps. Give a domain or a sitemap URL; the Actor finds the sitemaps, follows sitemap indexes, and returns one item per URL with its last-modified date, change frequency, priority, the sitemap it came from, and any image, video, news or language data the sitemap carries.

It reads sitemap files over plain HTTP. It does not open the pages themselves, so a run with tens of thousands of URLs takes seconds to minutes.

### What it does

- **Finds the sitemaps** of a domain: the `Sitemap:` lines in robots.txt first, then `/sitemap.xml` and other usual paths.
- **Follows sitemap indexes**, including indexes inside indexes, up to 5 levels below the start.
- **Reads every common format:** XML sitemaps, gzipped sitemaps (`.xml.gz`), plain-text sitemaps (one URL per line), and RSS and Atom feeds used as sitemaps.
- **Keeps the extra data:** image URLs, video details, news publication data and hreflang language versions, as compact fields.
- **Filters:** URL patterns to include or exclude, and a "modified on or after" date.
- **Removes duplicates** across sitemaps.
- **Reports what happened:** every sitemap file read, how many URLs each gave, and every error, in a run summary.

### Who it is for

- SEO specialists checking what a site asks search engines to index, or comparing a sitemap with a crawl.
- Developers who need a site's URL list as the input for another scraper, a monitor or a migration.
- Content and data teams tracking what a site published or changed since a given date.

### Input

Only `startUrls` is required.

| Field | Type | Default | What it does |
| --- | --- | --- | --- |
| `startUrls` | array of strings | required | Domains or sitemap URLs. A domain or home page (`example.com`) means "find this site's sitemaps". Anything with a path (`https://example.com/sitemap_index.xml`) is read as a sitemap. |
| `maxUrls` | integer | `10000` | The most URLs returned in one run. Hard limit: 1,000,000. |
| `modifiedSince` | date | none | Return only URLs whose `lastmod` is on or after this date (`2026-01-31`, or a full ISO 8601 date and time). |
| `includePatterns` | array of regular expressions | none | A URL is returned only if it matches at least one. |
| `excludePatterns` | array of regular expressions | none | A URL is left out if it matches any. |
| `deduplicate` | boolean | `true` | Return each URL once, even when several sitemaps list it. |
| `userAgent` | string | see below | Replaces the default User-Agent. |

Patterns are JavaScript regular expressions tested against the URL. Limits: at most 50 patterns per list, 500 characters per pattern. A pattern that backtracks heavily slows your own run, so keep patterns simple.

#### Input example

```json
{
    "startUrls": ["https://crawlee.dev/"],
    "maxUrls": 100
}
```

### Output

One dataset item per URL. These are real items from runs on 19 November 2026. The first is from the input above; the second is from a run on a site whose sitemap lists images.

```json
{
    "url": "https://crawlee.dev/blog",
    "lastmod": null,
    "changefreq": "weekly",
    "priority": 0.5,
    "sourceSitemap": "https://crawlee.dev/sitemap.xml",
    "images": [],
    "videos": [],
    "news": null,
    "alternates": []
}
```

```json
{
    "url": "https://yoast.com/december-2025-edition-the-seo-update-by-yoast/",
    "lastmod": "2026-01-06T08:46:41+00:00",
    "changefreq": null,
    "priority": null,
    "sourceSitemap": "https://yoast.com/post-sitemap.xml",
    "images": ["https://yoast.com/app/uploads/2025/12/seo_recap_yoast_december_2025.jpeg"],
    "videos": [],
    "news": null,
    "alternates": []
}
```

Every item has the same fields in the same order.

| Field | Meaning |
| --- | --- |
| `url` | The page URL: `<loc>` of a sitemap entry, the link of a feed item, or a line of a text sitemap. |
| `lastmod` | The last-modified date exactly as the sitemap gives it (a date, or a date and time). For RSS and Atom items, the item's date as ISO 8601. `null` when not given. |
| `changefreq` | `always`, `hourly`, `daily`, `weekly`, `monthly`, `yearly` or `never`, lower-cased. `null` when not given. |
| `priority` | 0.0 to 1.0. `null` when not given. |
| `sourceSitemap` | The sitemap file the URL was read from. |
| `images` | Image URLs listed for the page (up to 100). Empty when there are none. |
| `videos` | Videos listed for the page (up to 20), each with `title`, `thumbnailUrl`, `contentUrl`, `playerUrl`, `durationSecs`, `publicationDate`. Empty when there are none. |
| `news` | News sitemap data: `publicationName`, `language`, `publicationDate`, `title`. `null` when there is none. |
| `alternates` | Language versions listed for the page (up to 100), each with `hreflang` and `href`. Empty when there are none. |

#### Run summary

Each run also saves a summary under the key `OUTPUT` in the run's key-value store:

- `totals`: sitemaps read and failed, addresses refused, URLs found and returned, duplicates removed, URLs left out by each filter (`excludedByPattern`, `tooLongForPatterns`, `olderThanModifiedSince`, `withoutLastmod`), invalid entries, and child sitemaps skipped;
- `startUrls`: for each start entry, how its sitemaps were found (`robots.txt`, a usual path such as `/sitemap.xml`, or `given`), how many sitemaps and URLs it gave, and any error;
- `sitemaps`: every sitemap file with its kind (`urlset`, `sitemapindex`, `rss`, `atom`, `text`), depth, parent, URLs found and returned, size, and error (up to 2,000 files listed);
- `errors`: every file that could not be read and why;
- `refused`: every address that was refused because it is not on the public web, with `url`, `reason` (for example `loopback-address`, `resolves-to-loopback-address`, or `redirect to a refused address (…)`) and `refusedHop`, the URL that was refused. Nothing is requested from a refused address and nothing is charged;
- `httpRequests`, the requests actually handed to the network, and `refusedBeforeRequest`, the attempts refused before any connection was opened;
- `stoppedBy`: `max-urls`, `charge-limit`, `share-of-max-urls`, `max-sitemaps`, or `null` when everything was read;
- `peakMemoryMb` and `charging`.

For the example run it reported: 1 sitemap read, 101 URLs found before the run stopped at `maxUrls`, 100 returned, 2 HTTP requests, 0.9 seconds. A run on a documentation site with `maxUrls` 50,000 read one index and 9 gzipped sitemaps (446 kB downloaded) and returned 50,000 URLs in 10 seconds on a development machine.

### Pricing

This Actor uses pay-per-event pricing. You pay for URLs returned, not for run time.

| Event | Price | When |
| --- | --- | --- |
| URL returned (`url-result`) | US$0.0005 | For each URL saved to the dataset. |
| Actor start (`apify-actor-start`) | US$0.00005 | Once per run. |

Examples: 100 URLs cost about US$0.05; 10,000 URLs about US$5.00; 50,000 URLs about US$25.00. The prices shown on the Actor's Pricing tab are the ones that apply.

URLs removed by your filters, duplicates, invalid entries and sitemap files that cannot be read are not charged.

You control the cost in two ways: `maxUrls` caps the number of URLs, and the run's **maximum charge** (set in the run options) is never exceeded. When the maximum charge is reached the Actor stops cleanly: you receive exactly the URLs you paid for, and the summary says the run stopped at the limit.

### How it behaves on the sites it visits

- **Identifies itself.** Default User-Agent: `sitemap-url-extractor/0.1 (reads XML sitemaps; plain HTTP; honours robots.txt)`.
- **Obeys robots.txt.** A sitemap file is not requested when the rules for `sitemap-url-extractor` or for `*` disallow its path. If robots.txt answers with a server error or cannot be reached, nothing on that site is requested. Only the first 500 KiB of a robots.txt, its first 5,000 rules and its first 1,000 `Sitemap:` lines are used.
- **Goes slowly.** One file at a time, at least 0.3 seconds between requests to the same site.
- **Backs off.** HTTP 429 and 5xx answers and network errors are retried twice with growing pauses; `Retry-After` is followed up to 30 seconds.
- **Public web only.** Only `http` and `https`. Private, loopback and link-local addresses, internal host names (`localhost`, single-label names, `.local`, `.internal` and similar), URLs with credentials, and ports below 1024 other than 80 and 443 are refused. The check is repeated for every child sitemap an index names and for every redirect, and host names that resolve to an internal address are refused when the connection is made.

### Limits

- **It lists what the sitemap says.** URLs are not opened or checked. A URL in a sitemap may be gone, and a page that is not in any sitemap is not found.
- **`lastmod` is the site's own claim.** `modifiedSince` trusts it. URLs without a readable `lastmod` are left out when `modifiedSince` is set. A child sitemap that its index marks as older than the date is not downloaded.
- **Several start entries share `maxUrls`.** Each gets an equal share of what is left, so the first one cannot use it all; what one does not use goes to those after it. The summary shows each share. Run sites separately if you want a fixed number from each.
- **Sizes.** At most 5,000 sitemap files per run, 5 levels of index below a start sitemap, 64 MB per file, both as sent and after decompression (the sitemap standard allows 50 MB). A larger file is read up to the limit and marked in the summary.
- **Entries.** A URL longer than 4,096 characters is counted as invalid. Relative URLs are resolved against the sitemap's own address.
- **Very long URLs and patterns.** When you set include or exclude patterns, a URL longer than 2,000 characters is not tested against them. It is left out, not charged, and counted in the summary as `tooLongForPatterns`. It is never let through untested. Without patterns, long URLs are returned as usual.
- **Text encoding.** Files are read as UTF-8, which the sitemap standard requires.
- **A damaged file** (for example a cut-off gzip) is reported as an error; URLs read before the damage are kept and charged.
- **Not a sitemap.** If a start URL with a path serves an HTML page, it is reported as "not a sitemap". To have the Actor look for a site's sitemaps, give the bare domain.
- **Memory.** A file is downloaded in its compressed form and then decompressed and read piece by piece; neither the decompressed file nor the list of URLs is held in memory. Duplicate removal keeps a short fingerprint of each returned URL, about 115 MB for a million URLs. The default of 512 MB is meant to cover the hard limit; if you lower the memory to 256 MB, keep `maxUrls` at a few hundred thousand or switch `deduplicate` off.

### FAQ

**Do I give a domain or a sitemap URL?**
Either. For a domain the Actor reads robots.txt and tries the usual paths. If you know the sitemap address, give it directly: it is faster and leaves no doubt.

**Why did I get fewer URLs than the sitemap has?**
Look at `totals` in the `OUTPUT` record: duplicates, your filters, `maxUrls`, your maximum charge, or files that could not be read each have their own count.

**Why did the run fail with "No sitemap could be read"?**
No file could be read as a sitemap: the address answered 404, served an HTML page, was disallowed by robots.txt, or was refused because it is not on the public web. The summary gives the reason for each file. Nothing was charged.

**Does it handle a sitemap index with thousands of child sitemaps?**
Yes, up to 5,000 files per run. Use `modifiedSince` to skip child sitemaps the index marks as unchanged.

**Can I get only new or changed URLs?**
Set `modifiedSince` to the date of your last run. This works as well as the site's `lastmod` values are kept up to date.

**Can it read sitemaps behind a login?**
No. It sends no cookies and no credentials.

**The site blocks the Actor (403 or 429). What can I do?**
If it is your site, allow the User-Agent, or set `userAgent` to one your firewall allows. This Actor does not use proxies and does not try to get around blocking.

**Something looks wrong in a result.**
Open an issue on the Actor's Issues tab with the sitemap URL and the item.

### Changelog

See the Changelog tab or [CHANGELOG.md](./CHANGELOG.md).

# Changelog

This Actor's version history is a separate document: https://apify.com/uszatki/sitemap-url-extractor/changelog.md

# Actor input Schema

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

One per line. A domain or home page such as "example.com" means: find this site's sitemaps (robots.txt first, then /sitemap.xml and other usual paths). Anything with a path, such as https://example.com/sitemap_index.xml, is read as a sitemap. Only public http and https addresses are accepted.

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

The most URLs one run returns. You pay per URL returned, so this also caps the cost of the run. With several start entries, each gets an equal share. Hard limit: 1000000.

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

Return only URLs whose last-modified date (lastmod) is on or after this date, for example 2026-01-31. URLs without a readable lastmod are left out when this is set, and child sitemaps that an index marks as older are not downloaded.

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

Regular expressions. When set, a URL is returned only if it matches at least one. Example: /blog/

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

Regular expressions. A URL is left out if it matches any. Example: ?page=\d+

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

Return each URL once, even when several sitemaps list it. The first occurrence is kept.

## `userAgent` (type: `string`):

Sent with every request. Leave empty for the default: sitemap-url-extractor/0.1 (reads XML sitemaps; plain HTTP; honours robots.txt). robots.txt rules are matched against the part before the first "/".

## Actor input object example

```json
{
  "startUrls": [
    "https://crawlee.dev/"
  ],
  "maxUrls": 100,
  "deduplicate": true
}
```

# Actor output Schema

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

One item per URL, with its last-modified date and the sitemap it came from.

## `summary` (type: `string`):

Sitemaps read, URLs per sitemap, errors, addresses refused, and what was 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": [
        "https://crawlee.dev/"
    ],
    "maxUrls": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("uszatki/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://crawlee.dev/"],
    "maxUrls": 100,
}

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

```

## MCP server setup

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