# Sitemap URL Extractor (`webintel/sitemap-extractor`) Actor

Discover and parse XML, gzip and text sitemaps from domains, websites or direct sitemap URLs. Outputs one clean dataset item per URL.

- **URL**: https://apify.com/webintel/sitemap-extractor.md
- **Developed by:** [Deepak Ganesh](https://apify.com/webintel) (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.20 / 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

![Sitemap URL Extractor](https://api.apify.com/v2/key-value-stores/21SBwDwdNtlnapIdO/records/sitemap-extractor.png?v=d281590f)

Paste domains, website URLs, or direct sitemap URLs and get a clean dataset of page URLs from their public sitemaps.

- **Discovers sitemaps automatically** from `robots.txt` `Sitemap:` lines plus common paths such as `/sitemap.xml`, `/sitemap_index.xml`, `/sitemap-index.xml`, `/wp-sitemap.xml`, and `/sitemap.txt`.
- **Recursively expands sitemap indexes** with deduplication, loop protection, a depth limit, and a per-site cap.
- **Parses XML, `.xml.gz`, gzip-encoded responses, and plain-text sitemaps** using XML mode parsing, including namespaced image, video, news, and hreflang extensions.
- **Outputs one dataset item per page URL** with sitemap metadata. Per-site run details are saved to the key-value store record `SUMMARY`, keeping the dataset clean.

It only makes plain HTTP requests, uses gentle concurrency, and skips failed sites without charging for them.

### Use cases

- **SEO audits**: export every URL a site declares for crawling.
- **Content inventory**: collect lastmod, priority and changefreq metadata for large websites.
- **Migration planning**: compare sitemap URL lists before and after a relaunch.
- **Lead enrichment and monitoring**: discover public pages from many domains at low cost.
- **AI agents and data pipelines**: feed a clean URL list into crawlers, indexers or LLM workflows.

### Input

| Field | Default | Description |
|---|---:|---|
| `startUrls` | – | Domains (`example.com`), site URLs (`https://example.com`), or direct sitemap URLs (`https://example.com/sitemap.xml`). |
| `maxUrlsPerSite` | `10000` | Maximum page URLs to output and charge for from each site. |
| `includeImages` | `false` | Include image sitemap extension URLs in `images[]`. |
| `urlFilter` | – | Optional regex or glob include filter. Examples: `**/blog/**`, `product`, `^https://example.com/docs/`. |
| `excludeFilter` | – | Optional regex or glob exclude filter applied after `urlFilter`. |
| `maxConcurrency` | `5` | Maximum sitemap fetches in parallel per site, capped at 20. |
| `proxyConfiguration` | off | Optional Apify Proxy configuration. Most public sitemaps work without a proxy. |

```json
{
  "startUrls": ["apify.com", "wordpress.org", "https://www.python.org/sitemap.xml"],
  "maxUrlsPerSite": 200,
  "includeImages": true
}
```

### Output

One dataset item is produced per extracted page URL. Failed sites and sites with no usable sitemap are recorded in the `SUMMARY` key-value-store record instead of the dataset.

```json
{
  "url": "https://apify.com/",
  "lastmod": null,
  "changefreq": null,
  "priority": null,
  "alternates": [],
  "sourceSitemap": "https://apify.com/sitemap/pages.xml",
  "site": "https://apify.com",
  "domain": "apify.com"
}
```

When `includeImages` is enabled and image sitemap entries are present, `images` contains absolute image URLs. Hreflang links are returned as:

```json
"alternates": [{ "hreflang": "fr", "href": "https://example.com/fr/page" }]
```

The `SUMMARY` record includes totals and per-site diagnostics:

```json
{
  "totals": { "sites": 4, "sitemapsDiscovered": 211, "sitemapsFetched": 41, "urlsExtracted": 400, "urlsPushed": 400, "errors": 15 },
  "sites": [
    { "input": "apify.com", "domain": "apify.com", "sitemapsDiscovered": 21, "urlsPushed": 200, "limitReached": true, "errors": ["https://apify.com/wp-sitemap.xml: HTTP 404"] }
  ]
}
```

*(Examples trimmed from a real local run.)*

### Pricing

Pay per event: you pay only for URL items pushed to the dataset.

| Event | Price | When |
|---|---:|---|
| URL extracted | **$0.0002** ($0.20 per 1,000 URLs) | Charged for each page URL successfully pushed to the dataset. |

Sites with no sitemap, DNS errors, HTTP errors, malformed XML, filtered URLs and duplicate URLs are **free**. The Actor respects your maximum cost per run and stops cleanly when the charge limit is reached. Platform usage is included in the event price.

### FAQ

**Does it crawl pages?** No. It fetches sitemap and robots.txt files only. This keeps runs fast, cheap and gentle.

**Can I pass a direct sitemap URL?** Yes. Direct `.xml`, `.xml.gz`, `.txt`, or sitemap-like URLs are parsed directly.

**Are sitemap indexes supported?** Yes. The Actor recursively follows indexes with a depth limit, deduplication and loop protection.

**What happens when a site has no sitemap?** The site is logged in `SUMMARY` with errors and zero pushed URLs. You are not charged.

**Does it parse image/video/news sitemap extensions?** Yes. Namespaced sitemap XML is parsed safely. Image URLs can be included with `includeImages`; hreflang alternates are always returned. Video and news extension elements are tolerated without breaking parsing.

**Is this legal?** The Actor reads public sitemap files and robots.txt over HTTP. You are responsible for using the data in compliance with applicable laws and website terms.

### Changelog

- **0.1**: Initial release. Discovers robots.txt and common sitemaps, expands sitemap indexes, supports XML/gzip/text sitemaps, extracts URL metadata, images and hreflang alternates, and stores per-site summaries in `SUMMARY`.

# Actor input Schema

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

Enter domains (example.com), site URLs (https://example.com), or direct sitemap URLs (https://example.com/sitemap.xml). Duplicates are removed.

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

Maximum number of page URLs to output and charge for from each site.

## `includeImages` (type: `boolean`):

Extract image sitemap extension URLs into images\[].

## `urlFilter` (type: `string`):

Optional regex or glob. Only matching page URLs are output. Glob examples: **/blog/** or *product*.

## `excludeFilter` (type: `string`):

Optional regex or glob. Matching page URLs are skipped after the include filter.

## `maxConcurrency` (type: `integer`):

Maximum sitemap fetches in parallel per site.

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

Optional. Most public sitemaps work without a proxy.

## Actor input object example

```json
{
  "startUrls": [
    "apify.com",
    "wordpress.org",
    "https://www.python.org/sitemap.xml"
  ],
  "maxUrlsPerSite": 10000,
  "includeImages": false,
  "maxConcurrency": 5,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

One item per page URL with sitemap metadata: url, lastmod, changefreq, priority, images, alternates, sourceSitemap, site and domain.

## `images` (type: `string`):

Image sitemap extension URLs, when includeImages is enabled.

## `alternates` (type: `string`):

Alternate language URLs extracted from xhtml:link sitemap extensions.

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

Per-site summary with discovered sitemaps, output URL counts, skipped duplicates and non-fatal errors.

# 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": [
        "apify.com",
        "wordpress.org",
        "https://www.python.org/sitemap.xml"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("webintel/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": [
        "apify.com",
        "wordpress.org",
        "https://www.python.org/sitemap.xml",
    ],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("webintel/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": [
    "apify.com",
    "wordpress.org",
    "https://www.python.org/sitemap.xml"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call webintel/sitemap-extractor --silent --output-dataset

```

## MCP server setup

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