# Sitemap URL Extractor & Change Monitor: New & Removed Pages (`datatoolsforall/website-sitemap-extractor`) Actor

Give it a website, get every URL from its sitemaps: robots.txt discovery, nested indexes and .xml.gz, with lastmod, hreflang and image counts. Schedule it to see new and removed pages, filter by regex or date, and optionally check HTTP status. $0.20 per 1,000 URLs, no monthly fee.

- **URL**: https://apify.com/datatoolsforall/website-sitemap-extractor.md
- **Developed by:** [Data Tools for All](https://apify.com/datatoolsforall) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.12 / 1,000 page urls

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 & Change Monitor: New & Removed Pages

**Give it a website, get every URL from its sitemaps.** It finds them through **robots.txt**, common paths, **nested sitemap indexes** and **.xml.gz** files, and returns **one row per page URL** with lastmod, hreflang alternates and image counts. Schedule it with **Compare with previous run** to see which pages were added or removed, filter by regex or date, and optionally check each URL's HTTP status. Price: **$0.20 per 1,000 URLs** (pay per event, no monthly fee). To try it, run it with the prefilled input (`https://apify.com`, 200 URLs, about $0.04).

### What data can you get

| Field | What it contains |
|---|---|
| `url` | Page URL exactly as listed in the sitemap |
| `site` | Website the URL belongs to (origin of your start URL) |
| `sitemapUrl` | The sitemap file the URL was read from |
| `lastmod` | Last modification date from the sitemap (ISO 8601) or `null`. Values with a time zone are converted to UTC (`...Z`); a time without a zone is kept as written (`2026-06-23T01:02:37`, no `Z`) because its zone is unknown |
| `changefreq` | `always`, `hourly`, `daily`, `weekly`, `monthly`, `yearly`, `never` or `null` |
| `priority` | Number between 0.0 and 1.0, or `null` |
| `alternates` | hreflang language versions: `[{ "hreflang": "de", "href": "..." }]` |
| `imageCount`, `videoCount` | How many images and videos the sitemap lists for the page |
| `newsTitle` | Article title from Google News sitemaps, or `null` |
| `statusCode`, `redirectLocation` | HTTP status and redirect target (only with `checkUrlStatus`) |
| `statusCheckError` | Why a status is missing, e.g. `ROBOTS_DISALLOWED` (only with `checkUrlStatus`) |
| `diffStatus` | `new`, `unchanged` or `removed` (only with `compareWithPreviousRun`) |
| `discoveredAt` | When the URL was read (UTC) |
| `error`, `errorCode`, `sitemapsTried` | Filled only on error rows (see FAQ) |

Every row has all of these keys; values that do not apply are `null`. A **SUMMARY** record in the run's key-value store lists, per website, which sitemaps were found or failed and how many URLs were read, filtered or skipped; its `outcome` is `OK` or `PARTIAL` (see the FAQ).

### How to use

1. Open the Actor and add one or more websites or sitemap URLs to **Websites or sitemap URLs** (`startUrls`).
2. Set **Maximum URLs per website** (`maxUrlsPerSite`). Every billable row of a website counts towards it (page URLs and, in comparison mode, removed URLs), so it also caps your cost per website.
3. Optional: add **Only keep URLs matching** / **Skip URLs matching** regular expressions, or **Only URLs modified on or after** (`lastmodAfter`, a date or e.g. `30 days`).
4. Optional: turn on **Compare with previous run** and give it a schedule to get new and removed URLs every day or week.
5. Click **Start** and download the results as JSON, CSV, Excel or via API.

### Use with AI agents

- **Actor ID:** `datatoolsforall/website-sitemap-extractor`
- **MCP URL** (Claude, Cursor, VS Code, ChatGPT): `https://mcp.apify.com/?tools=datatoolsforall/website-sitemap-extractor` (sign in with your Apify account; runs bill to it)
- **Claude Code:** `claude mcp add --transport http sitemap "https://mcp.apify.com/?tools=datatoolsforall/website-sitemap-extractor"`
- **Minimal input:** `{"startUrls":["https://example.com"],"maxUrlsPerSite":500}` costs at most $0.10 (500 rows x $0.0002, plus the $0.00005 start fee). Always set `maxUrlsPerSite`: without it the default of 10,000 allows up to $2.00 per website.
- **Example prompt:** "List every URL in example.com's sitemap that changed in the last 30 days." (the agent sets `lastmodAfter` to `30 days`)
- **Python (LangChain):** `from langchain_apify import ApifyActorsTool; tool = ApifyActorsTool("datatoolsforall/website-sitemap-extractor")` (reads `APIFY_API_TOKEN` from the environment)
- **Reading the result:** one dataset row per page URL. Error rows have `errorCode` set, and only `NO_SITEMAP_FOUND` is charged. The `SUMMARY` record says whether a read was complete.

#### Input example

```json
{
    "startUrls": ["https://apify.com"],
    "maxUrlsPerSite": 200
}
```

More examples:

```json
{
    "startUrls": ["https://apify.com/sitemap.xml"],
    "maxUrlsPerSite": 2000,
    "includePatterns": ["/store/"],
    "compareWithPreviousRun": true,
    "stateKey": "apify-store-weekly"
}
```

#### Output example

Real rows from local test runs on 2026-11-25 (the first from the input above, the second from `https://css-tricks.com/post-sitemap.xml`):

```json
[
    {
        "url": "https://apify.com/about",
        "site": "https://apify.com",
        "sitemapUrl": "https://apify.com/sitemap/pages.xml",
        "lastmod": null,
        "changefreq": null,
        "priority": null,
        "alternates": [],
        "imageCount": 0,
        "videoCount": 0,
        "newsTitle": null,
        "statusCode": null,
        "redirectLocation": null,
        "statusCheckError": null,
        "diffStatus": null,
        "discoveredAt": "2026-11-26T01:49:15.979Z",
        "error": null,
        "errorCode": null,
        "sitemapsTried": null
    },
    {
        "url": "https://css-tricks.com/complete-guide-css-grid-layout/",
        "site": "https://css-tricks.com",
        "sitemapUrl": "https://css-tricks.com/post-sitemap.xml",
        "lastmod": "2026-09-30T19:06:45.000Z",
        "changefreq": null,
        "priority": null,
        "alternates": [],
        "imageCount": 72,
        "videoCount": 0,
        "newsTitle": null,
        "statusCode": null,
        "redirectLocation": null,
        "statusCheckError": null,
        "diffStatus": null,
        "discoveredAt": "2026-11-26T01:51:11.290Z",
        "error": null,
        "errorCode": null,
        "sitemapsTried": null
    }
]
```

### Monitor a website's new and removed pages

1. Turn on **Compare with previous run** (`compareWithPreviousRun`) and give the comparison a name in `stateKey`, for example `competitor-weekly`.
2. Save the input as a task and add a daily or weekly schedule in Apify Console.
3. Every row gets `diffStatus` = `new` or `unchanged`, and each URL that disappeared since the previous run with the same name and start URL comes back as a row with `diffStatus` = `removed`. Filter the dataset on `diffStatus`, or send it on with a webhook or integration.

```json
{
    "startUrls": ["https://example.com"],
    "maxUrlsPerSite": 5000,
    "compareWithPreviousRun": true,
    "stateKey": "competitor-weekly"
}
```

The first run marks every URL `new`. Removed URLs are reported only after a complete read (see the FAQ), and each `removed` row is charged like a page row and counts towards `maxUrlsPerSite`.

### Use cases

- **SEO audits:** get the full list of URLs a site submits to search engines, with lastmod dates and hreflang alternates.
- **Competitor monitoring:** schedule the Actor with `compareWithPreviousRun` to see which pages a site added or removed since the last run.
- **Crawl seeding:** feed the URL list into another Actor, for example a Lighthouse audit or a content scraper.
- **Migration checks:** with `checkUrlStatus`, find sitemap URLs that redirect or return 404.

### How much does it cost?

This Actor uses **pay per event** pricing. You only pay for results:

| Event | Price (Free plan) | Bronze | Silver | Gold |
|---|---|---|---|---|
| Page URL (`url-extracted`): one row in your dataset | $0.0002 | $0.00018 | $0.00015 | $0.00012 |
| URL status checked (`url-status-checked`): optional HTTP status check of one URL | $0.0005 | $0.0005 | $0.0005 | $0.0005 |

Platinum and Diamond plans pay the Gold price. Plus the standard Actor start fee of $0.00005 per run.

- **100 URLs:** $0.02
- **1,000 URLs:** $0.20
- **10,000 URLs:** $2.00 (Gold: $1.20)
- 1,000 URLs **with** status check: $0.20 + $0.50 = $0.70

The **free $5 monthly credit** of the Apify Free plan covers about **25,000 URLs** per month.

You pay for each page URL row, each `removed` row in diff mode, and one row for a website that has no sitemap at all (`NO_SITEMAP_FOUND`). Error rows for websites that could not be read, blocked access or have a broken sitemap are free; the FAQ lists the exact rules. The run stops cleanly at your maximum cost per run.

### Data source, limits and legality

- **Source:** only the website's own discovery files, which are published for automated clients: robots.txt `Sitemap:` lines ([RFC 9309](https://www.rfc-editor.org/rfc/rfc9309)), XML sitemaps and sitemap indexes ([sitemaps.org protocol](https://www.sitemaps.org/protocol.html)), gzip-compressed sitemaps, plain-text sitemaps and RSS/Atom feeds used as sitemaps. When robots.txt names no sitemap, or none of the sitemaps it names can be read (stale `Sitemap:` lines are common), the Actor tries `/sitemap.xml`, `/sitemap_index.xml`, `/sitemap-index.xml` and `/wp-sitemap.xml`.
- **No page content is downloaded.** With `checkUrlStatus` on, one HEAD request per URL is sent (a GET whose body is not read if the server rejects HEAD), redirects are not followed, and robots.txt `Disallow` rules for the Actor are respected.
- **Freshness:** data is read live at run time. It is as current as the site's sitemap; many sites update lastmod rarely or not at all.
- **Polite client:** at most 2 parallel requests per host in total (sitemap downloads, robots.txt and status checks together; at most one of them a sitemap download), retries with exponential backoff, `Retry-After` honored, an honest User-Agent (`website-sitemap-extractor/0.1 (+https://apify.com) Apify Actor`). Common locations disallowed by robots.txt are not probed.
- **No circumvention:** a 401/403 or a bot challenge becomes a `BLOCKED` error row and the Actor stops asking that host. It does not use proxies, browser spoofing or challenge solving.
- **Not covered:** pages that are not listed in any sitemap (this is not a crawler), sitemaps that need a login, and sitemaps that only exist as HTML pages. A server that answers a sitemap with an HTTP error status (e.g. 404 with an XML body) is treated as "no sitemap". Sitemaps must be UTF-8 by protocol; a file that declares another encoding (ISO-8859-1 in its XML declaration or Content-Type header, for example) is decoded with that encoding and listed under `encodingWarnings` in the SUMMARY record.
- **Personal data:** the Actor collects no personal data beyond what the website itself publishes in its sitemaps. Some sites list author archive pages (for example WordPress `wp-sitemap-users-1.xml`); those URLs are returned as listed, with no enrichment. You are responsible for how you use the results.
- **Size limits:** one sitemap file is read up to 100 MB uncompressed (the protocol allows 50 MB). Memory: the Actor caps its JavaScript heap at half of the run memory so that garbage collection keeps it inside the limit. 256 MB is meant for typical runs; for more than about 500,000 URLs per website or diff mode on very large sites, choose 512 MB or 1 GB. Peak memory depends on the site, because rows with many hreflang alternates are larger. Local measurements for 10,000 URLs: ikea.com (many alternates) peaked at 241 MB with the heap cap and 352 MB without it; developer.mozilla.org peaked at 142 MB. Memory on the Apify platform itself has not been measured yet.

### Use via API, schedules and integrations

Run it from your code with the Apify API (replace `<YOUR_API_TOKEN>` with your token):

```bash
curl -X POST "https://api.apify.com/v2/acts/datatoolsforall~website-sitemap-extractor/run-sync-get-dataset-items" \
  -H "Authorization: Bearer <YOUR_API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"startUrls":["https://apify.com"],"maxUrlsPerSite":200}'
```

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

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('datatoolsforall/website-sitemap-extractor').call({ startUrls: ['https://apify.com'], maxUrlsPerSite: 200 });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

You can also run it on a **schedule** (pair it with `compareWithPreviousRun`), connect it to Make, Zapier, Google Sheets or webhooks through Apify **integrations**, or call it from AI agents through the Apify **MCP server** (see [Use with AI agents](#use-with-ai-agents)).

### Related actors

- [Bulk Lighthouse & PageSpeed Test: Sitemap, Core Web Vitals](https://apify.com/datatoolsforall/bulk-lighthouse-pagespeed-audit): run Lighthouse lab audits (performance, accessibility, best-practices and SEO scores, LCP, CLS, TBT) on the page URLs this Actor returns, or straight from a sitemap.
- [Domain Availability Checker: Bulk Names & TLDs via RDAP](https://apify.com/datatoolsforall/bulk-domain-availability-checker): check which domain names are free, with registrar and expiry date from registry RDAP data.
- [Secretary of State Search & New LLC Filings: NY, TX, CO, OR, CT](https://apify.com/datatoolsforall/state-business-entity-search): look up LLCs and corporations by name or ID, or pull new filings by date, from official state open data for five states.

### FAQ and troubleshooting

**What do the error codes mean?**

| `errorCode` | Meaning | Charged |
|---|---|---|
| `NO_SITEMAP_FOUND` | robots.txt names no sitemap, or only sitemaps that answer an HTTP error status (e.g. a stale `Sitemap:` line answering 404), and every common location that was requested answered that there is no sitemap (an HTTP error status such as 404, or a complete HTML page or empty body). Not such an answer (see `FETCH_FAILED`): a file cut off before its root element, a sitemap named in robots.txt that answers HTTP 200 with something that is not a sitemap, and an error message after the XML declaration. `error` says exactly what was checked, `sitemapsTried` lists every file requested. | Yes, one `url-extracted` event (never a status check, also with `checkUrlStatus` on) |
| `SITEMAP_NOT_FOUND` | A sitemap link you entered answered an error (e.g. HTTP 404) or is not a sitemap (e.g. an HTML page). Enter the website address instead to let the Actor discover the sitemaps. | No |
| `ROBOTS_DISALLOWED` | robots.txt names no working sitemap and disallows all common sitemap locations for this Actor, so nothing else was requested. | No |
| `SITEMAP_EMPTY` | Sitemaps were found, but they list no page URLs, e.g. an empty `<urlset xmlns="..."/>` (for a website, the common locations were checked too). | No |
| `CHILD_SITEMAPS_FAILED` | A sitemap index was found, but every sitemap it names (or robots.txt names) failed, so no page URL could be read (for a website, the common locations were checked too). `sitemapErrors` in SUMMARY lists the failures. | No |
| `INDEX_NOT_FOLLOWED` | Only sitemap index files were found and `followSitemapIndexes` is off. The child sitemap URLs are in the SUMMARY record. | No |
| `DNS_NOT_FOUND` | The domain does not exist. Check the spelling. | No |
| `BLOCKED` | The site answered 401/403 or a bot challenge. Nothing was bypassed. | No |
| `FETCH_FAILED` | Timeouts, network errors or HTTP 5xx persisted after 3 retries, or a sitemap download failed or was cut off (e.g. `TRUNCATED`, corrupt gzip) before its first entry, so no page URL could be read. This includes a file cut off before its root element, e.g. one that stops after the XML declaration or inside `<urlset`, a sitemap whose generator crashed after the XML declaration (`GENERATOR_ERROR`, e.g. a PHP fatal error served with HTTP 200), and a sitemap named in robots.txt that answers HTTP 200 with an HTML page, an empty body or other content that is not a sitemap. The row's `error` names the file; `sitemapErrors` in SUMMARY lists every failure. | No |
| `INTERNAL_ERROR` | An unexpected error in the Actor for this website. Please report it in the Issues tab. | No |

If every start URL ends with `FETCH_FAILED`, the run is marked as failed.

**What is in the SUMMARY record, and what does PARTIAL mean?** The SUMMARY record in the run's key-value store lists, per website, which sitemaps were found, which failed and how many URLs were read, filtered or skipped as duplicates, plus `rowsExtracted` (rows produced), `rowsStored` (rows actually saved in the dataset), `urlsEmitted` (page URL rows saved) and `rowsCharged` (`url-extracted` events charged). The row totals and the final status message are counted from what was actually saved, also when several websites are processed at the same time. Its `outcome` is `OK` for a complete read, or `PARTIAL` when a sitemap download failed or was cut off part-way (timeout, network error, HTTP 5xx after retries, or an XML file that ends before its root element is closed, e.g. no `</urlset>` after `<urlset>`, reported as `TRUNCATED` in `sitemapErrors`), or when a sitemap's generator crashed (`GENERATOR_ERROR`, see below): the rows that arrived are kept, and the final status message starts with "Done, but the result is PARTIAL" and names the failed file. An empty sitemap such as `<urlset xmlns="..."/>` is complete, not cut off. If a download fails or is cut off before its first entry (also before its root element, e.g. a file that stops after the XML declaration or inside `<urlset`) and no other sitemap of the website can be read, the website gets a free `FETCH_FAILED` row instead.

**What if a sitemap's generator crashed?** That is a failure, not a missing sitemap: when a file answers HTTP 200 with an XML declaration followed by something that is not a sitemap (typically a PHP error such as `<?xml ...?><br /><b>Fatal error</b>: Allowed memory size ... exhausted`), it is reported as `GENERATOR_ERROR` in `sitemapErrors` with the start of the error text, exactly like the same crash served with HTTP 500. If no other sitemap of the website can be read, the website gets a free `FETCH_FAILED` row that names the file.

**Exactly which rows are charged?** Each page URL row, each `removed` row in diff mode (page rows plus removed rows never exceed `maxUrlsPerSite` per website), and one row per website where we looked and found **no sitemap at all** (`NO_SITEMAP_FOUND`). That last charge is made only when robots.txt was read **and at least one common sitemap location was actually requested**, and every file requested answered that there is no sitemap: an HTTP error status such as 404, or, at a common location such as `/sitemap.xml`, a complete page that is not a sitemap (an HTML page or an empty body). The lookup itself is then a real answer; the row's `error` says what was checked and `sitemapsTried` lists every file requested. You are **not** charged when a sitemap link you entered yourself does not work (`SITEMAP_NOT_FOUND`), when robots.txt disallows every common location so nothing was requested (`ROBOTS_DISALLOWED`), for the `INDEX_NOT_FOLLOWED`, `SITEMAP_EMPTY` and `CHILD_SITEMAPS_FAILED` notices, for websites that could not be reached, refused access or do not exist (`DNS_NOT_FOUND`, `BLOCKED`, `FETCH_FAILED`, `INTERNAL_ERROR`), for websites whose sitemap download failed or was cut off before its first entry, even before its root element (`FETCH_FAILED`), for websites where a sitemap named in robots.txt answers HTTP 200 with something that is not a sitemap (an HTML page, an empty body: a broken sitemap, `FETCH_FAILED`), for websites whose sitemap generator crashed after the XML declaration (e.g. a PHP fatal error, `FETCH_FAILED`), or for invalid input. With `checkUrlStatus`, only page URL rows are status-checked: `removed` rows and the `NO_SITEMAP_FOUND` row are never checked or charged `url-status-checked`. Rows and status checks are sized together against your maximum cost per run, so no status result is delivered unpaid; the Actor stops cleanly when the limit is reached.

**Why did I get fewer URLs than the site has?** Check `maxUrlsPerSite`, your filters and `lastmodAfter` (URLs without a lastmod date are dropped when it is set). The SUMMARY record shows `truncatedBy`, `filteredOut`, `duplicatesSkipped` and every sitemap that failed. If a sitemap download failed part-way, the website's `outcome` is `PARTIAL` and the status message says so; run again to get the rest. With `checkUrlStatus` on, the status checks run alongside the download (up to 1,000 rows wait for their check at a time), and `requestTimeoutSecs` only counts time the server itself is silent, so slow status checks never cut a sitemap short.

**Are duplicates removed?** Yes. Within a website, a URL listed in several sitemaps appears once, with the first sitemap it was found in. A website start URL is always read as the whole site, so a page address such as `https://example.com/blog` is reduced to `https://example.com/`, and several start URLs on the same host (`http://` and `https://` included) count as one website: the site is extracted and charged once, and the log and the final status message say which entries were merged. To get only one section, use `includePatterns` or enter that section's sitemap URL. A direct sitemap URL is read on its own, so if you enter both a website and one of its sitemaps, URLs found by both are output twice (the run warns about this).

**Why is `lastmod` sometimes without a `Z`?** Many sitemaps (WordPress, for example) write a time without a time zone, such as `2026-06-23 01:02:37`, often in the site's local time. The Actor does not guess the zone: it keeps the value as `2026-06-23T01:02:37`. For the `lastmodAfter` filter such values are compared as if they were UTC, so near the boundary date they can be off by the site's UTC offset.

**How does diff mode decide that a URL was removed?** Only after a complete read of all sitemaps (no cap reached, no failed sitemap, all index files followed, no `lastmodAfter`), and only for URLs that match your current include/exclude filters. If you narrow the filters under the same `stateKey`, URLs outside them are not reported as removed and stay remembered, so widening the filters later does not report them as new. Removed rows count towards `maxUrlsPerSite`; any that do not fit stay remembered and are reported in a later run once there is room under `maxUrlsPerSite` (while the site still has at least `maxUrlsPerSite` URLs there is no room, so raise the limit to see them). Their number is in `removedNotReported` in the SUMMARY record and in the final status message. When removed URLs are not detected for a website (first run, a failed sitemap, a cap reached, `lastmodAfter`), the reason is in `diff.removedDetectionOffReason` in the SUMMARY record and in the status message. A website with a permanently failing sitemap (for example a stale robots.txt line) therefore never gets removal detection. When the read is not complete, rows are marked `new`/`unchanged` only and the remembered list is kept. If a run stops at your maximum cost per run, only the URLs whose rows were actually saved are remembered, so the URLs that did not fit are reported as `new` in the next run. The list is stored in your account in a named key-value store called `website-sitemap-extractor-state`.

**Can it read sitemaps of sites that block bots?** No. That is deliberate.

# Changelog

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

# Actor input Schema

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

Website addresses (e.g. https://apify.com) or direct sitemap links (e.g. https://apify.com/sitemap.xml). For a website, sitemaps are found via robots.txt and common locations such as /sitemap.xml. A website is always read whole: a page path such as /blog is ignored, and http and https on one host count as one website (extracted and charged once). To keep one section, use the URL filters below or enter that section's sitemap URL.

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

Caps the billable rows per website, and so your cost: $0.20 per 1,000 rows (without the status check). Page URLs and, in comparison mode, removed URLs count towards it. If you leave it out (e.g. via API), the default of 10,000 means at most $2.00 per website.

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

Optional. Keep only URLs that match at least one of these regular expressions, for example /blog/ or .pdf$. Matching is case-sensitive. Leave empty to keep everything.

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

Optional. Drop URLs that match any of these regular expressions, for example /tag/ or ?page=. Applied after the include list.

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

Optional. Keep only URLs whose sitemap 'lastmod' date is on or after this date. Pick a date or enter a relative value such as '30 days'. URLs without a lastmod date are dropped when this is set.

## `followSitemapIndexes` (type: `boolean`):

Sitemap index files point to other sitemaps. Keep this on to read all of them (recommended). When it is off, only page URLs listed directly in the sitemap files you enter or that are discovered are returned: a website whose sitemap is an index (for example apify.com) then gives no page URLs, only a free INDEX_NOT_FOLLOWED row, and the child sitemap URLs are listed in the SUMMARY record.

## `includeAlternates` (type: `boolean`):

Add the language versions of each page (xhtml:link hreflang entries) to the 'alternates' field.

## `includeMediaCounts` (type: `boolean`):

Add how many images and videos the sitemap lists for each page ('imageCount' and 'videoCount').

## `checkUrlStatus` (type: `boolean`):

Paid add-on: $0.0005 per checked URL (1,000 URLs = $0.50 extra). Sends one HEAD request to every extracted page URL and adds 'statusCode' and 'redirectLocation'. Redirects are not followed, robots.txt rules are respected, and runs get slower.

## `compareWithPreviousRun` (type: `boolean`):

Remember each website's URLs between runs: every row gets 'diffStatus' = new or unchanged, and URLs that disappeared since the last run are added as 'removed' rows. Removed URLs are detected only after a complete read (no cap reached, no failed sitemap, no lastmodAfter); removed rows are charged like page rows and count towards the maximum URLs per website. Ideal with a schedule.

## `stateKey` (type: `string`):

Optional name for the remembered URL list, e.g. 'competitor-weekly'. Runs with the same name and start URL are compared even if you change the filters (URLs outside the current filters are then not reported as removed). Without a name, changing the filters starts a new comparison. Letters, digits, '-', '\_' and '.' only.

## `maxSitemapsPerSite` (type: `integer`):

Safety limit on how many sitemap files (including index files) are downloaded for one start URL.

## `requestTimeoutSecs` (type: `integer`):

How long to wait for a server to start answering, and the longest pause allowed while downloading a file. Failed requests are retried up to 3 times.

## Actor input object example

```json
{
  "startUrls": [
    "https://apify.com"
  ],
  "maxUrlsPerSite": 200,
  "followSitemapIndexes": true,
  "includeAlternates": true,
  "includeMediaCounts": true,
  "checkUrlStatus": false,
  "compareWithPreviousRun": false,
  "maxSitemapsPerSite": 500,
  "requestTimeoutSecs": 30
}
```

# Actor output Schema

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

Dataset items: one row per page URL found in the website's sitemaps, with lastmod, changefreq, priority, hreflang alternates and image/video counts (plus diffStatus and statusCode when those options are on). Error rows have errorCode set.

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

SUMMARY record: per website, the sitemaps found and failed, URL and row counts, and the outcome (OK or PARTIAL).

# 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://apify.com"
    ],
    "maxUrlsPerSite": 200
};

// Run the Actor and wait for it to finish
const run = await client.actor("datatoolsforall/website-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 = {
    "startUrls": ["https://apify.com"],
    "maxUrlsPerSite": 200,
}

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,datatoolsforall/website-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/qKyjeeglkPMNZUmVP/builds/97esxtRWRkhoZT2mK/openapi.json
