# Web search API (SERP) to search and scrape | Spider Guides

A web search API that returns SERP results and can scrape every page in the same call. Parameters, geo and time filters, pagination, Python examples.

Canonical: https://spider.cloud/guides/search/

One endpoint, `POST /search`, runs a query against the web and hands back the result list. Turn on `fetch_page_content` and it also scrapes the pages it found, so a [research agent](/blog/web-search-api-for-ai-agents/) gets both the SERP and the text in a single call. The same request accepts a location, a country code, a language, and a time filter. Set `location` to London and `tbs` to `qdr:w` to target that city and hold results to the past week instead of taking the default index.

## Search and scrape in one request

Spider’s [web search API](/api/search/) returns SERP results for a query. Set `fetch_page_content` and the same call scrapes every result it finds, so discovery and extraction happen in one round trip. Common use cases:

- Feeding [real-time content into large language models](/blog/real-time-web-search-for-rag-pipelines/) (LLMs)
- Building intelligent agents and data pipelines
- Crawling and collecting fresh, targeted data

## SERP API endpoint

**POST** `/search` Send a query and get back the ranked result list: title, description and URL for each hit. Feed those URLs to a crawl, or let the same call fetch them.

### Search parameters

| Parameter            | Type    | Required | Default    | Description                                                                                                                                                       |
| -------------------- | ------- | -------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `search`             | string  | **Yes**  | _required_ | The search query to execute. Supports advanced search operators (e.g. `site:`, `intitle:`, `filetype:`).                                                          |
| `search_limit`       | integer | No       | `0` (all)  | Maximum number of results to return. Acts as a filter on top of the results. Set to `0` to return all results.                                                    |
| `num`                | integer | No       | `10`       | Number of results to request per search page. Controls how many results the search engine returns per page.                                                       |
| `page`               | integer | No       | `1`        | The search results page to retrieve. Use with `num` for manual pagination.                                                                                        |
| `fetch_page_content` | boolean | No       | `false`    | When `true`, Spider crawls each search result URL and returns the full page content. Standard crawl parameters apply (see below).                                 |
| `location`           | string  | No       | none       | The geographic location the search should originate from (e.g. `"San Diego, CA"`, `"London, UK"`).                                                                |
| `country`            | string  | No       | none       | Two-letter country code to prioritize results from (e.g. `"us"`, `"fr"`, `"de"`).                                                                                 |
| `language`           | string  | No       | none       | Two-letter language code for search results (e.g. `"en"`, `"es"`, `"ja"`).                                                                                        |
| `tbs`                | string  | No       | none       | Time-based search filter. Restricts results to a specific time period. See values below.                                                                          |
| `quick_search`       | boolean | No       | `true`     | Enables fast search mode with parallel provider queries and automatic retries for broader coverage. Set to `false` for single-provider queries.                   |
| `auto_pagination`    | boolean | No       | `false`    | Automatically paginate through search result pages until `search_limit` is reached. Useful for collecting large result sets without manually incrementing `page`. |

### Time-based search filters (`tbs`)

| Value   | Description   |
| ------- | ------------- |
| `qdr:h` | Past hour     |
| `qdr:d` | Past 24 hours |
| `qdr:w` | Past week     |
| `qdr:m` | Past month    |
| `qdr:y` | Past year     |

### Crawl parameters (when `fetch_page_content` is `true`)

When `fetch_page_content` is enabled, all standard crawl parameters are available alongside search parameters. These let you control how Spider processes each result URL. Common options include:

| Parameter          | Type    | Description                                                                                         |
| ------------------ | ------- | --------------------------------------------------------------------------------------------------- |
| `return_format`    | string  | Content format for crawled pages: `"markdown"`, `"raw"`, `"text"`, `"html2text"`, etc.              |
| `limit`            | integer | Maximum pages to crawl per result URL. Set to `1` to scrape only the landing page.                  |
| `readability`      | boolean | Apply readability pre-processing to extract the main article content.                               |
| `root_selector`    | string  | CSS selector to extract only specific content from each page.                                       |
| `exclude_selector` | string  | CSS selector to exclude elements from the extracted content.                                        |
| `request_timeout`  | integer | Timeout in seconds for each page request.                                                           |
| `headers`          | object  | Custom HTTP headers to send with each crawl request.                                                |
| `locale`           | string  | Locale for the crawl request (e.g. `"en-US"`).                                                      |
| `stealth`          | boolean | Use the full native browser profile and the premium network, for sites that need the most fidelity. |
| `webhooks`         | object  | Webhook destination to stream results to as they arrive.                                            |

For the full list of crawl parameters, see the [Scraping and Crawling docs](/docs/core/scraping-crawling/).

### Example request (Python)

```python
import requests, os

headers = {
  'Authorization': f'Bearer {os.getenv("SPIDER_API_KEY")}',
  'Content-Type': 'application/json',
}

json_data = {
  "search": "sports news today",
  "search_limit": 5
}

response = requests.post('https://api.spider.cloud/search', headers=headers, json=json_data)
print(response.json())
```

