# Links API: map a site's URLs before you scrape | Spider

Spider's links API fetches a site's pages and returns the links on each one, without the content. Map the URLs, then scrape or crawl the ones you choose.

Canonical: https://spider.cloud/api/links/

## Links API. Map a site before you scrape it.

Send one URL and get back the links on each page, without the page content, so you can choose the URLs worth scraping.

Request

```
POST https://api.spider.cloud/links{ "url": "https://books.toscrape.com/",  "limit": 50, "depth": 2,  "return_page_links": true }
```

```
curl https://api.spider.cloud/links \  -H "Authorization: Bearer $SPIDER_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "url": "https://books.toscrape.com/",    "limit": 50,    "depth": 2,    "return_page_links": true  }'
```

Response 200, the first page's links

1. "links": \[
2. "catalogue/page-2.html",
3. "catalogue/category/books/classics_6/index.html",
4. "catalogue/the-boys-in-the-boat-nine-americans-and-their-epic-quest-for-gold-at-the-1936-berlin-olympics_992/index.html",
5. "catalogue/scott-pilgrims-precious-little-life-scott-pilgrim-1_987/index.html",
6. ],
7. "status": 200,
8. "url": "https\://books.toscrape.com/"

73 hrefs on this page

Hrefs come back as the page wrote them, so a relative path comes back relative.

