> ## 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.

# Introduction

> REST API reference for ScrapeGraphAI v2

## Overview

The ScrapeGraphAI v2 API exposes five core services behind a single host. All endpoints accept JSON, return JSON, and are authenticated with an API key header.

* **Scrape** — fetch a URL in one or more formats (markdown, HTML, screenshot, JSON extraction, …) in a single call.
* **Extract** — structured data extraction from a URL, raw HTML, or markdown using a natural-language prompt.
* **Search** — web search with page content returned inline and optional AI extraction across results.
* **Crawl** — async multi-page traversal with URL patterns, depth limits, and per-page formats.
* **Monitor** — cron-scheduled watches with change detection and optional webhooks.
* **History** — look up past requests by ID, including the formatted content of crawled pages via each `scrapeRefId`.

Prefer using an SDK? See the [Python SDK](/sdks/python) or [JavaScript SDK](/sdks/javascript) — both wrap this same API.

## Base URL

```bash theme={null}
https://v2-api.scrapegraphai.com
```

All endpoints are prefixed with `/api/`, e.g. `POST https://v2-api.scrapegraphai.com/api/scrape`.

<Warning>
  The v1 host (`https://api.scrapegraphai.com/v1`) and its endpoint names (`smartscraper`, `searchscraper`, `markdownify`, `smartcrawler`) are deprecated. See the [v1 → v2 transition guide](/transition-from-v1-to-v2) for the endpoint mapping.
</Warning>

## Authentication

All requests require an API key in the `SGAI-APIKEY` header. Get yours from the [dashboard](https://scrapegraphai.com/dashboard).

```bash theme={null}
SGAI-APIKEY: sgai-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```

<Note>
  Keep your API key secret. Never ship it in client-side code — load it from an environment variable or a server-side secret store.
</Note>

## Group requests by session

Add the optional `SGAI-Session-Id` header to requests that belong to the same workflow, agent run, or batch:

```bash theme={null}
curl -X POST https://v2-api.scrapegraphai.com/api/scrape \
  -H "SGAI-APIKEY: $SGAI_API_KEY" \
  -H "SGAI-Session-Id: import-2026-09-15" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com","formats":[{"type":"markdown"}]}'
```

The value is trimmed, must contain 1–128 characters, and is stored as request metadata. It does not change request parameters or cache keys. Requests without the header have no session ID.

Use the same value across related calls, then filter them in the dashboard or with [`GET /api/history?sessionId=import`](/api-reference/endpoint/history). Session filtering is case-insensitive and supports partial matches. Crawl child requests inherit the session ID from the request that started the crawl.

## Endpoints

<CardGroup cols={2}>
  <Card title="Scrape" icon="code" href="/api-reference/endpoint/scrape">
    `POST /api/scrape` — multi-format page fetch.
  </Card>

  <Card title="Extract" icon="robot" href="/api-reference/endpoint/extract">
    `POST /api/extract` — structured data with an LLM prompt.
  </Card>

  <Card title="Search" icon="magnifying-glass" href="/api-reference/endpoint/search">
    `POST /api/search` — web search + content fetch.
  </Card>

  <Card title="Crawl · start" icon="spider" href="/api-reference/endpoint/crawl/start">
    `POST /api/crawl` — start an async crawl job.
  </Card>

  <Card title="Crawl · status" icon="list-check" href="/api-reference/endpoint/crawl/get-status">
    `GET /api/crawl/:id` — poll a crawl job.
  </Card>

  <Card title="Monitor · create" icon="clock" href="/api-reference/endpoint/monitor/create">
    `POST /api/monitor` — schedule a recurring fetch.
  </Card>

  <Card title="Monitor · manage" icon="sliders" href="/api-reference/endpoint/monitor/manage">
    List, pause, resume, update, delete monitors; fetch activity.
  </Card>

  <Card title="History" icon="clock-rotate-left" href="/api-reference/endpoint/history">
    `GET /api/history[/:id]` — list past requests or fetch a single result by ID (including content for crawled pages).
  </Card>

  <Card title="Credits" icon="coins" href="/api-reference/endpoint/credits">
    `GET /api/credits` — remaining balance and job quotas.
  </Card>
</CardGroup>

## HTTP status codes

| Code | Meaning |
| - | - |
| `200` | Success |
| `400` | Validation error — the request body didn't pass schema checks. |
| `401` | Missing `SGAI-APIKEY` header. |
| `402` | Insufficient credits. |
| `403` | Invalid or deprecated API key. |
| `404` | Not found — the resource ID does not exist for this account. |
| `429` | Rate limit exceeded. |
| `500` | Server error. |

See [Error handling](/api-reference/errors) for the full response shape and examples.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.