# Sitemap URL Extractor - Bulk Sitemap.xml Scraper (`cuantic_data/sitemap-url-extractor`) Actor

Extracts every URL from a website's sitemap.xml, auto-discovering the real sitemap via robots.txt and following nested sitemap index files. Returns clean JSON/CSV, ready for SEO audits, crawl budgets or feeding an LLM pipeline.

- **URL**: https://apify.com/cuantic\_data/sitemap-url-extractor.md
- **Developed by:** [Cuantic Data](https://apify.com/cuantic_data) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 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.

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 — Bulk Sitemap.xml Scraper

Extracts every URL from a website's `sitemap.xml`, auto-discovering the real
sitemap via `robots.txt` and following nested sitemap index files. Returns a
clean dataset in JSON/CSV/Excel.

### What it does

- Finds the real sitemap for any domain (it doesn't assume `/sitemap.xml`:
  it first looks for the `Sitemap:` line in `robots.txt`, which is where
  many large sites declare it).
- Follows nested sitemap indexes (sitemaps that point to other sitemaps) up
  to 5 levels deep.
- Deduplicates URLs repeated across sitemaps.
- Caps the run safely with `maxUrls` and an internal ceiling of 50 sitemaps
  processed per run, so a huge site can't trigger an unpredictable cost.
- If an individual sitemap fails (404, timeout), it's reported as an error
  and the run continues with the rest — one broken link doesn't crash the
  whole run.

### Who it's for

- SEO teams auditing indexation coverage or building a crawl budget.
- Data/agent pipelines that need the full list of URLs on a site before
  processing them (custom scraping, comparative sitemap generation, change
  monitoring).

### Input

| Field | Type | Required | Description |
|---|---|---|---|
| `startUrl` | string | Yes | Site homepage (e.g. `https://example.com`) or a direct URL to a `.xml` file. |
| `maxUrls` | integer | No (default 1000) | Maximum number of URLs to return, between 1 and 20000. |

```json
{
  "startUrl": "https://example.com",
  "maxUrls": 1000
}
```

### Output

One item per URL found:

```json
{
  "url": "https://example.com/blog/post-1",
  "sourceSitemap": "https://example.com/sitemap-posts.xml"
}
```

The run's key-value store (`RUN-SUMMARY`) also holds a summary: sitemaps
processed, how the sitemap was discovered (`robots.txt`, default, or direct
input), and per-sitemap errors, if any.

### Pricing

Pay per event: **USD 0.0005** per URL extracted (`url-extracted`) = **$0.50 / 1,000 URLs**.

### How to call it

```bash
curl "https://api.apify.com/v2/acts/cuantic-data~sitemap-url-extractor/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"startUrl": "https://example.com", "maxUrls": 500}'
```

### Source terms and limits

See [`TERMS.md`](./TERMS.md): sitemap.xml and robots.txt are public files
designed to be read by automated programs. The Actor doesn't follow
`Disallow`, doesn't visit site pages (only sitemap files), and doesn't
extract personal data.

**Known limitation (disclosed, not hidden):** compressed sitemaps
(`.xml.gz`) aren't supported in this version — if your site only publishes
the compressed sitemap, the Actor reports it as an error instead of failing
silently.

### FAQ

**Why does it return 0 URLs?**
The site has no `robots.txt` with a `Sitemap:` line and no `/sitemap.xml` at
the root. Check the run summary (`RUN-SUMMARY`) for the exact error per
sitemap.

**Found a bug?**
Email `cuanticwindows@gmail.com` — we reply within 72 hours.

***

See `build/README.md` for how to run tests and publish this Actor.

# Actor input Schema

## `startUrl` (type: `string`):

Can be the site's homepage (e.g. https://example.com) - the sitemap is auto-discovered, first via robots.txt and then via /sitemap.xml - or the direct URL of a .xml file.

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

Caps the run at this number of URLs to control cost. Between 1 and 20000.

## Actor input object example

```json
{
  "startUrl": "https://apify.com",
  "maxUrls": 1000
}
```

# Actor output Schema

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

Every URL found in the sitemap(s), one item per row.

## `runSummary` (type: `string`):

Sitemaps processed, discovery method (robots.txt / default path / direct input), total URLs found and any 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 = {
    "startUrl": "https://apify.com"
};

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

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

```

## MCP server setup

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