# Crawl a website

> Crawl a whole website in the background: start at one page, follow links of the same site up to a depth and page limit, get every page as Markdown, HTML or data.

Source: https://docs.virginproxy.com/crawl/

`POST /v1/crawl` starts at one page and follows the links of the same site, breadth first, until it reaches `max_depth` or `max_pages`. It runs in the background as a [job](https://docs.virginproxy.com/jobs/): you get its id at once and fetch the pages as they are done – or let a [webhook](https://docs.virginproxy.com/webhooks/) bring them.

## Start a crawl

**cURL**

```bash
curl https://api.virginproxy.com/v1/crawl \
  -H "Authorization: Bearer $VP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://docs.virginproxy.com/",
    "max_pages": 4,
    "max_depth": 1,
    "request": {
      "format": "markdown",
      "main_content": true
    },
    "tag": "docs-crawl"
  }'
```

**Python**

```python
import os, requests

r = requests.post(
    "https://api.virginproxy.com/v1/crawl",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    json={
        "url": "https://docs.virginproxy.com/",
        "max_pages": 4,
        "max_depth": 1,
        "request": {"format": "markdown", "main_content": True},
        "tag": "docs-crawl",
    },
    timeout=30,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["id"], data["status"])
```

**Node.js**

```javascript
const res = await fetch("https://api.virginproxy.com/v1/crawl", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.VP_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({
    url: "https://docs.virginproxy.com/",
    max_pages: 4,
    max_depth: 1,
    request: { format: "markdown", main_content: true },
    tag: "docs-crawl",
  }),
  signal: AbortSignal.timeout(30_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.id, data.status);
```

**Python SDK**

```pysdk
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.call("POST", "/v1/crawl", {
    "url": "https://docs.virginproxy.com/",
    "max_pages": 4,
    "max_depth": 1,
    "request": {"format": "markdown", "main_content": True},
    "tag": "docs-crawl",
})
print(data)
```

**Node SDK**

```nodesdk
import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs

const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.crawl({
  url: "https://docs.virginproxy.com/",
  max_pages: 4,
  max_depth: 1,
  request: { format: "markdown", main_content: true },
  tag: "docs-crawl",
});
console.log(data);
```

**PHP**

```php
<?php
$ch = curl_init("https://api.virginproxy.com/v1/crawl");
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "url" => "https://docs.virginproxy.com/",
        "max_pages" => 4,
        "max_depth" => 1,
        "request" => ["format" => "markdown", "main_content" => true],
        "tag" => "docs-crawl",
    ], JSON_UNESCAPED_SLASHES),
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
    exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["id"], " ", $data["status"], PHP_EOL;
```

**Go**

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	payload := []byte(`{
  "url": "https://docs.virginproxy.com/",
  "max_pages": 4,
  "max_depth": 1,
  "request": {
    "format": "markdown",
    "main_content": true
  },
  "tag": "docs-crawl"
}`)
	req, err := http.NewRequest("POST", "https://api.virginproxy.com/v1/crawl", bytes.NewReader(payload))
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var data map[string]any
	if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
		log.Fatal(err)
	}
	if res.StatusCode >= 300 {
		e := data["error"].(map[string]any)
		log.Fatalf("%v: %v", e["code"], e["message"])
	}
	fmt.Println(data["id"], data["status"])
}
```

POST`/v1/crawl`

*Response:*

```http
HTTP/2 202

