# Moving from the Serper request format

Change the host and the key. The bodies stay as they are.

A client written for the Serper request format moves here by changing the host and the key. The bodies, field names and response shapes follow that format. The values come from this service.

## What to change

Base URL and key:

```diff
- $PREVIOUS_BASE_URL
+ https://api.websearch.fast
- X-API-KEY: $PREVIOUS_API_KEY
+ X-API-KEY: $WEBSEARCH_API_KEY
```

In that format the page endpoint is the root of its host, so `POST /` on `api.websearch.fast` reads a page. Set the same host as the base URL of both the search client and the page client.

Before:

```bash
curl "$PREVIOUS_BASE_URL/search" \
  -H "X-API-KEY: $PREVIOUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"q": "apple inc", "gl": "us", "num": 10}'
```

After:

```bash
curl https://api.websearch.fast/search \
  -H "X-API-KEY: $WEBSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"q": "apple inc", "gl": "us", "num": 10}'
```

## Paths

Each path is served at the root of `api.websearch.fast` and under `/v1/web/compat/serper/` on every host. A planned path returns `501 api_not_implemented`.

| Endpoint | On api.websearch.fast | On every host | Native counterpart | State |
| --- | --- | --- | --- | --- |
| search | `POST /search` | `/v1/web/compat/serper/search` | [search](https://websearch.fast/docs/search), `type: web` | available |
| webpage | `POST /` and `POST /webpage` | `/v1/web/compat/serper/webpage` | [fetch](https://websearch.fast/docs/fetch) | available |
| images | `POST /images` | `/v1/web/compat/serper/images` | [search](https://websearch.fast/docs/search), `type: images` | planned |
| videos | `POST /videos` | `/v1/web/compat/serper/videos` | [search](https://websearch.fast/docs/search), `type: videos` | planned |
| news | `POST /news` | `/v1/web/compat/serper/news` | [search](https://websearch.fast/docs/search), `type: news` | planned |
| places | `POST /places` | `/v1/web/compat/serper/places` | [search](https://websearch.fast/docs/search), `type: places` | planned |
| maps | `POST /maps` | `/v1/web/compat/serper/maps` | [search](https://websearch.fast/docs/search), `type: places` with `near` | planned |
| reviews | `POST /reviews` | `/v1/web/compat/serper/reviews` | [place reviews](https://websearch.fast/docs/places-reviews) | planned |
| shopping | `POST /shopping` | `/v1/web/compat/serper/shopping` | [search](https://websearch.fast/docs/search), `type: shopping` | planned |
| lens | `POST /lens` | `/v1/web/compat/serper/lens` | [search by image](https://websearch.fast/docs/lens) | planned |
| scholar | `POST /scholar` | `/v1/web/compat/serper/scholar` | [search](https://websearch.fast/docs/search), `type: scholar` | planned |
| patents | `POST /patents` | `/v1/web/compat/serper/patents` | [search](https://websearch.fast/docs/search), `type: patents` | planned |
| autocomplete | `POST /autocomplete` | `/v1/web/compat/serper/autocomplete` | [autocomplete](https://websearch.fast/docs/autocomplete) | available |

## Request rules

- Numbers and booleans are accepted as JSON values or as strings (`"num": "10"`).
- Unknown fields are ignored, not refused, and named in the response header `X-Web-Ignored-Params`. The native paths are strict instead.
- `num` over 100, or `page` times `num` over 200, is refused with `400`.
- Operators in `q` (`site:`, `-site:`, quotes, `OR`, `-term`, `before:`, `after:`) are parsed as on the native paths.
- `GET` with the same fields as query parameters is accepted on every path, with the key in the `X-API-KEY` header. A key in the query string is refused.
- A JSON array body is a batch of up to 100 items, answered with an array in the same order. Each item is charged as one call.
- The search answer carries `knowledgeGraph` when page 1 has a knowledge panel, with `title`, `type`, `website`, `description`, `descriptionSource`, `descriptionLink`, `attributes` and `attribution`. It is included in the search price.
- `autocomplete` answers with the suggestions of [autocomplete](https://websearch.fast/docs/autocomplete). `location` is ignored, and the response adds `attribution`.

## What does not carry over

- Results never contain redirect links, so there is nothing to resolve.
- `searchParameters.engine` is always `"websearch"`.
- Ranking is our own. Results and their order are not promised to match any other service.
- `credits` in the responses is counted in the units of this service.
- A field that cannot be filled is left out of the response, never sent empty or invented.

## Errors

An error on a compatibility path carries the fields that clients of the format read, and the error object of the native API.

```json
{"message": "Invalid token", "statusCode": 401,
 "error": {"code": "invalid_token", "message": "Invalid token", "type": "authentication_error"},
 "request_id": "20261128120007123456789a1b2c3d4Kx7Qm2Pg"}
```

The native API has more. It returns page text in the same response as the results ([search](https://websearch.fast/docs/search) with `content`), geocoding, batches and an MCP server. Its [reference](https://websearch.fast/docs/reference) lists every operation.