## Search results format

The API returns structured results as an array of objects:

```json
[
	{
		"title": "ESPN – Serving Sports Fans. Anytime. Anywhere.",
		"description": "Visit ESPN for live scores, highlights and sports news. Stream exclusive games on ESPN+ and play fantasy sports.",
		"url": "https://www.espn.com/"
	},
	{
		"title": "Sports Illustrated",
		"description": "SI.com provides sports news, expert analysis, highlights, stats and scores for the NFL, NBA, MLB, NHL, college football, soccer...",
		"url": "https://www.si.com/"
	}
]
```

## Scrape every result with fetch_page_content

Set `fetch_page_content: true` and Spider crawls each URL it found. All standard crawl parameters work alongside search parameters, so you can control output format, depth, and proxy settings.

```python
import requests, os

headers = {
  'Authorization': f'Bearer {os.getenv("SPIDER_API_KEY")}',
  'Content-Type': 'application/json',
}

json_data = {
  "search": "spider web crawling",
  "return_format": "raw",
  "fetch_page_content": True,
  "search_limit": 10,
  "limit": 1
}

response = requests.post('https://api.spider.cloud/search', headers=headers, json=json_data)
print(response.json())
```

When `fetch_page_content` is enabled, the response format changes to include full crawl data:

```json
[
	{
		"error": null,
		"status": 200,
		"duration_elasped_ms": 120,
		"costs": {
			"file_cost": 0.000363,
			"ai_cost": 0,
			"compute_cost": 7e-8,
			"transform_cost": 0,
			"total_cost": 0.00036307,
			"bytes_transferred_cost": 0
		},
		"url": "https://en.wikipedia.org/wiki/Web_crawler",
		"content": "<!DOCTYPE html><html><body>content...</body></html>"
	}
]
```

This is useful for:

- Extracting full content from top search results
- Automated research and summarization pipelines
- Reducing round-trips in data collection workflows

## Geo-targeted search

Use `location`, `country`, and `language` to get results as a user in a specific region would see them.

```python
import requests, os

headers = {
  'Authorization': f'Bearer {os.getenv("SPIDER_API_KEY")}',
  'Content-Type': 'application/json',
}

json_data = {
  "search": "latest sports news",
  "search_limit": 5,
  "language": "en",
  "country": "us",
  "location": "San Diego, CA"
}

response = requests.post('https://api.spider.cloud/search', headers=headers, json=json_data)
print(response.json())
```

## Time-filtered search

Restrict results to a specific time period with the `tbs` parameter.

```python
import requests, os

headers = {
  'Authorization': f'Bearer {os.getenv("SPIDER_API_KEY")}',
  'Content-Type': 'application/json',
}

json_data = {
  "search": "AI breakthroughs",
  "search_limit": 10,
  "tbs": "qdr:w"
}

response = requests.post('https://api.spider.cloud/search', headers=headers, json=json_data)
print(response.json())
```

## Search operators

The `search` string takes the operators you would type into a search box. `site:` keeps results on one domain, `intitle:` matches words in the page title, and `filetype:` filters by document type. Pair an operator with `fetch_page_content` to scrape one site’s matching pages as markdown.

```python
import requests, os

headers = {
  'Authorization': f'Bearer {os.getenv("SPIDER_API_KEY")}',
  'Content-Type': 'application/json',
}

json_data = {
  "search": "site:docs.python.org asyncio",
  "search_limit": 5,
  "fetch_page_content": True,
  "return_format": "markdown",
  "limit": 1
}

response = requests.post('https://api.spider.cloud/search', headers=headers, json=json_data)
for page in response.json():
    print(page["url"])
    print(page["content"][:500])
```

## Auto-pagination

Set `auto_pagination: true` to automatically collect results across multiple search pages until your `search_limit` is reached.

```python
import requests, os

headers = {
  'Authorization': f'Bearer {os.getenv("SPIDER_API_KEY")}',
  'Content-Type': 'application/json',
}

json_data = {
  "search": "machine learning tutorials",
  "search_limit": 50,
  "auto_pagination": True
}

response = requests.post('https://api.spider.cloud/search', headers=headers, json=json_data)
print(response.json())
```

## Batch multiple queries

Send an array of query objects to execute multiple searches in a single API call. Each query runs independently and returns its own result set. Streaming is not supported for batch requests.

```python
import requests, os

headers = {
  'Authorization': f'Bearer {os.getenv("SPIDER_API_KEY")}',
  'Content-Type': 'application/json',
}

json_data = [
  {
    "search": "latest sports news united states",
    "search_limit": 5
  },
  {
    "search": "latest news around the globe",
    "search_limit": 5
  }
]

response = requests.post('https://api.spider.cloud/search', headers=headers, json=json_data)
print(response.json())
```

## Rate limits

- Up to 10,000 search requests per minute
- Multiple search providers for redundancy
- Distributed crawling and parsing for fetched content
