# Find Sitemap from url (`eesti/find-sitemap-from-url`) Actor

A powerful \[Apify Actor] that finds sitemap URLs for any website. This Actor helps you discover XML sitemaps by checking common locations, robots.txt files, and analyzing HTML content for sitemap links.

- **URL**: https://apify.com/eesti/find-sitemap-from-url.md
- **Developed by:** [ando](https://apify.com/eesti) (community)
- **Categories:** Developer tools, Automation, AI
- **Features:** Limited permissions
- **Stats:** 212 total users, 0 monthly users, 100.0% runs succeeded, 5 bookmarks
- **User rating**: 1.00 out of 5 stars

## Pricing

from $2.00 / 1,000 sitemap lookups

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 Finder

Discover all XML sitemaps for any website by checking common file paths, parsing `robots.txt` directives, and scanning HTML content. Provide one or more URLs and get a complete inventory of every sitemap, validated and classified.

### Features

- **Multi-source discovery** — checks 15+ common sitemap paths, `robots.txt` directives, and HTML `<a>` / `<link>` tags
- **Batch processing** — process multiple websites in a single run with configurable concurrency
- **Recursive index traversal** — follows sitemap index files to discover all nested child sitemaps
- **Gzip support** — handles `.xml.gz` compressed sitemaps automatically
- **XML validation** — verifies sitemaps contain valid XML and classifies them as `index` or `urlset`
- **Rich metadata** — reports URL count per sitemap, last modified date, discovery source, and validation status

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `urls` | `string[]` | — | Website URLs to check (e.g., `["https://example.com"]`) |
| `url` | `string` | — | Single URL for backward compatibility. Merged into `urls` if both are set. |
| `findAll` | `boolean` | `true` | Find all sitemaps or stop after the first one |
| `followIndexes` | `boolean` | `true` | Recursively follow sitemap index files to discover child sitemaps |
| `verify` | `boolean` | `true` | Verify sitemaps are valid XML and extract metadata |
| `timeout` | `integer` | `10` | HTTP request timeout in seconds |
| `concurrency` | `integer` | `3` | Max concurrent website processing (1–20) |

#### Example Input

```json
{
    "urls": ["https://example.com", "https://crawlee.dev"],
    "findAll": true,
    "followIndexes": true,
    "verify": true,
    "timeout": 10,
    "concurrency": 3
}
```

### Output

Results are stored in the default dataset. Each record represents a discovered sitemap:

```json
{
    "websiteUrl": "https://crawlee.dev",
    "sitemapUrl": "https://crawlee.dev/sitemap.xml",
    "type": "index",
    "urlCount": 4,
    "lastModified": "2024-12-15T10:30:00Z",
    "isValid": true,
    "source": "common-location"
}
```

| Field | Description |
|-------|-------------|
| `websiteUrl` | The input website URL |
| `sitemapUrl` | Full URL of the discovered sitemap |
| `type` | Sitemap type: `index` (contains other sitemaps), `urlset` (contains page URLs), or `unknown` |
| `urlCount` | Number of entries in the sitemap (child sitemaps for indexes, page URLs for urlsets) |
| `lastModified` | Most recent `<lastmod>` date found in the sitemap |
| `isValid` | Whether the sitemap contains valid XML |
| `source` | How the sitemap was discovered: `common-location`, `robots.txt`, `html-content`, or `index:<parent-url>` |
| `error` | Error message if the lookup failed (only present on error records) |

When no sitemaps are found for a URL, a single record is returned with `sitemapUrl: null` and an appropriate error message.

### API Usage

Call the actor via the API and retrieve results from the default dataset:

```bash
curl "https://api.apify.com/v2/acts/YOUR_USERNAME~find-sitemap-from-url/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://example.com"]}'
```

### Pricing

This actor uses pay-per-event (PPE) pricing:

| Event | Cost |
|-------|------|
| `sitemap-lookup` | $0.001 per URL processed |

You are charged once per input URL, regardless of how many sitemaps are discovered for that URL. There are no additional platform fees beyond the per-event charge.

### Use Cases

- **SEO auditing** — verify sitemap coverage and freshness across your sites
- **Web scraping** — discover all available sitemaps before crawling to plan efficient scraping
- **Site monitoring** — track sitemap changes, URL counts, and last modified dates over time
- **Competitor analysis** — map out a competitor's site structure via their sitemaps
- **Migration validation** — confirm sitemaps are correctly set up after a site migration
- **Content indexing** — find all content endpoints for search engine optimization

### Discovery Methods

The actor uses three complementary discovery strategies:

1. **Common paths** — checks 15+ well-known sitemap file locations (`/sitemap.xml`, `/wp-sitemap.xml`, `/sitemap_index.xml`, etc.)
2. **robots.txt** — parses `Sitemap:` directives from the site's robots.txt file
3. **HTML scanning** — searches the homepage HTML for `<a>` and `<link>` tags referencing sitemaps

When `followIndexes` is enabled, any discovered sitemap index is recursively expanded to reveal all child sitemaps.

# Actor input Schema

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

List of website URLs to find sitemaps for. Each URL should be the homepage or base URL of a website (e.g., https://example.com).

## `url` (type: `string`):

A single website URL. Use 'urls' for multiple websites. If both are provided, this URL is merged into the urls list.

## `findAll` (type: `boolean`):

If true, searches all common locations, robots.txt, and HTML content. If false, stops after finding the first sitemap.

## `followIndexes` (type: `boolean`):

If true, recursively follows sitemap index files to discover all child sitemaps (capped by maxSitemaps).

## `verify` (type: `boolean`):

If true, verifies that discovered sitemaps contain valid XML and extracts metadata (URL count, type, last modified).

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

Safety cap on how many sitemap URLs to return per website (prevents runaway index following).

## `timeout` (type: `integer`):

HTTP request timeout in seconds for each sitemap check.

## `concurrency` (type: `integer`):

Maximum number of websites to process concurrently.

## Actor input object example

```json
{
  "urls": [
    "https://crawlee.dev"
  ],
  "url": "https://crawlee.dev",
  "findAll": true,
  "followIndexes": true,
  "verify": true,
  "maxSitemaps": 50,
  "timeout": 10,
  "concurrency": 3
}
```

# Actor output Schema

## `results` (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://crawlee.dev"
    ],
    "url": "https://crawlee.dev"
};

// Run the Actor and wait for it to finish
const run = await client.actor("eesti/find-sitemap-from-url").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://crawlee.dev"],
    "url": "https://crawlee.dev",
}

# Run the Actor and wait for it to finish
run = client.actor("eesti/find-sitemap-from-url").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://crawlee.dev"
  ],
  "url": "https://crawlee.dev"
}' |
apify call eesti/find-sitemap-from-url --silent --output-dataset

```

## MCP server setup

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

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/2U4t8F2993kNAE3qE/builds/hfFYlRBeQapAc7Ex1/openapi.json
