# Spider Crawl API

> POST one URL and Spider follows the site's links and returns each page as markdown, HTML or text, up to the caps you set.

Generated from the data behind https://spider.cloud/api/crawl/, so the figures here match the page.

## Endpoint

`POST https://api.spider.cloud/crawl`, with your API key as a bearer token. Pay as you go, from $1 per GB, with no subscription. The response is one JSON array with an object for each page fetched, in the order the pages came back.

## One site, crawled twice

Recorded on 2026-11-19 against books.toscrape.com, a public sandbox site. One seed URL went out twice, 43 seconds apart, with depth changed from 2 to 1 and every other field the same. This is the first request as sent.

```json
{
  "url": "https://books.toscrape.com/",
  "limit": 25,
  "depth": 2,
  "return_format": "markdown",
  "request": "http",
  "return_page_links": true
}
```

Six fields went over the wire. Two of them cap the crawl. The other four say where it starts and what comes back for each page.

- `url`: Where the crawl starts. Spider follows links from it.
- `limit`: The most pages the crawl may return, 25 here.
- `depth`: How deep the crawl may go. 2 here, 1 in the second run.
- `return_format`: The form of each page's content, markdown here.
- `request`: How Spider fetches a page. http is a plain fetch without a browser.
- `return_page_links`: Adds a links array to each page, 73 or 74 hrefs here.

What each run returned:

| `depth` | `limit` | Pages returned | Markdown returned | Wall time | Response size | Total cost |
|---|---|---|---|---|---|---|
| 2 | 25 | 25 | 157,728 bytes | 5.52 s | 299,614 bytes | $0.0039 |
| 1 | 25 | 2 | 12,500 bytes | 3.51 s | 23,721 bytes | $0.0003 |

Wall time is the whole call as the client measured it, one reading per run. Response size is the whole JSON body. Total cost is the sum of `costs.total_cost` over the pages.

The first 5 of the 25 pages of the depth 2 run, in the order they came back:

| Place | `status` | Path | `content` |
|---|---|---|---|
| 1 | 200 | `/` | 6,250 bytes |
| 2 | 200 | `/index.html` | 6,250 bytes |
| 3 | 200 | `/catalogue/page-2.html` | 6,162 bytes |
| 4 | 200 | `/catalogue/page-3.html` | 6,562 bytes |
| 5 | 200 | `/catalogue/page-1.html` | 5,903 bytes |

## The same request in code

```bash
curl https://api.spider.cloud/crawl \
  -H "Authorization: Bearer $SPIDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://books.toscrape.com/",
    "limit": 25,
    "depth": 2,
    "return_format": "markdown",
    "request": "http",
    "return_page_links": true
  }'
```

```python
from spider import Spider

client = Spider()

pages = client.crawl_url(
    "https://books.toscrape.com/",
    params={
        "limit": 25,
        "depth": 2,
        "return_format": "markdown",
        "request": "http",
        "return_page_links": True,
    },
)

for page in pages:
    print(page["status"], page["url"])
```

```javascript
import {
  Spider,
} from "@spider-cloud/spider-client";

const client = new Spider();

const pages = await client.crawlUrl(
  "https://books.toscrape.com/",
  {
    limit: 25,
    depth: 2,
    return_format: "markdown",
    request: "http",
    return_page_links: true,
  },
);

for (const page of pages) {
  console.log(page.status, page.url);
}
```

## Which caps to set

Set limit first on any site you have not crawled before. In the recorded pair, limit stopped one run and depth stopped the other.

- `limit`: The most pages one crawl may return. Both runs sent 25, and the depth 2 run ended on it with 25 pages.
- `depth`: Depth 1 ended the other run at 2 pages, 23 short of its limit. The default is 25 and 0 removes the cap, so try a value on a small limit before you rely on it.

Four more caps from the reference. Neither recorded run sent them.

