# Sitemap URL Extractor: All URLs, Lastmod, Images & Status (`best_apis/sitemap-url-extractor`) Actor

Extract every URL from any website's XML sitemaps. Auto-discovers sitemaps from robots.txt, follows nested sitemap indexes, reads .gz, text and RSS sitemaps, returns lastmod, priority, hreflang, image, video and news tags, with URL filters and optional status-code check. $0.20 per 1,000 URLs.

- **URL**: https://apify.com/best_apis/sitemap-url-extractor.md
- **Developed by:** [A Q](https://apify.com/best_apis) (community)
- **Categories:** SEO tools, Developer tools, Automation
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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: All URLs, Lastmod, Images & Status

Get **every URL listed in a website's XML sitemaps** in seconds. Give it a domain and the Actor finds the sitemaps for you (robots.txt `Sitemap:` lines, then `/sitemap.xml`, `/sitemap_index.xml`, `/wp-sitemap.xml`, `/sitemap.txt`), follows **nested sitemap indexes**, unpacks **.xml.gz** files and returns one clean row per URL:

- **URL**, **lastmod** (normalized to ISO 8601), **changefreq**, **priority**
- **hreflang alternates** (`xhtml:link`) for multilingual sites
- **Image sitemap** tags (image URL, title, caption)
- **Video sitemap** tags (title, description, thumbnail, content/player URL, duration, publication date)
- **Google News sitemap** tags (headline, publication date, publication name, language)
- Which **sitemap file** (and parent index) each URL came from
- Optional **HTTP status check** of every URL (status code and redirect target), to find 404s and redirects in your sitemap

Also reads **plain-text sitemaps** and **RSS/Atom feeds** used as sitemaps. No browser, no proxy cost on normal sites, so runs are fast and cheap: 4,800 URLs in about 3 seconds.

### Pricing: $0.20 per 1,000 URLs

| | This Actor | Typical sitemap extractors on Apify |
|---|---|---|
| URL from sitemap | **$0.20 per 1,000** | $0.50 to $5 per 1,000 |
| URL + status-code check | **$0.60 per 1,000** | often unavailable or $1+ per 1,000 |
| Actor start | $0.0005 per GB of memory (256 MB default) | up to $0.01 |

You pay only for URLs you receive. Filters (patterns, lastmod) are applied **before** charging, so skipped URLs are free. **Max URLs per site** and **Max URLs in total** cap every run, and your Apify maximum cost per run is respected exactly.

### Use cases

- **SEO audits and site migrations**: export the full URL inventory of a site, compare old and new sitemaps, find 404s and redirect chains that are still in the sitemap.
- **Crawl seeding**: feed the URL list into a scraper or crawler (Website Content Crawler, our [SEO Audit Tool](https://apify.com/best_apis/seo-audit-tool) or [Broken Link Checker](https://apify.com/best_apis/broken-link-checker)) instead of discovering pages by crawling.
- **Content monitoring**: schedule a daily run with `lastmodAfter: "1 day"` to get only pages a competitor added or changed.
- **News monitoring**: read Google News sitemaps for fresh headlines with publication times.
- **RAG and AI agents**: get the list of documentation pages to index.

### Input examples

Auto-discover all sitemaps of a website:

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

A specific sitemap, only blog posts changed in the last 30 days:

```json
{ "startUrls": ["https://www.shopify.com/sitemap.xml"], "includePatterns": ["*/blog/*"], "lastmodAfter": "30 days" }
```

Check every sitemap URL for 404s and redirects:

```json
{ "startUrls": ["example.com"], "checkStatus": true, "maxUrlsPerSite": 5000 }
```

### Output

```json
{
  "type": "url",
  "url": "https://www.bbc.com/news/videos/ckdd22kyq81o",
  "lastmod": "2026-10-29T15:17:00.000Z",
  "changefreq": null,
  "priority": null,
  "alternates": [],
  "images": [],
  "videos": [],
  "news": { "title": "BBC Newsline signed summary", "publicationDate": "2026-10-29T15:17:00.000Z", "publication": "BBC News", "language": "en" },
  "site": "https://www.bbc.com",
  "sitemapUrl": "https://www.bbc.com/sitemaps/https-sitemap-com-news-1.xml",
  "parentSitemapUrl": "https://www.bbc.com/sitemaps/https-index-com-news.xml",
  "statusCode": 200,
  "redirectTo": null,
  "scrapedAt": "2026-10-30T05:17:12.135Z"
}
```

(`statusCode`, `redirectTo` and `checkError` appear only with **Check HTTP status** on.)

A per-site **SUMMARY** record in the key-value store lists every sitemap file found (index or urlset, URL counts) and any sitemap errors. Inputs that fail (no sitemap, DNS error, HTML instead of XML) are listed in **FAILURES**, and the run keeps going with the other sites.

### How it works

- Discovery order: robots.txt `Sitemap:` directives, then common sitemap paths. A URL that looks like a sitemap (`.xml`, `.gz`, `.txt`, `sitemap`, feeds) is read directly.
- Sitemap indexes are followed breadth-first, de-duplicated, up to **Max sitemap files per site** (500 default).
- URLs are de-duplicated per site. `http://` sitemaps listed in robots.txt fall back to `https://` automatically.
- Polite by default: an identifying user agent, no more than 4 sites in parallel, retries with back-off, and Apify Proxy only if a site refuses direct connections.

### FAQ

**Does it crawl the website?** No. It only reads the sitemaps the site publishes for search engines, which is why it is fast and cheap. Use a crawler if a site has no sitemap.

**My site has no sitemap at robots.txt.** Put the direct sitemap URL in the input. If nothing is found the input is listed in FAILURES with the reason.

**How many URLs can it handle?** Hundreds of thousands. Sitemaps are parsed with a lightweight streaming-friendly parser, so 50,000-URL files are fine at 256 MB.

**Can I use it from the API, Make, Zapier, n8n or an AI agent (MCP)?** Yes, like every Apify Actor. Input is flat JSON, output is a dataset you can download as JSON, CSV or Excel.

# Actor input Schema

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

A website (example.com, https://example.com) to auto-discover its sitemaps from robots.txt and common paths, or a direct sitemap URL (sitemap.xml, sitemap_index.xml, .xml.gz, sitemap.txt, RSS/Atom feed). Leave empty for a demo on crawlee.dev.

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

Stop reading a site's sitemaps after this many matching URLs.

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

Optional. Keep only URLs containing one of these patterns. Use \* as a wildcard, e.g. */blog/* or \*.html. Case-insensitive.

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

Optional. Drop URLs containing any of these patterns, e.g. */tag/* or *?page=*.

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

Optional. Only URLs whose <lastmod> is newer than this: a date (2026-01-01) or a relative time like "24 hours", "7 days", "3 months". URLs without lastmod are skipped when set.

## `includeExtras` (type: `boolean`):

Add alternates (hreflang), images, videos and Google News fields when the sitemap has them.

## `checkStatus` (type: `boolean`):

Send a HEAD request (GET fallback) to every URL and add statusCode and redirectTo. Finds 404s and redirects listed in your sitemap. Priced as a 'checked URL'.

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

Safety cap on how many sitemap files (incl. nested indexes) are read per site.

## `maxItems` (type: `integer`):

Hard cap for the whole run, so cost stays predictable.

## Actor input object example

```json
{
  "startUrls": [
    "https://crawlee.dev",
    "https://docs.apify.com/sitemap.xml"
  ],
  "maxUrlsPerSite": 100,
  "includeExtras": true,
  "checkStatus": false,
  "maxSitemapsPerSite": 500,
  "maxItems": 100000
}
```

# Actor output Schema

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

No description

## `full` (type: `string`):

No description

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

No description

## `failures` (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 = {
    "startUrls": [
        "https://crawlee.dev",
        "https://docs.apify.com/sitemap.xml"
    ],
    "maxUrlsPerSite": 100
};

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

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

```

## MCP server setup

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