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

Recursively crawl and extract every single URL from a website’s sitemap.xml. Automate your SEO audits and scraping queues.

- **URL**: https://apify.com/andok/sitemap-extractor.md
- **Developed by:** [Andok](https://apify.com/andok) (community)
- **Categories:** SEO tools, Developer tools
- **Features:** Limited permissions
- **Stats:** 8 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.47 / 1,000 url extracteds

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

## XML Sitemap URL Extractor

Extract every URL from XML sitemaps and sitemap indexes in bulk for site audits, migrations, and SEO analysis. Missing or outdated sitemap entries silently kill organic traffic — this actor gives you a complete URL inventory in seconds. Handles recursive sitemap indexes, processes thousands of URLs per run, and outputs structured data ready for spreadsheets or downstream automation.

### Features

- **Recursive index traversal** — automatically follows sitemap index files up to a configurable depth
- **Bulk processing** — extract URLs from multiple sitemaps in a single run
- **Rich metadata** — captures `lastmod`, `changefreq`, and `priority` for every URL
- **Source tracking** — each URL records which sitemap file it came from
- **Configurable limits** — set max URLs and max depth to control run scope and cost
- **Error handling** — reports fetch failures per sitemap without stopping the entire run
- **Pay-per-result** — only charged for URLs actually extracted

### Input

| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `urls` | `array` | Yes | — | List of sitemap or sitemap index URLs to extract (e.g. `https://example.com/sitemap.xml`) |
| `maxUrls` | `integer` | No | `1000` | Maximum number of individual URLs to extract per top-level sitemap |
| `maxDepth` | `integer` | No | `2` | How many levels deep to follow sitemap index links (1 = no recursion) |
| `timeoutSeconds` | `integer` | No | `15` | HTTP timeout in seconds for each XML file download |

#### Input Example

```json
{
    "urls": ["https://apify.com/sitemap.xml"],
    "maxUrls": 5000,
    "maxDepth": 3,
    "timeoutSeconds": 20
}
```

### Output

Each extracted URL produces one dataset item containing the page URL, its source sitemap, and any available SEO metadata.

- `sourceSitemapUrl` (`string`) — the sitemap file this URL was found in
- `loc` (`string`) — the extracted page URL
- `lastmod` (`string | null`) — last modification date from the sitemap
- `changefreq` (`string | null`) — change frequency hint (daily, weekly, etc.)
- `priority` (`string | null`) — priority value (0.0 to 1.0)

#### Output Example

```json
{
    "sourceSitemapUrl": "https://apify.com/sitemap.xml",
    "loc": "https://apify.com/store",
    "lastmod": "2025-11-20T08:30:00Z",
    "changefreq": "weekly",
    "priority": "0.8"
}
```

### Pricing

| Event | Cost |
|-------|------|
| URL Extracted | $0.001 per URL |

You are charged per URL extracted to the dataset. Platform usage fees apply separately.

### Use Cases

- **Site migration audits** — dump every URL from your current sitemap before migrating to verify nothing gets lost
- **SEO coverage checks** — compare sitemap URLs against your CMS to find pages missing from the sitemap
- **Competitor analysis** — extract a competitor's full URL structure from their public sitemaps
- **Content inventory** — build a master spreadsheet of all pages with last-modified dates for content planning
- **Automated monitoring** — schedule runs to track sitemap growth and detect removed pages over time

### Related Actors

| Actor | What it adds |
|-------|-------------|
| [Robots.txt Auditor](https://apify.com/andok/robotstxt-auditor) | Audit robots.txt crawl rules and discover sitemap URLs declared there |
| [Broken Links Checker](https://apify.com/andok/broken-links-checker) | Verify that the URLs in your sitemap actually return 200 OK |
| [Hreflang Checker](https://apify.com/andok/hreflang-checker) | Validate hreflang tags on the multilingual URLs found in your sitemap |

# Actor input Schema

## `urls` (type: `array`):

List of XML sitemap or sitemap index URLs to extract. Supports both direct sitemaps and sitemap index files that reference child sitemaps.

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

Maximum number of individual page URLs to extract per top-level sitemap. Increase for large sites with thousands of pages.

## `maxDepth` (type: `integer`):

How many levels deep to follow sitemap index links. Set to 1 to only process the top-level sitemap without recursion.

## `timeoutSeconds` (type: `integer`):

HTTP timeout in seconds for downloading each XML sitemap file. Increase for slow or large sitemaps.

## Actor input object example

```json
{
  "urls": [
    "https://apify.com/sitemap.xml"
  ],
  "maxUrls": 1000,
  "maxDepth": 2,
  "timeoutSeconds": 15
}
```

# Actor output Schema

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

No description

## `resultsCsv` (type: `string`):

No description

## `run` (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 = {
    "urls": [
        "https://apify.com/sitemap.xml"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("andok/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 = { "urls": ["https://apify.com/sitemap.xml"] }

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

```

## MCP server setup

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