# Sitemap URLs Extractor: Every URL, lastmod, Images, Hreflang (`sebdata/sitemap-urls-extractor`) Actor

Every URL from the sitemaps of many websites in one run. Finds sitemaps through robots.txt and the usual paths, follows indexes, reads XML, gzip, text and RSS/Atom. One row per URL with lastmod, changefreq, priority and source sitemap. Filters by pattern and date.

- **URL**: https://apify.com/sebdata/sitemap-urls-extractor.md
- **Developed by:** [Sebastian](https://apify.com/sebdata) (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.30 / 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

### What does Sitemap URLs Extractor do?

Give Sitemap URLs Extractor websites and get back **every URL their sitemaps list, one row per URL,
with `lastmod`, `changefreq`, `priority` and the sitemap file it came from**. It finds the sitemaps
itself (robots.txt, then the usual paths), follows sitemap indexes up to 5 levels deep, and reads XML, gzip, plain
text and RSS/Atom. Many sites in one run.

- **Price:** $0.30 per 1,000 URLs ($0.0003 per URL). You pay only for rows saved to the dataset; a
  site without a sitemap, a blocked site or a dead domain costs nothing.
- **Many sites per run:** up to 500 websites or sitemap addresses, read 4 at a time.
- **Finds the sitemaps for you:** or give the address of one sitemap or sitemap index to read only that.
- **Filters:** keep or skip URLs by text or regular expression, and keep only URLs modified on or
  after a date ("7 days" works too, for scheduled runs).
- **Image, video, news and hreflang data** on request, as lists on each row.
- **Tolerant:** gzip recognised by its content, not its name; broken XML still gives its URLs.
- **Fast and light:** plain HTTP, no browser; files are streamed, so a sitemap of any size fits in
  512 MB. In a local test 97,334 URLs from 4 sites took 214 seconds (most of it writing rows to
  disk) with a memory peak of 179 MB.

### Input example

```json
{
    "sites": ["https://www.sitemaps.org", "yoast.com", "https://www.mkdocs.org/sitemap.xml.gz"],
    "maxUrlsPerSite": 5000,
    "includePatterns": ["/blog/", "\\.html$"],
    "excludePatterns": ["/tag/"],
    "modifiedAfter": "2026-01-01",
    "includeExtensions": false
}
```

| Field | What it does | Default |
|---|---|---|
| `sites` | Websites (`example.com`, `https://www.example.com`) or direct sitemap addresses. An address is read as a sitemap when its path ends in `.xml`, `.xml.gz` or `.txt`, or contains `sitemap`. Up to 500. Required. | |
| `maxUrlsPerSite` | Stop after this many saved URLs per entry of `sites`; no further sitemap files are fetched. `0` = no limit. | `10000` |
| `includePatterns` | Keep a URL only if it matches at least one. Each pattern is text the URL must contain, or a regular expression. Case-sensitive. | none |
| `excludePatterns` | Drop a URL if it matches any. Applied after `includePatterns`. | none |
| `modifiedAfter` | Keep only URLs whose `lastmod` is on or after this: `2026-01-31`, `2026-01-31T12:00:00Z`, or an age such as `7 days`, `2 weeks`, `3 months`. See "Dates" below. | none |
| `includeExtensions` | Add `images`, `videos`, `news` and `alternates` (hreflang) to the rows whose sitemap entry has them. | `false` |
| `proxyConfiguration` | Optional proxy. Usually not needed. | none |

### Output example

A row, as saved from `https://www.learnenough.com/sitemap.txt` (which is gzipped XML despite its name):

```json
{
    "url": "https://www.learnenough.com/blog",
    "lastmod": "2024-02-22T02:01:21.000Z",
    "changefreq": "weekly",
    "priority": 0.8,
    "sitemapUrl": "https://www.learnenough.com/sitemap.txt",
    "site": "https://www.learnenough.com/sitemap.txt"
}
```

With `includeExtensions` on, from a Shopify store given as `www.deathwishcoffee.com`:

```json
{
    "url": "https://www.deathwishcoffee.com/products/valhalla-java-single-serve-pods",
    "lastmod": "2026-11-14T08:11:24.000Z",
    "changefreq": "daily",
    "priority": null,
    "sitemapUrl": "https://www.deathwishcoffee.com/sitemap_products_1.xml?from=171104582&to=15420124135479",
    "site": "www.deathwishcoffee.com",
    "images": [
        {
            "url": "https://cdn.shopify.com/s/files/1/0271/7209/files/Valhalla_Java_10ct_Angle_Vertical_Pods_A1_2.jpg?v=1733925456",
            "title": "Valhalla Java Single-Serve Pods",
            "caption": "Death Wish Coffee 10 Count Valhalla Java Single-Serve Pods."
        }
    ]
}
```

| Field | Meaning |
|---|---|
| `url` | The page address as the sitemap gives it (XML entities decoded, relative addresses resolved). |
| `lastmod` | A date (`2026-01-31`) when the sitemap gives no time, otherwise ISO 8601 in UTC. `null` when absent or unreadable. |
| `changefreq`, `priority` | The sitemap's hints, `null` when absent. |
| `sitemapUrl` | The sitemap file the URL was read from. |
| `site` | The entry of `sites` it belongs to, as you typed it. |
| `images` | `url`, `title`, `caption`. |
| `videos` | `title`, `description`, `thumbnailUrl`, `contentUrl`, `playerUrl`, `durationSeconds`, `publicationDate`. |
| `news` | `title`, `publicationName`, `language`, `publicationDate`. |
| `alternates` | `hreflang`, `href`. |

The four lists appear only with `includeExtensions`, and only on rows that have them; empty fields
inside them are left out. Export the dataset as JSON, CSV or Excel, or read it through the Apify API.

### How discovery works

For a website:

1. `robots.txt` is read and every `Sitemap:` line is followed (they may point to another host).
2. If robots.txt names none (or none of those could be read), these addresses are tried in order
   and the first that is a sitemap is used: `/sitemap.xml`, `/sitemap_index.xml`,
   `/sitemap-index.xml`, `/sitemap.txt`, `/wp-sitemap.xml`.
3. Sitemap indexes are followed, index inside index up to 5 levels, each file once (so a sitemap that
   lists itself cannot loop), up to 5,000 sitemap files per site.

For a direct sitemap address only that file is read, plus the files it lists if it is an index.

What it reads: XML sitemaps and indexes with any namespace prefix, with or without an XML
declaration, a byte-order mark or CDATA; gzip files (recognised by their first bytes, so a
mislabelled `.txt` or `.xml` works, and so does a plain file named `.gz`); text sitemaps with one URL
per line; RSS and Atom feeds listed as sitemaps (the item link and its date). XML is not parsed
strictly: an entry with a missing closing tag, a bare `&`, junk before the declaration or a file cut
off in the middle still gives its URLs. A download that breaks off is restarted up to twice and
carries on where it stopped.

Each URL is saved once per site, the first time it is seen, even if several sitemaps list it.

### Dates: `lastmod` and `modifiedAfter`

- A `lastmod` without a time covers its whole day: with `modifiedAfter` `2026-01-31T12:00:00Z`, a
  URL dated `2026-01-31` is kept. A time without a zone is read as UTC.
- **URLs without a `lastmod` are dropped when `modifiedAfter` is set.** The filter means "known to
  have changed since"; a URL with no date cannot show that. They are counted in `urlsFilteredOut`.
- **Child sitemaps that an index dates before `modifiedAfter` are not fetched** (counted in
  `sitemapFilesSkippedOld`). This saves most of the requests on large sites, and relies on the
  site's index dates being right. Child sitemaps without a date in the index are always read.
- An age (`7 days`) is counted back from the start of the run; a month is 30 days, a year 365.

### The run summary

The key-value store record `SUMMARY` has the totals, the peak memory, and one `siteReport` entry
per input:

```json
{
    "input": "yoast.com",
    "status": "ok",
    "discovery": "robots",
    "sitemapsFound": 1,
    "sitemapFilesRead": 22,
    "sitemapFilesFailed": 0,
    "sitemapFilesSkippedOld": 0,
    "sitemapFilesSkipped": 0,
    "urlsFound": 2646,
    "urlsSaved": 2524,
    "urlsFilteredOut": 0,
    "duplicates": 122,
    "entriesInvalid": 0
}
```

- `discovery`: how the sitemaps were found: `robots`, `guess` (one of the usual paths) or `direct`.
  `sitemapsFound` counts the starting sitemaps; `sitemapFilesRead` counts every file, indexes included.
- `status`: `ok`; `partial` (some sitemap files failed, the site started refusing requests, or the
  5,000-file or 5-level limit was hit; `failedFiles` lists failed files with reasons); `no_sitemap`; `blocked` (the site answers 401, 403 or 429);
  `unreachable` (no answer, for example a domain that does not exist); `error`. A `message` says
  what happened in words.
- `entriesInvalid`: sitemap entries without a usable address.

Sites that give nothing are reported here and in the log, are not charged, and do not fail the run.
The run fails only on invalid input, or when not a single site could be read.

### Limits

- 500 sites per run; 5,000 sitemap files and 5 index levels per site; a single sitemap is read up to
  300 MB uncompressed (the standard allows 50 MB).
- **The filters do not cap the reading.** `maxUrlsPerSite` counts saved URLs, so with narrow filters
  on a very large site the Actor may read many sitemap files to find them.
- Only what the sitemaps list: pages a site leaves out of its sitemaps are not found, and no page is
  opened. `lastmod`, `changefreq` and `priority` are the site's own claims.
- Polite by design: at most 2 sitemap files of a site at a time with a short pause between files,
  retries with backoff, and after 3 refusals in a row (401, 403, 429) the site is left alone and
  reported as `blocked`. Sites behind a browser check (a "Just a moment..." page) are reported, not
  worked around; a proxy in the input sometimes helps.
- Duplicates are detected with a 53-bit fingerprint of the URL instead of the URL itself, to keep
  memory flat on sites with millions of URLs. Two different URLs sharing a fingerprint is possible
  in theory (about 1 chance in 18,000 across a million URLs of one site); one of them would then be counted as
  a duplicate.
- Text encodings other than UTF-8 and UTF-16 are read as UTF-8; addresses are plain ASCII in
  practice, so this rarely matters.
- **Spending limit:** if you set a maximum charge for the run, the Actor stops when it is reached
  and keeps what it has saved.
- Only public sitemap files are read: no login, no personal data.

### How to use Sitemap URLs Extractor

1. Open the **Input** tab and paste websites (`example.com`) or direct sitemap addresses, one per line.
2. Set **Maximum URLs per site** to cap the cost: each saved URL is charged.
3. Optional: keep or skip URLs by pattern, or set **Modified on or after** to a date or an age such as `7 days`.
4. Press **Start**, then open the **Output** tab: one row per URL with `lastmod` and the sitemap it came from.
5. Download the rows as JSON, CSV, Excel or HTML, or read them through the API.

### How much does Sitemap URLs Extractor cost?

**$0.30 per 1,000 URLs**, charged per URL saved to the dataset. The price includes the platform
usage of the run: there is no separate charge for compute.

| Run | For example | Cost |
|---|---|---|
| 1,000 URLs | a small site | $0.30 |
| 10,000 URLs | the default cap for one site | $3.00 |
| 100,000 URLs | a large shop or publisher | $30.00 |

A site without a sitemap, a blocked site or a dead domain is reported in the run summary and not charged. URLs removed by your filters are not charged. To cap a run, set a maximum charge when you start it: the Actor stops
there and keeps what it has saved.

### API, schedules and integrations

Sitemap URLs Extractor runs like every Apify Actor: from the Console, through the Apify API and its JavaScript and
Python clients, on a schedule, from a webhook, from workflow tools such as Make, n8n and Zapier, and as a
tool for AI agents through the Apify MCP server. A daily schedule with `modifiedAfter: "1 day"` returns, and charges for, only the pages that are new or changed.

```js
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('sebdata/sitemap-urls-extractor').call({ sites: ['https://www.sitemaps.org'], maxUrlsPerSite: 1000 });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

### Related Actors

- [ATS Jobs Scraper](https://apify.com/sebdata/ats-jobs-feed): jobs from Greenhouse, Lever, Ashby, Workable, Recruitee and SmartRecruiters in one schema.
- [WHOIS Domain Lookup via RDAP](https://apify.com/sebdata/domain-rdap-lookup): registration, expiry, registrar and nameservers for a list of domains.
- [Contact Page Finder](https://apify.com/sebdata/contact-page-finder): contact page, contact form, social profiles and role addresses for a list of websites.
- [Website Tech Stack Detector](https://apify.com/sebdata/tech-stack-detector): the technologies a list of websites runs on, with the evidence for each.

### Typical uses

A URL list for a crawler or scraper, content audits and migrations, finding new or recently changed
pages (schedule a run with `modifiedAfter: "1 day"`), following a competitor's new pages, checking a
site's own sitemaps for gaps and duplicates, hreflang and image-sitemap audits, feeding a site's
pages to an LLM or agent.

### Who maintains this

This Actor is built and maintained by an AI agent (Anthropic's Claude), under a human account owner.
Report a problem in the Issues tab: it is read and answered.

# Actor input Schema

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

One per line, up to 500. A website (example.com or https://www.example.com): its sitemaps are found through robots.txt, then the usual paths. Or the address of one sitemap or sitemap index (ending in .xml, .xml.gz or .txt, or containing "sitemap"): only that one is read.

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

Stop after this many saved URLs for each entry above; no further sitemap files are fetched. 0 = no limit. Each URL saved is charged.

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

Optional. Keep a URL only if it matches at least one of these. Each line is a piece of text the URL must contain (/blog/) or a regular expression (.html$, ^https://shop.). Case-sensitive.

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

Optional. Drop a URL if it matches any of these (text or regular expression, as above). Applied after "Only URLs matching".

## `modifiedAfter` (type: `string`):

Optional. Keep only URLs whose lastmod is on or after this: a date (2026-01-31), a date and time (2026-01-31T12:00:00Z) or an age (7 days, 2 weeks, 3 months). URLs without a lastmod are dropped, and child sitemaps that an index dates earlier are not fetched.

## `includeExtensions` (type: `boolean`):

Adds the lists images, videos, news and alternates (hreflang) to each URL whose sitemap entry has them. Off = a smaller, flat output.

## `proxyConfiguration` (type: `object`):

Optional. Most sites serve their sitemaps without a proxy; a few refuse datacenter addresses.

## Actor input object example

```json
{
  "sites": [
    "https://www.sitemaps.org",
    "https://docs.apify.com"
  ],
  "maxUrlsPerSite": 100,
  "includeExtensions": false
}
```

# Actor output Schema

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

All rows saved by the run (the default dataset).

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

Counts, and every input that could not be read with its reason (SUMMARY record in the default key-value store).

# 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": [
        "https://www.sitemaps.org",
        "https://docs.apify.com"
    ],
    "maxUrlsPerSite": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("sebdata/sitemap-urls-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": [
        "https://www.sitemaps.org",
        "https://docs.apify.com",
    ],
    "maxUrlsPerSite": 100,
}

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

```

## MCP server setup

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