- `budget`: A page count for each path you name, to cap one part of a site apart from the rest.
- `max_credits_allowed`: The most credits the whole run may use.
- `max_credits_per_page`: The most credits any one page may use.
- `crawl_timeout`: The longest the crawl may run, sent as an object of secs and nanos.

Depth and limit in the crawl reference: https://spider.cloud/docs/api/crawl/

## What one crawl returns

The response is one JSON array with an object for each page fetched, in the order the pages came back.

| Key | What it holds |
|---|---|
| `url` | The address of the page. In both recorded runs the seed came first. |
| `status` | The HTTP status of the fetch. All 25 were 200. |
| `content` | The page in the format you asked for. Here that was markdown, 157,728 bytes across the 25 pages. |
| `links` | The hrefs found on the page, present because the request sent return_page_links. Together the 25 pages named 537 distinct URLs. |
| `costs` | What the page cost in dollars, split into compute_cost, bytes_transferred_cost, file_cost and transform_cost, with their sum in total_cost. |
| `error` | Holds the failure for that page when a fetch goes wrong. |

`content` of page 1, `/`, lines 1 to 13 of 168:

```markdown
All products | Books to Scrape - Sandbox
* [Home](index.html)
* All products
**1000** results - showing **1** to **20**.
**Warning!** This is a demo website for web scraping purposes. Prices and ratings here were randomly assigned and have no real meaning.
1.
[![A Light in the Attic](media/cache/2c/da/2cdad67c44b002e7ead0cc35693c0e8b.jpg)](catalogue/a-light-in-the-attic_1000/index.html)
**********
### [A Light in the ...](catalogue/a-light-in-the-attic_1000/index.html)
£51.77
**
In stock
Add to basket
```

`content` of page 3, `/catalogue/page-2.html`, lines 1 to 13 of 169:

```markdown
All products | Books to Scrape - Sandbox
* [Home](../index.html)
* All products
**1000** results - showing **21** to **40**.
**Warning!** This is a demo website for web scraping purposes. Prices and ratings here were randomly assigned and have no real meaning.
1.
[![In Her Wake](../media/cache/5d/72/5d72709c6a7a9584a4d1cf07648bfce1.jpg)](in-her-wake_980/index.html)
**********
### [In Her Wake](in-her-wake_980/index.html)
£12.84
**
In stock
Add to basket
```

`content` of page 25, `/catalogue/page-23.html`, lines 1 to 4 of 169:

```markdown
All products | Books to Scrape - Sandbox
* [Home](../index.html)
* All products
**1000** results - showing **441** to **460**.
```

The recorded run sent Content-Type: application/json and the pages arrived as one array. Send application/jsonl and the API answers with one JSON line per page as each one finishes, per the reference.

## What a crawl costs

From $0.16 per 1,000 pages on light static pages. Cost varies by site.

The receipt adds up the costs object on each of the 25 recorded pages. They came to $0.0039, about $0.16 per 1,000 on light static pages. $0.0034 of that was file_cost, the page bodies as fetched, so a site with heavier pages costs more.

| Key | depth 2, 25 pages | depth 1, 2 pages |
|---|---|---|
| `compute_cost` | 0.00001332 | 0.00000569 |
| `bytes_transferred_cost` | 0.00001815 | 0.00000137 |
| `file_cost` | 0.00342876 | 0.00027545 |
| `transform_cost` | 0.00044750 | 0.00003580 |
| `total_cost` | 0.00390773 | 0.00031831 |

Recorded November 19, 2026 against books.toscrape.com. US dollars, each key summed over the pages of the run. Every page reports its own cost in costs.total_cost. Crawl 25 pages of your own site and the response tells you what the next thousand will cost.

## Crawl or Scrape

This request named one URL and 25 pages came back, 24 of them found by following links. When you already have the URLs, [Scrape](https://spider.cloud/api/scrape/) fetches the ones you name.

## Links

- Page: https://spider.cloud/api/crawl/
- Docs: https://spider.cloud/docs/api/crawl/
- Map a site's URLs first: https://spider.cloud/api/links/
- Rates: https://spider.cloud/pricing/