{
  "id": "job_RZ0SqikbW5KDPAbikfrL",
  "status": "queued",
  "total": 1,
  "succeeded": 0,
  "failed": 0,
  "canceled": 0,
  "pending": 1,
  "credits": 0,
  "tag": "docs-crawl",
  "webhook": null,
  "created_at": "2026-11-21T23:36:51.501Z",
  "started_at": null,
  "finished_at": null,
  "expires_at": null,
  "last_progress_at": null,
  "kind": "crawl",
  "crawl": {
    "url": "https://docs.virginproxy.com/",
    "max_pages": 4,
    "max_depth": 1,
    "include_paths": [],
    "exclude_paths": [],
    "include_subdomains": false,
    "ignore_query": false
  }
}
```

`total` grows while the crawl finds pages. Everything else works as for every job: progress with [GET /v1/jobs/{id}](https://docs.virginproxy.com/jobs/#status), cancel with `DELETE`, `Idempotency-Key`, the limit of open jobs.

## Get the pages

**cURL**

```bash
curl https://api.virginproxy.com/v1/jobs/job_RZ0SqikbW5KDPAbikfrL/results \
  -H "Authorization: Bearer $VP_KEY"
```

**Python**

```python
import os, requests

r = requests.get(
    "https://api.virginproxy.com/v1/jobs/job_RZ0SqikbW5KDPAbikfrL/results",
    headers={"Authorization": "Bearer " + os.environ["VP_KEY"]},
    timeout=30,
)
data = r.json()
if not r.ok:
    raise SystemExit(data["error"]["code"] + ": " + data["error"]["message"])
print(data["job"]["status"])
print(data["next_offset"])
```

**Node.js**

```javascript
const res = await fetch("https://api.virginproxy.com/v1/jobs/job_RZ0SqikbW5KDPAbikfrL/results", {
  headers: { Authorization: "Bearer " + process.env.VP_KEY },
  signal: AbortSignal.timeout(30_000),
});
const data = await res.json();
if (!res.ok) throw new Error(data.error.code + ": " + data.error.message);
console.log(data.job.status);
console.log(data.next_offset);
```

**Python SDK**

```pysdk
from virginproxy import VirginProxy  # docs.virginproxy.com/sdk/virginproxy.py

vp = VirginProxy()  # reads VP_KEY
data = vp.call("GET", "/v1/jobs/job_RZ0SqikbW5KDPAbikfrL/results")
print(data)
```

**Node SDK**

```nodesdk
import { VirginProxy } from "./virginproxy.mjs"; // docs.virginproxy.com/sdk/virginproxy.mjs

const vp = new VirginProxy(); // reads VP_KEY
const data = await vp.call("GET", "/v1/jobs/job_RZ0SqikbW5KDPAbikfrL/results");
console.log(data);
```

**PHP**

```php
<?php
$ch = curl_init("https://api.virginproxy.com/v1/jobs/job_RZ0SqikbW5KDPAbikfrL/results");
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("VP_KEY"),
    ],
]);
$data = json_decode(curl_exec($ch), true);
if (isset($data["error"])) {
    exit($data["error"]["code"] . ": " . $data["error"]["message"] . PHP_EOL);
}
echo $data["job"]["status"], PHP_EOL;
echo $data["next_offset"], PHP_EOL;
```

**Go**

```go
package main

import (
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"os"
	"time"
)