In [our recorded run of November 19, 2026](#recorded-run), one links call fetched 50 pages of books.toscrape.com and returned 3,697 hrefs naming 1,061 unique URLs.

Each page fetched bills bandwidth from $1 per GB plus $0.0001 per minute a request runs. Cost varies by site.

[Get an API key](https://spider.cloud/register/)

POST /links 2026-11-19

50 pages, in response order

One mark in the top row for each page. Under it, one mark for every URL that page was the first to name.

73 new URLs from page 1 21 or 22 new URLs from each of 47 pages

0 new URLs from 2 pages, /index.html and /catalogue/page-1.html

50 pages fetched limit 50, depth 2

3,697 hrefs returned 73 or 74 a page

1,061 unique URLs named each href resolved against its page

Unique URLs, by path

- Book pages 960 URLs

  /catalogue/{book}/index.html

- Category pages 51 URLs

  /catalogue/category/...

- Listing pages 49 URLs

  /catalogue/page-{n}.html

- Home page 1 URL

  /index.html

Recorded November 19, 2026 against books.toscrape.com, a public sandbox site. One links request and one crawl request went out 46 seconds apart with the same url, limit and depth.

## The request, field by field

Four fields went over the wire: the start URL and the two caps a crawl takes, plus the flag that puts each page's hrefs in the response.

[Run this](https://spider.cloud/playground/?mode=links\&url=https%3A%2F%2Fbooks.toscrape.com%2F\&p.limit=50\&p.depth=2\&src=api_links_run)

```
curl https://api.spider.cloud/links \  -H "Authorization: Bearer $SPIDER_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "url": "https://books.toscrape.com/",    "limit": 50,    "depth": 2,    "return_page_links": true  }'
```

```
from spider import Spider client = Spider() pages = client.links(    "https://books.toscrape.com/",    params={        "limit": 50,        "depth": 2,        "return_page_links": True,    },) for page in pages:    print(page["url"], len(page["links"]))
```

```
import {  Spider,} from "@spider-cloud/spider-client"; const client = new Spider(); const pages = await client.links(  "https://books.toscrape.com/",  {    limit: 50,    depth: 2,    return_page_links: true,  },); for (const page of pages) {  console.log(page.url, page.links.length);}
```

- url

  - "https\://books.toscrape.com/"
  - The address to start from. A comma-separated list starts from several.

- limit

  - 50
  - Caps the pages fetched, not the URLs found. Each page can name many.

- depth

  - 2
  - Caps how deep the run goes. The reference default is 25, and [the reference](https://spider.cloud/docs/api/links/) has the full entry. Try a value on a small limit before you rely on it.

- return_page_links

  - true
  - Puts each page's hrefs in links, as the page wrote them. Leave the flag out and links comes back empty.

## Links or crawl?

We sent both endpoints the same URL, limit and depth, and both fetched the same pages. Links returned the hrefs and left the content out. Crawl returned the markdown. Pick by what you need back.

- To see a site before deciding what to fetch Links

  Sort the returned hrefs by path and you have the sections of the site before any page is converted.

- To fetch a chosen part of a site Links, then Scrape

  Filter the resolved URLs in your own code and send the ones you kept to Scrape as a comma-separated url. If the job is the 960 book pages, the 51 category pages are left out of the scrape.

- The content of every page the run reaches Crawl

  Crawl returns each page as markdown. Links returns null in content.

- A small response Links

  With the content left out, the links body in this run was about half the size of the crawl body.

- Links and content in one call Crawl

  Send return_page_links: true to crawl and each page carries both.

limit 50, depth 2

Reading POST /links POST /crawl

Pages returned Links 50 pages Crawl 50 pages

Hrefs returned Links 3,697 hrefs Crawl 0 hrefs

Markdown returned Links 0 characters Crawl 307,511 characters

Response body Links 241,846 bytes Crawl 471,393 bytes

Wall time Links 18.06 s Crawl 19.28 s

One run of each endpoint. Wall time is a single reading, and two calls do not rank the endpoints on speed.

## What one links call returns

An array with one object per page fetched. It is the shape a crawl returns, with links filled in and content empty.

field in this run

- `url`

  The page that was fetched, as an absolute URL.

- `status`

  The HTTP status of that fetch. All 50 were 200.

- `links`

  The hrefs on the page, as the page wrote them. 73 or 74 per page in this run, each listed once.

- `content`

  null on every page.

- `costs`

  What the page cost in dollars, in parts. transform_cost was 0 on every page.

- `error`

  null on every page in this run.

The parameters that scope a crawl scope a map. whitelist and blacklist take path patterns, and sitemap adds the URLs the site lists in its sitemap.

[Every parameter in the links reference](https://spider.cloud/docs/api/links/)

response 200 first object

1. \[
2. {
3. "content": null,
4. "costs": {
5. "ai_cost": 0.0,
6. "bytes_transferred_cost": 6.715185e-​7,
7. "compute_cost": 4.301966666666667e-​6,
8. "file_cost": 0.00013772439,
9. "total_cost": 0.00014269787516666665,
10. "transform_cost": 0.0,
11. },
12. "error": null,
13. "links": \[
14. "catalogue/​page-​2.html",
15. "catalogue/​category/​books/​classics_6/​index.html",
16. ...
17. ],
18. "status": 200,
19. ...
20. "url": "https\://books.toscrape.com/"
21. },

Line numbers are those of the body printed with two-space indentation. Three dots stand for a run of lines left out.

Resolve each href against the url of the page it came from before you fetch it. Here are two from this response, found one folder apart.

- page

  /

- href

  catalogue/​page-2.html

- url

  https\://books.toscrape.com/​catalogue/​page-2.html

* page

  /​catalogue/​page-2.html

* href

  category/​books/​health_47/​index.html

* url

  https\://books.toscrape.com/​catalogue/​category/​books/​health_47/​index.html

## What a links call costs

Links bills each page it fetches, on the meter a crawl uses, less the step that converts the page to markdown.

Fetching cost the same on both sides. The difference is transform_cost, the step that converts a page to markdown, which links skips. That put links at $0.000138 a page against $0.000156 for crawl, about 12% less. The saving is small, so choose links for the map.

Pay as you go from $1 per GB of bandwidth plus $0.0001 per minute a request runs. No subscription. Top up from $5.

costs, USD

Key, all 50 pages POST /links POST /crawl

compute_cost Links $0.00004958 Crawl $0.00005679

bytes_transferred_cost Links $0.00003641 Crawl $0.00003641

file_cost Links $0.00683168 Crawl $0.00683168

transform_cost Links $0.00000000 Crawl $0.00089500

total_cost Links $0.00691767 Crawl $0.00781989

Each key of costs, added up across the pages of one run. Dollars, to eight places.

This is one run on light static pages. Cost varies by site, and a links response reports each page's cost in costs.total_cost, so your own first map shows what yours costs.

## Common questions

What does the links API cost?

Each page links fetches bills bandwidth from $1 per GB plus $0.0001 per minute a request runs. In our recorded run of November 19, 2026, 50 light static pages of books.toscrape.com cost $0.0069 in total, which is $0.000138 a page. A crawl of the same 50 pages cost $0.000156 a page. Cost varies by site.

What is the difference between the links API and the crawl API?

Both start from one URL and fetch pages by following links, with the same limit and depth. Links returns the hrefs on each page and leaves content empty. Crawl returns each page's content. In our recorded run, both fetched the same 50 pages of books.toscrape.com, and the links response was 241,846 bytes against 471,393 for crawl.

Does limit cap the number of URLs the links API returns?

limit caps the pages fetched, not the URLs found, and each page can name many URLs. In our recorded run, a limit of 50 fetched 50 pages, and those pages returned 3,697 hrefs naming 1,061 unique URLs.

Are the links returned as absolute URLs?

The url of each fetched page is absolute. The hrefs in its links array come back as the page wrote them, so a relative href comes back relative. Resolve each one against the url of the page it was found on before you fetch it.

How do I scrape the URLs I picked from a links response?

Resolve each href to an absolute URL, filter the list in your own code, and send the ones you kept to /scrape as a comma-separated url. To fetch a whole section instead, send its top URL to /crawl with a limit.

Can I keep a link map to one part of a site?

Yes. whitelist and blacklist take path patterns, including regex. budget sets a page cap per path, such as {"/docs/": 100}. sitemap adds the URLs in the site's sitemap to the run.

### Keep reading

[Crawl API](https://spider.cloud/api/crawl/)

[The same pages with their content, capped by limit and depth.](https://spider.cloud/api/crawl/)

[Scrape API](https://spider.cloud/api/scrape/)

[Fetch the URLs you chose as markdown, HTML or text.](https://spider.cloud/api/scrape/)

[SEO tracking](https://spider.cloud/use-cases/seo-tracking/)

[A link map run on a schedule to see what a site added or dropped.](https://spider.cloud/use-cases/seo-tracking/)

## See the site, then choose

A links call returns the URLs a site carries, and you decide which ones are worth a scrape. Pay as you go, with bandwidth from $1 per GB.

[Get an API key](https://spider.cloud/register/)
