> ## Documentation Index
> Fetch the complete documentation index at: https://docs.scrapegraphai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sitemap

> Extract all URLs from a website sitemap automatically

<Warning>
  **Removed in API v2 — no direct replacement.** For multi-page URL discovery, use [`Crawl`](/services/crawl) with `extraction_mode="links"`, or fetch a `sitemap.xml` directly via [`Scrape`](/services/scrape). This page is kept for reference.
</Warning>

<Frame>
  <img src="https://mintcdn.com/scrapegraphaiinc-9e950277/YyZCOJZ2S-0C1Ind/services/images/markdownify-banner.png?fit=max&auto=format&n=YyZCOJZ2S-0C1Ind&q=85&s=c11d746b66f36295bf2ad5f126bc8274" alt="Sitemap Service" width="3600" height="907" data-path="services/images/markdownify-banner.png" />
</Frame>

## Overview

Sitemap is our service that extracts all URLs from a website's sitemap.xml file automatically. The API discovers the sitemap from robots.txt, common locations like /sitemap.xml, or sitemap index files—perfect for discovering pages for bulk scraping, content inventory, or combining with other endpoints.

<Note>
  Try Sitemap instantly in our [interactive playground](https://scrapegraphai.com/dashboard) - no coding required!
</Note>

## Getting Started

### Quick Start

<CodeGroup>
  ```python Python theme={null}
  from scrapegraph_py import Client

  # Initialize the client
  client = Client(api_key="YOUR_API_KEY")

  # Sitemap request
  response = client.sitemap(
      website_url="https://scrapegraphai.com"
  )

  print("Result:", response)
  ```

  ```javascript JavaScript theme={null}
  import { sitemap } from 'scrapegraph-js';

  const apiKey = 'YOUR_API_KEY';

  const response = await sitemap(apiKey, {
    website_url: 'https://scrapegraphai.com',
  });

  if (response.status === 'error') {
    console.error('Error:', response.error);
  } else {
    console.log('Result:', response.data);
  }
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.scrapegraphai.com/v1/sitemap \
    -H "Content-Type: application/json" \
    -H "SGAI-APIKEY: YOUR_API_KEY" \
    -d '{
    "website_url": "https://scrapegraphai.com"
  }'
  ```

  ```bash CLI theme={null}
  just-scrape sitemap https://scrapegraphai.com
  ```
</CodeGroup>

#### Parameters

| Parameter    | Type    | Required | Description                                                                                                 |
| ------------ | ------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| apiKey       | string  | Yes      | The ScrapeGraph API Key.                                                                                    |
| website\_url | string  | Yes      | The URL of the website to extract the sitemap from. The API will automatically locate the sitemap.xml file. |
| headers      | object  | No       | Optional headers (user agent, cookies, etc.).                                                               |
| mock         | boolean | No       | Enable mock mode for testing. Default: false                                                                |
| stealth      | boolean | No       | Enable stealth mode for anti-bot protection. Adds +5 credits. Default: false                                |

<Note>
  Get your API key from the [dashboard](https://scrapegraphai.com/dashboard)
</Note>

<Accordion title="Example Response" icon="terminal">
  ```json theme={null}
  {
    "request_id": "65401e0d-8cd6-4d6a-88f6-e21255d1c06a",
    "status": "completed",
    "website_url": "https://scrapegraphai.com",
    "urls": [
      "https://scrapegraphai.com/",
      "https://scrapegraphai.com/about",
      "https://scrapegraphai.com/blog",
      "https://scrapegraphai.com/docs",
      "https://scrapegraphai.com/pricing",
      "https://scrapegraphai.com/contact"
    ],
    "error": ""
  }
  ```

  The response includes:

  * `request_id`: Unique identifier for tracking your request
  * `status`: Current status of the extraction
  * `website_url`: The website that was processed
  * `urls`: Array of all URLs found in the sitemap
  * `error`: Error message (if any)
</Accordion>

## Key Features

<CardGroup cols={2}>
  <Card title="Automatic Discovery" icon="magnifying-glass">
    Finds sitemap from robots.txt or common locations
  </Card>

  <Card title="Sitemap Index Support" icon="layer-group">
    Handles sitemap index files with multiple sitemaps
  </Card>

  <Card title="Fast Extraction" icon="bolt">
    Retrieves all URLs without scraping each page
  </Card>

  <Card title="Integration Ready" icon="puzzle-piece">
    Combine with SmartScraper for bulk operations
  </Card>
</CardGroup>

## Use Cases

* Discover all pages on a website for bulk scraping
* Build content inventory from a website
* Monitor website structure changes
* Combine with [SmartScraper](/services/smartscraper) to scrape multiple pages
* Create site maps for SEO analysis

## API Reference

For full request/response details and async status polling, see the [Sitemap API reference](/api-reference/endpoint/sitemap/start).
