# Sitemap Crawler — Every URL a Site Publishes (`xtracto/sitemap-crawler`) Actor

Enumerate a website's full URL list from its sitemaps. Follows sitemap indexes, handles gzip, reads robots.txt, and returns lastmod, changefreq and priority. Keyless, HTTP-only, no browser.

- **URL**: https://apify.com/xtracto/sitemap-crawler.md
- **Developed by:** [Farhan Febrian Nauval](https://apify.com/xtracto) (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 $1.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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 Crawler — Every URL a Site Publishes

Give it a domain, get back the site's full URL list from its sitemaps, with
`lastmod`, `changefreq` and `priority` where the site provides them. Follows
sitemap indexes, handles gzip, reads `robots.txt`. Keyless, HTTP-only, no browser.

Useful as a first step for anything that needs to know what a site contains:
feeding a RAG index, auditing SEO coverage, or watching for new pages over time.

### Input

```json
{
  "sites": ["apify.com", "https://www.shopify.com/sitemap.xml"],
  "maxUrlsPerSite": 1000,
  "urlPattern": "/blog/"
}
```

A bare domain, a site URL, or a direct sitemap URL all work.

### What you get

| Field | Meaning |
|---|---|
| `url`, `host`, `path` | The published URL, split for easy filtering |
| `lastmod` | When the site says the page last changed |
| `changefreq`, `priority` | The site's own hints, when present |
| `hasNewsMetadata`, `hasImageMetadata`, `hasVideoMetadata` | Whether the entry carries those sitemap extensions |
| `alternateLanguages` | Count of `xhtml:link` alternates, for multilingual sites |
| `sitemapUrl`, `sitemapDepth` | Which sitemap file this URL came from, and how deep |

### Things worth knowing

**`robots.txt` is not a reliable index.** Four of ten sites tested named no sitemap
in `robots.txt` while still serving a perfectly good one — shopify.com among them.
This actor tries `robots.txt` first and then the conventional paths, so a silent
robots file is not treated as "no sitemap".

**A sitemap URL is often an index of sitemaps.** apify.com's is a `<sitemapindex>`
pointing at 15 children, which between them publish over 600,000 URLs. Indexes are
followed automatically, up to `maxSitemapFiles` and three levels of nesting.

**Set `maxUrlsPerSite` deliberately.** Large sites are very large. The limit counts
URLs *returned*, so it still means what it says when `urlPattern` is set — a narrow
pattern keeps searching later files rather than quietly handing back a short list.

**200 does not mean sitemap.** reddit.com/sitemap.xml answers 200 with an HTML
page. This actor inspects the body and reports `not_a_sitemap` with the first bytes
it saw, rather than parsing nothing and calling it empty.

**Gzip is handled either way.** A `.xml.gz` URL usually arrives already inflated,
because servers send `Content-Encoding: gzip`. Some serve the file with no such
header; the gzip magic bytes are checked and inflated by hand when that happens.

**A refusal can be a 406 with an empty body.** github.com/sitemap.xml returns 406
and zero bytes for every `Accept` header, including none — so some hosts simply do
not serve sitemaps to anyone. Two User-Agents are tried before a host is called
closed, because a few hosts reject unfamiliar agents and a few reject browsers.

### Failure reporting

| `_error` | Meaning |
|---|---|
| `no_sitemap_urls` | No sitemap found or readable — the detail lists what was tried |
| `no_urls_matched` | Sitemaps read fine, but `urlPattern` excluded every URL (not a run failure) |

If no site yields a readable sitemap the run aborts rather than finishing empty.

### Related

Pair it with **Website Content Extractor** to turn the URL list into clean article
text, or with **RAG Web Search** when you want to start from a question instead of
a domain.

# Actor input Schema

## `sites` (type: `array`):

A bare domain (example.com), a site URL, or a direct sitemap URL. Bare domains are discovered via robots.txt, then conventional paths.

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

Large sites publish hundreds of thousands of URLs. Truncation is reported in the log.

## `maxSitemapFiles` (type: `integer`):

A sitemap index can point at thousands of children; this bounds the crawl.

## `urlPattern` (type: `string`):

Optional Python regular expression. Only URLs matching it are returned — e.g. /blog/ to keep just blog posts.

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

Optional. Most hosts serve sitemaps to anything, but a few refuse datacentre addresses.

## Actor input object example

```json
{
  "sites": [
    "apify.com"
  ],
  "maxUrlsPerSite": 1000,
  "maxSitemapFiles": 50,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

One row per scraped record, stored in the run's default dataset.

# 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 = {
    "sites": [
        "apify.com"
    ]
};

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

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,xtracto/sitemap-crawler"
        }
    }
}
```

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/72dOnzKZxhgNTBhCc/builds/gWp493usYxo81cacu/openapi.json