func main() {
	req, err := http.NewRequest("GET", "https://api.virginproxy.com/v1/jobs/job_RZ0SqikbW5KDPAbikfrL/results", nil)
	if err != nil {
		log.Fatal(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("VP_KEY"))

	client := &http.Client{Timeout: 30 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		log.Fatal(err)
	}
	defer res.Body.Close()

	var data map[string]any
	if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
		log.Fatal(err)
	}
	if res.StatusCode >= 300 {
		e := data["error"].(map[string]any)
		log.Fatalf("%v: %v", e["code"], e["message"])
	}
	fmt.Println(data["job"].(map[string]any)["status"])
	fmt.Println(data["next_offset"])
}
```

GET`/v1/jobs/job_RZ0SqikbW5KDPAbikfrL/results`

*Response (shortened):*

```json
{
  "job": { "id": "job_RZ0SqikbW5KDPAbikfrL", "status": "done", "total": 4, "succeeded": 4, "credits": 4, "kind": "crawl" },
  "items": [
    { "index": 0, "status": "succeeded", "url": "https://docs.virginproxy.com/", "depth": 0, "credits": 1,
      "response": { "status": 200, "format": "markdown", "body": "# Fetch any page from a clean IP …" } },
    { "index": 1, "status": "succeeded", "url": "https://docs.virginproxy.com/requests/", "depth": 1, "credits": 1,
      "response": { "status": 200, "format": "markdown", "body": "# Make a request …" } }
  ],
  "next_offset": null
}
```

Each item has the `url` it read, its `depth` (links away from the start page) and the `response` exactly as `POST /v1/requests` would give it. Results are kept 24 hours after the crawl ends; page through them with `offset`.

## Options

| Field | Default | Meaning |
| --- | --- | --- |
| `max_credits` | – | Cost cap of the whole crawl: once it used that many credits, pages not started end as `job_budget_reached` (not charged). |
| `robots` | `"ignore"` | `"respect"`: pages the site's robots.txt disallows are not read. Reading robots.txt costs 1 credit. |
| `url` | required | The start page. |
| `max_pages` | 100 or the plan limit | Pages at most, start page included: up to your plan's crawl limit (10, 100, 500, 1,000 on Free, Starter, Growth, Scale). |
| `max_depth` | `2` | Links away from the start page, 0 to 10. 0 reads only the start page. |
| `include_paths` | `[]` | Follow only paths that match one of these patterns (up to 20). |
| `exclude_paths` | `[]` | Never follow paths that match one of these patterns (up to 20). |
| `include_subdomains` | `false` | Also follow links to subdomains of the start host. |
| `ignore_query` | `false` | Treat `/list?page=2` and `/list?page=3` as the same page. |
| `request` | `{}` | Options for every page, as for [POST /v1/requests](https://docs.virginproxy.com/reference/) – `format`, `render`, `extract`, `parse`, `max_credits` … – without `url`, `method` and body. |
| `webhook` | – | Where to send results, as for [jobs](https://docs.virginproxy.com/webhooks/). |
| `tag` | – | Tag for the crawl and every page in it. |
| `delivery` | – | Write the pages into your own storage when the crawl ends, see [Delivery](https://docs.virginproxy.com/delivery/). |
| `only_changed` | `false` | Only pages that changed since they were last read (see [below](#only-changed)). |

## Path patterns

Patterns match the whole path of an address, without host and query. `*` matches any characters except `/`, `**` matches anything.

| Pattern | Matches | Does not match |
| --- | --- | --- |
| `/blog/**` | `/blog/`, `/blog/2026/post` | `/blogroll` |
| `/p/*` | `/p/123` | `/p/123/reviews` |
| `/**/reviews` | `/p/123/reviews` | `/reviews/all` |

The start page is always read. Links to files that are not pages (images, PDFs, archives, scripts, stylesheets, feeds) are not followed.

## Links and parse

The crawl reads the links of every page it may go deeper from. They are in the result only if you ask for them with `"parse": ["links"]` in `request` – otherwise `parsed` stays as you asked.

## Only what changed: only_changed

`"only_changed": true` reads every page as usual but compares it with the last time that page was read ([track_changes](https://docs.virginproxy.com/automation/#changes)): pages whose content is the same are left out of the results, the export, the [stream](https://docs.virginproxy.com/jobs/#stream), [deliveries](https://docs.virginproxy.com/delivery/) and item webhooks. Made for crawls that run on a [schedule](https://docs.virginproxy.com/monitors/): each run hands on only what is new or different. Every page is still read and charged.

## What it costs

Every page is one ordinary request with the options in `request`: 1 credit per started MB, 10 or more with `render`. A crawl of 100 plain pages costs about 100 credits. Pages that do not answer are not charged. Check the worst case beforehand with [POST /v1/estimate](https://docs.virginproxy.com/billing/#estimate-api), and set `max_credits` in `request` to bound each page.

> **Note:** A crawl follows what the pages link to. Respect the site's terms and keep the load reasonable: `max_pages` and your plan's parallel requests set the pace, `exclude_paths` keeps it away from pages you do not need.
