# Sitemap URL Extractor - Get All Website URLs (`faglez/sitemap-url-extractor`) Actor

Get every URL of a website from its sitemaps, with last-modified dates. Finds sitemaps via robots.txt, follows indexes, reads .xml, .gz and .txt. Optional check finds 404s and redirects.

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

## Pricing

from $0.25 / 1,000 results

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 - Get All Website URLs

Get every URL of any website in seconds, straight from its sitemap.xml. Give it a website or a sitemap link, and this sitemap scraper returns every page URL with its last-modified date, ready to download as Excel, CSV or JSON, or to pass to another Actor.

No browser, no crawling page by page, so it is fast and cheap: thousands of URLs per minute.

### What does it do?

- **Finds the sitemaps for you.** Reads `robots.txt`, then tries `/sitemap.xml`, `/sitemap_index.xml` and `/wp-sitemap.xml`.
- **Follows sitemap indexes** (sitemaps of sitemaps), including big sites split into hundreds of files.
- **Reads every format:** XML, gzipped `.xml.gz` and plain-text sitemaps.
- **Removes duplicates** across all sitemaps and websites in a run.
- **Filters URLs** so you only get (and pay for) what you need, for example only `/blog/` or `/products/`.
- **Optional status check:** adds the HTTP status (200, 301, 404...) and the final address after redirects, to find broken or redirected pages.

### Who uses it?

