# Baidu Search API

> Get Baidu web results for a query with organic results, answer boxes, related searches and pagination.

Source: https://www.sandbase.ai/apis/baidu/search
API reference: https://www.sandbase.ai/apis/baidu/search#api

## Facts

- Provider: Baidu
- Type: Data API
- Endpoint: `POST https://api.sandbase.ai/v1/api/baidu/search`
- Price: $0.01 per call
- Capabilities: api, baidu, web search, serp
- Billing: pay per use from one SandBase balance; no provider account or subscription needed

## Call it

`POST https://api.sandbase.ai/v1/api/baidu/search` with `Authorization: Bearer $SANDBASE_API_KEY` and the parameters as a JSON body.

| Parameter | Type | Required | Allowed values |
| --- | --- | --- | --- |
| `q` | string | yes |  |
| `ct` | string | no |  |
| `pn` | string | no |  |
| `rn` | string | no |  |
| `gpc` | string | no |  |
| `q5` | string | no |  |
| `q6` | string | no |  |
| `bs` | string | no |  |
| `oq` | string | no |  |
| `f` | string | no |  |
| `device` | string | no |  |
| `json_restrictor` | string | no |  |

## FAQ

### How do I use the Baidu Search API?

Send a POST request to https://api.sandbase.ai/v1/api/baidu/search with your SandBase API key in the Authorization header (Bearer) and the parameters as a JSON body. You can also try it in the Playground on this page without writing code.

### How much does the Baidu Search API cost?

$0.01 per call, billed from your SandBase balance. You are only charged for calls you make; there is no subscription.

### What parameters does the Baidu Search API accept?

Required: q (string). Optional: ct (string), pn (string), rn (string), gpc (string), q5 (string) and q6 (string) and 5 more. The Parameters table and the Playground on this page list every field.

### What does the Baidu Search API return?

A JSON response returned in the same HTTP request (synchronous).

### Do I need a Baidu developer account or API key?

No. Baidu Search runs through SandBase, so one SandBase API key covers this endpoint and every other API and model in the catalog. You do not need to apply for Baidu API access separately.

## README

### Baidu Search

Get Baidu web results for a query with organic results, answer boxes, related searches and pagination.

#### Request

```bash
curl -X POST "https://api.sandbase.ai/v1/api/baidu/search" \
  -H "Authorization: Bearer $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"q": "人工智能"}'
```

The result is returned in `outputs[0].data` as structured JSON.

#### Parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `q` | string | Yes | Parameter defines the search query, including all Baidu search operators. (e.g., `inurl:`, `site:`, `intitle:`, etc.). |
| `ct` | string | No | Parameter defines which language to restrict results. Available options: `1` - All languages `2` - Simplified Chinese `3` - Traditional Chinese |
| `pn` | string | No | Parameter defines the result offset. It skips the given number of results. It's used for pagination. (e.g., `0` (default) is the first page of results, `10` is the 2nd page of results, `20` is the 3rd page of results, etc.). |
| `rn` | string | No | Parameter defines the maximum number of results to return, limited to 50. (e.g., `10` (default) returns 10 results, `30` returns 30 results, and `50` returns 50 results). This parameter is only available for **desktop and tablet** searches. |
| `gpc` | string | No | Parameter defines the time period for results. (e.g., `stf=1793918685,1794523485/stftype=1` only returns results from the past 7 days. First integer within the parameter,`1793918685` is Unix Timestamp for 7 days ago. Second integer,`1794523 |
| `q5` | string | No | Similar to using `inurl:` or `intitle:`. (e.g., `1` to search by page title, `2` to search by web address.). |
| `q6` | string | No | Similar to using `site:`. (e.g., `q6=the API.com` to search for results only from the domain `the API.com`). |
| `bs` | string | No | Defines the previous search query. |
| `oq` | string | No | Defines the original search query when navigated from a related search. |
| `f` | string | No | Defines the originating search type. (e.g., `8` is a normal search, `3` is from the suggestion list, and `1` is a related search. |
| `device` | string | No | Parameter defines the device to use to get the results. It can be set to `desktop` (default) to use a regular browser, `tablet` to use a tablet browser (currently using iPads), or `mobile` to use a mobile browser. |
| `json_restrictor` | string | No | Parameter defines the fields you want to include in the output, reducing payload size for faster response. See the JSON Restrictor documentation for more details. |

#### Pricing

$0.010 per successful call. Failed calls are not charged.
