# Sitemap Extractor (all URLs from sitemap.xml) (`sagnato/sitemap-urls`) Actor

Get every page URL a site lists in its sitemaps, with lastmod, changefreq and priority. Finds sitemaps through robots.txt, follows sitemap indexes, reads .gz and text sitemaps. Free, 512 MB, obeys robots.txt.

- **URL**: https://apify.com/sagnato/sitemap-urls.md
- **Developed by:** [Sagnato](https://apify.com/sagnato) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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 Extractor (all URLs from sitemap.xml)

Give it a site or a sitemap link; get back every page URL the site lists in its sitemaps, one row each, with `lastmod`, `changefreq` and `priority`. Handy before a crawl, an SEO check, or a screenshot run of every page.

### Limits, up front

- **No proxy and no retries.** Requests come straight from Apify's servers as SagnatoBot; a site that blocks bots, or a sitemap that fails once, gives a plain reason in the summary.
- **The status check is optional and slow**: off by default, about one second per URL per site, and at most 10,000 checks per run.
- Sitemap indexes are followed **five levels deep, up to 1,000 sitemap files**.

### What it handles

- **Finds the sitemaps for you**: reads the `Sitemap:` lines in robots.txt, and falls back to `/sitemap.xml` and `/sitemap_index.xml`.
- **Sitemap indexes**, nested up to five levels.
- **Gzip** (`.xml.gz`) and **plain-text** sitemaps, CDATA and escaped URLs.
- **Same-site filter** (on by default) and a total limit, so huge sites still finish.
- A **summary per site**: sitemaps read, URLs found, and a plain reason for anything that couldn't be read.
- **Optional status check** (`checkStatus`): opens the start of each listed page and adds its HTTP status, the final URL after redirects and the `Last-Modified` header, so you can spot broken or moved pages. Up to 10,000 checks per run (`maxStatusChecks`, default 1,000); about one second per URL per site.

### Input

- **urls** (required): sites (`example.com`) or sitemap links, up to 100 per run.
- **maxUrls** (default 50,000, up to 500,000), **sameHostOnly** (default on), **includeSitemapUrl** (default on).
- **checkStatus** (default off) and **maxStatusChecks** (default 1,000).

Example for an AI agent or the API: `{"urls": ["example.com"], "maxUrls": 1000}`.

### Polite by design

Free; runs at 512 MB. Only public addresses; robots.txt read first and obeyed for our crawler SagnatoBot; one request per site at a time, at least a second apart (or the site's Crawl-delay). It reads only sitemap files, never the pages themselves, unless you turn on the status check, which reads only the first 64 KB of each page, in the same one-at-a-time queue per site.

### Output

Dataset rows: `url`, `lastmod`, `changefreq`, `priority`, `sitemap`, plus `status`, `finalUrl`, `lastModifiedHeader` and `checkError` when the status check is on. Key-value store: `SUMMARY` (per site) and `REPORT.md`.

### What it does not do

- It does not crawl links to find pages that are missing from the sitemaps.
- No sitemap file over 50 MB (the sitemap protocol's own limit), zipped or unzipped: it is skipped with a reason.
- No proxy: requests come straight from Apify's servers under our own crawler name.

# Actor input Schema

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

A site (example.com) to find its sitemaps through robots.txt, or a sitemap's own URL. Up to 100 per run.

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

The run stops collecting after this many URLs in total and says so.

## `sameHostOnly` (type: `boolean`):

Leave out URLs on other domains that a sitemap lists (www. counts as the same site).

## `includeSitemapUrl` (type: `boolean`):

Adds a 'sitemap' field to each row with the sitemap file the URL was listed in.

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

Opens the start of each listed page (64 KB) and adds status, finalUrl (after redirects), lastModifiedHeader and checkError. Pages on one site are checked one at a time, at least a second apart, so this takes about a second per URL per site.

## `maxStatusChecks` (type: `integer`):

Only the first this many URLs are checked; the rest are listed without a status.

## Actor input object example

```json
{
  "urls": [
    "apify.com"
  ],
  "maxUrls": 1000,
  "sameHostOnly": true,
  "includeSitemapUrl": true,
  "checkStatus": false,
  "maxStatusChecks": 1000
}
```

# Actor output Schema

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

One row per page URL with lastmod, changefreq, priority and its sitemap.

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

Sitemaps read, URLs found and any problems, per site.

# 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": [
        "apify.com"
    ],
    "maxUrls": 1000
};

// Run the Actor and wait for it to finish
const run = await client.actor("sagnato/sitemap-urls").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": ["apify.com"],
    "maxUrls": 1000,
}

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

```

## MCP server setup

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

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/STquDQ2TsuzunJpr1/builds/FeruA8lYPYx09Do4J/openapi.json
