# Deep Search API for RAG

> SERP and page bodies in one round-trip. Built for RAG.

- Endpoint: `POST https://scrapenest.dev/v1/search/deep`
- Price: 5 + 5 / page
- Category: Search & Discovery
- Reference: https://scrapenest.dev/docs#ep-search-deep
- Web page: https://scrapenest.dev/catalog/search-deep
- Updated: 2026-11-04

Same multi-engine SERP as /v1/search, but with the top-N pages fetched, anti-bot-cleared, and parsed into readable text in the same response. Stop bolting a fetcher onto every search call.

## The hard part

Search-then-fetch is a two-step pattern that gets brittle in production: one slow site holds up the whole batch, retries pile up, and you end up paying for failed fetches that came back blocked. One round-trip with a per-page deadline, and failed pages don't bill.

## Deep search API: what you get

- Single round-trip: SERP plus body text in one JSON.
- Per-page fetch budget scales with `depth` (~2.5s fast → ~12s stealth; default ~3.5s) so slow news sites don't block the response.
- Returns extracted text, final URL, status, and elapsed time per page.
- Pages that fail fetching don't bill. You pay only for what you got.
- `depth=stealth` allows full anti-bot escalation on page fetches for hard sites (slower, maximum coverage).

## Deep search API use cases

- **RAG retrieval in one round-trip**: Search and read the top pages in one call, then chunk `pages[].text` straight into your embeddings or prompt.
- **Agent research steps**: Give an agent one tool that returns sources and their contents, with `error` set on any page it couldn't use.
- **Market and competitor research**: Pull the top results for a list of queries and compare what each page says, with `final_url` and `status` recorded for every fetch.

## Deep search API quickstart

Install an SDK with `pip install scrapenest` or `npm install scrapenest`, or call the HTTP API directly with your key in the `Authorization: Bearer` header. No key yet? Sign up free at https://scrapenest.dev/signup, verify your email, then create a key in your dashboard.

### Python SDK

```python
import os
from scrapenest import Client

client = Client(os.environ["SCRAPENEST_API_KEY"])
res = client.search_deep("fastapi vs litestar 2026", num_results=8, fetch_top=5)
print(res.fetched_count, "pages,", res.credits_charged, "credits")
for page in res.pages:
    print(page.url, page.status, len(page.text or ""), page.error)
```

### Node SDK

```javascript
import { ScrapeNest } from "scrapenest";

const client = new ScrapeNest({ apiKey: process.env.SCRAPENEST_API_KEY });
const res = await client.searchDeep({
  query: "fastapi vs litestar 2026",
  num_results: 8,
  fetch_top: 5,
});
console.log(res.fetched_count, "pages,", res.credits_charged, "credits");
for (const page of res.pages) console.log(page.url, page.status, (page.text ?? "").length);
```

### curl

```bash
curl -X POST https://scrapenest.dev/v1/search/deep \
  -H "Authorization: Bearer sn_••••" \
  -H "Content-Type: application/json" \
  -d '{
        "query": "fastapi vs litestar 2026",
        "num_results": 8,
        "fetch_top": 5
      }'
```

### Python (httpx)

```python
import httpx

r = httpx.post(
    "https://scrapenest.dev/v1/search/deep",
    headers={"Authorization": "Bearer sn_••••"},
    json={
        "query": "fastapi vs litestar 2026",
        "num_results": 8,
        "fetch_top": 5,
    },
    timeout=60,
)
data = r.json()
for page in data["pages"]:
    print(page["url"], len(page.get("text") or ""))
```

### JavaScript (fetch)

```javascript
const r = await fetch("https://scrapenest.dev/v1/search/deep", {
  method: "POST",
  headers: {
    "Authorization": "Bearer sn_••••",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    query: "fastapi vs litestar 2026",
    num_results: 8,
    fetch_top: 5,
  }),
});
const { pages } = await r.json();
```

### Go

```go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    body, _ := json.Marshal(map[string]any{
        "query":       "fastapi vs litestar 2026",
        "num_results": 8,
        "fetch_top":   5,
    })
    req, _ := http.NewRequest("POST",
        "https://scrapenest.dev/v1/search/deep", bytes.NewReader(body))
    req.Header.Set("Authorization", "Bearer sn_••••")
    req.Header.Set("Content-Type", "application/json")
    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    var out struct{ Pages []struct{ URL, Text string } }
    json.NewDecoder(resp.Body).Decode(&out)
    for _, p := range out.Pages { fmt.Println(p.URL, len(p.Text)) }
}
```

## Deep search API request and response

### Request body

```json
{
  "query": "fastapi vs litestar 2026",
  "num_results": 8,
  "fetch_top": 5,
  "render": "auto"
}
```