- **SEO audits:** get every indexable URL and compare it with what search engines show.
- **Content inventories and site migrations:** list every old URL before moving to a new site, then check that each one redirects correctly with [URL Status & Redirect Checker](https://apify.com/faglez/url-redirect-checker).
- **Researchers and analysts:** count a site's products, articles or locations from its URL structure, and see how fast it grows.
- **Competitor monitoring:** sort by last-modified date to see which pages a competitor added or changed recently.
- **Feeding other scrapers:** collect product, article or listing URLs first, then send them to the scraper of your choice.
- **AI agents and automations:** a predictable, cheap first step for any workflow that needs a site's page list.

### How to use it

1. Add one or more websites (`https://example.com`) or direct sitemap links (`https://example.com/sitemap.xml`). For long lists, link a text file with one website per line.
2. Optional: set **Maximum URLs**, filters, or turn on **Check that each URL works**.
3. Click **Start**, then download the results as Excel, CSV, JSON or HTML, or get them through the API.

#### Input example

```json
{
    "startUrls": [{ "url": "https://crawlee.dev" }],
    "maxUrls": 1000,
    "includeUrlsContaining": ["/docs/"],
    "checkStatus": false
}
```

#### Output example

```json
{
    "url": "https://crawlee.dev/js/docs/quick-start",
    "lastmod": null,
    "changefreq": "weekly",
    "priority": 0.5,
    "httpStatus": null,
    "finalUrl": null,
    "sitemapUrl": "https://crawlee.dev/sitemap.xml",
    "website": "https://crawlee.dev"
}
```

`lastmod`, `changefreq` and `priority` are only filled when the website provides them. `httpStatus` and `finalUrl` are filled when the status check is on.

Each run also saves a **SUMMARY** record (in the key-value store) with, for each website: where the sitemaps were found, how many were read, URLs saved, duplicates, filtered URLs and any problems.

### Use it from the API or an AI agent

- **AI agents:** connect your AI assistant to the [Apify MCP server](https://mcp.apify.com) and it can find and run this Actor on its own. The Actor's ID is `faglez/sitemap-url-extractor`, and every input field has a plain description, so the agent knows what to send.
- **API:** a single call starts a run and returns the results. This suits small runs that finish within 5 minutes:

```
POST https://api.apify.com/v2/acts/faglez~sitemap-url-extractor/run-sync-get-dataset-items?token=<YOUR_API_TOKEN>
Content-Type: application/json

{ "startUrls": [{ "url": "https://crawlee.dev" }], "maxUrls": 100 }
```

For bigger jobs, start a run and read its dataset when it finishes, or use the Apify clients for JavaScript and Python.

- **No code:** set up schedules, webhooks and integrations (Make, Zapier, Slack, Google Drive and more) from the Actor's Integrations tab.

### How much does it cost?

You only pay for what you get:

| Event | Price |
| --- | --- |
| Each URL saved | $0.25 per 1,000 URLs |
| Each status check (only if you turn it on) | $0.50 per 1,000 checks |
| Actor start | $0.001 per run |

Example: 10,000 URLs cost about $2.50, or $7.50 with the status check on. Set **Maximum URLs** or a maximum cost per run and the Actor stops cleanly at your limit, keeping everything it saved.

### Tips

- **Big sites:** start with a small **Maximum URLs** to preview the data, then raise it.
- **Only some sections:** use **Only keep URLs containing** (for example `/blog/`) so you do not pay for URLs you will throw away.
- **Know the sitemap already?** Give the direct link, it saves a few requests.
- **Several websites:** add them all to one run. Duplicates are removed across all of them.

### Questions

**What if a website has no sitemap?** The run still finishes, and the status message and SUMMARY record tell you which websites had none. This Actor reads sitemaps only; it does not crawl pages to discover links.

**Some sitemaps failed. Why?** Some websites block automated requests or have broken sitemap files. The SUMMARY record lists every problem with the exact address and error.

**Is it allowed?** Websites publish sitemaps so that search engines and other tools can find their pages, and this Actor only reads those public files (and, if you ask, sends one quick request per URL to check its status). You are responsible for how you use the data, including any website's terms.

**I already have a list of URLs. How do I check them all?** Use [URL Status & Redirect Checker](https://apify.com/faglez/url-redirect-checker). It checks any list of URLs and records every redirect hop.

**How many URLs can I get?** Up to 1,000,000 per run (**Maximum URLs**). Big sitemap indexes are followed automatically, including .gz files and nested indexes.

**Can I get only one section of a website, like the blog?** Yes: put `/blog/` in **Only keep URLs containing**, or exclude sections with **Skip URLs containing**. URLs that are filtered out are not charged.

**I entered several websites, but only the first one has URLs. Why?** **Maximum URLs** is a limit for the whole run, and websites are read in the order you list them, so one big website can use it up. To get a set number of URLs from each website, raise the limit or run the Actor once per website.

**Does it give the last-modified date?** Yes, when the sitemap has one: `lastmod`, plus `changefreq` and `priority`. Many sitemaps leave these out; they are then `null`.

**Found a bug or need a feature?** Open an issue in the Issues tab and I will look into it.

# Changelog

This Actor's version history is a separate document: https://apify.com/faglez/sitemap-url-extractor/changelog.md

# Actor input Schema

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

A website (https://example.com) or a direct sitemap link (https://example.com/sitemap.xml). Add as many as you like.

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

Stop after saving this many URLs in total, across all websites. You pay per saved URL, so this also caps the cost of a run.

## `includeUrlsContaining` (type: `array`):

Keep only URLs that contain at least one of these texts, for example /blog/ or /products/. Not case-sensitive. Leave empty to keep every URL.

## `excludeUrlsContaining` (type: `array`):

Skip URLs that contain any of these texts, for example /tag/ or ?page=. Not case-sensitive.

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

Sends a quick request to every saved URL and adds its HTTP status (200, 301, 404...) and final address after redirects. Charged per checked URL, on top of the URL itself.

## `maxSitemaps` (type: `integer`):

Safety limit on how many sitemap files are read for each website.

## `requestTimeoutSecs` (type: `integer`):

How long to wait for each sitemap or status check before giving up. Requests that fail are retried twice.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://crawlee.dev"
    }
  ],
  "maxUrls": 50,
  "includeUrlsContaining": [],
  "excludeUrlsContaining": [],
  "checkStatus": false,
  "maxSitemaps": 500,
  "requestTimeoutSecs": 30
}
```

# Actor output Schema

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

No description

## `summary` (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 = {
    "startUrls": [
        {
            "url": "https://crawlee.dev"
        }
    ],
    "maxUrls": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("faglez/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 = {
    "startUrls": [{ "url": "https://crawlee.dev" }],
    "maxUrls": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("faglez/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 '{
  "startUrls": [
    {
      "url": "https://crawlee.dev"
    }
  ],
  "maxUrls": 50
}' |
apify call faglez/sitemap-url-extractor --silent --output-dataset

```

## MCP server setup

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