### Response

```json
{
  "query": "fastapi vs litestar 2026",
  "results": [
    {
      "position": 1,
      "url": "https://blog.litestar.dev/comparison",
      "title": "FastAPI vs Litestar in 2026",
      "snippet": "A side-by-side look at routing, DI, and performance …",
      "engine": "bing",
      "engines": ["bing", "duckduckgo"],
      "score": 0.92
    }
  ],
  "pages": [
    {
      "url": "https://blog.litestar.dev/comparison",
      "final_url": "https://blog.litestar.dev/comparison",
      "status": 200,
      "method": "fetch",
      "elapsed_ms": 812,
      "title": "FastAPI vs Litestar in 2026",
      "text": "Litestar 3.0 ships … (cleaned readable text)"
    }
  ],
  "took_ms": 2110,
  "fetched_count": 5,
  "cache_hit": false,
  "credits_charged": 30,
  "unresponsive_engines": [],
  "partial": false
}
```

Fields with no value are left out of the JSON rather than sent as `null`, so read optional fields defensively.

## Deep search API pricing

5 credits base for the SERP, plus 5 credits per page actually fetched. Pages that fail (timeout, block, 4xx) do not bill, and neither do bot walls, consent or login pages, not-found pages, pages under 200 characters, or pages off the query's subject.

## Deep search API limits

- `fetch_top`: 1 to 10 pages, default 5. `num_results`: 1 to 50.
- Per-page fetch budget follows `depth`: about 2.5 s at `fast`, 3.5 s at `balanced` (the default), 6 s at `thorough` and 12 s at `stealth`.
- Whole-call budget: about 4.5 s, 10 s, 11 s and 18 s by depth. `timeout_seconds` (0.1 to 20) can only lower it.
- A page bills only when it is usable: at least 200 characters, on the query's subject, and not a bot wall, consent gate, login redirect or not-found page.
- `page` is accepted but ignored: deep search always reads the first page of results.

## Deep search API error codes

| HTTP | Code | Meaning |
| --- | --- | --- |
| 422 | `validation_error` | A field is out of range, for example `fetch_top` above 10. |
| 503 | `upstream_failed` | The search engines failed inside the time budget. Not billed. |
| 200 (in body) | `search_deadline_exceeded` | The budget ran out before any result arrived: `partial: true`, 0 credits. |
| 200 (per page) | `blocked, not_found, no_content` | Set as a page's `error` when that page couldn't be used. It isn't billed or counted in `fetched_count`. |

Every endpoint can also return `401 unauthorized` (missing or wrong key), `402 insufficient_credits` (balance used up), `403 email_not_verified` (an email signup must verify its address before its key works) and `429 rate_limited` or `concurrency_limit_exceeded`. All errors share one JSON envelope; see the [error reference](https://scrapenest.dev/docs#errors).

## Deep search API FAQ

### What is the difference between search and deep search?

`/v1/search` returns the SERP only. `/v1/search/deep` returns the same SERP plus the cleaned text of the top `fetch_top` pages, fetched in parallel inside the same request, so you skip a second round of scraping.

### How is deep search billed?

5 credits for the search plus 5 for each page that came back usable. Pages that time out, are blocked, run under 200 characters or are off the query's subject bill nothing, and a call that delivers nothing at all is free.

### How do I get past bot walls on the result pages?

Set `depth` to `thorough` or `stealth`. Those tiers escalate blocked pages through a real-browser bypass with a longer per-page budget (about 6 s and 12 s). `fast` and `balanced` skip escalation and fall back to the search snippet.

### What happens when a page can't be used?

A blocked, missing or empty page stays in `pages` with an `error` (`blocked`, `not_found` or `no_content`) and no text, and while the budget allows, the next on-subject result is fetched in its place. If the fetch phase runs out of time you still get the search results, billed as a plain search.

## Related endpoints

- [SERP API for multi-engine web search](https://scrapenest.dev/catalog/search.md): `POST /v1/search`. Multi-engine web search aggregated and re-ranked into one feed.
- [AI answer API with citations](https://scrapenest.dev/catalog/search-answer.md): `POST /v1/search/answer`. RAG-style. Search, fetch, summarise with numbered [1][2] citations.
- [Batch scraping API](https://scrapenest.dev/catalog/scrape-batch.md): `POST /v1/scrape/batch`. Fetch up to 10 URLs in a single request — the same engine as Any URL, run concurrently.

## Get 1,000 free credits

Every account starts on the Free plan: 1,000 credits a month, no card. Verify your email, then mint an API key and make this call. Sign up at https://scrapenest.dev/signup.
