Baidu search API
Baidu’s first results page for a query: titles, target URLs, snippets and card types (web results, Baike, video, shopping), as its mobile page shows them.
GET /v1/baidu/searchBeta1 credit per callRefunded on failureimport os, requests
res = requests.get(
"https://api.groundsocial.dev/v1/baidu/search?query=%E5%92%96%E5%95%A1",
headers={"Authorization": f"Bearer {os.environ['GROUNDSOCIAL_API_KEY']}"},
)
res.raise_for_status()
data = res.json()Response
200 · 1 credit{ "query": "咖啡", "page": 1, "results": [ { "position": 1, "title": "咖啡- 百度百科", "url": "https://baike.baidu.com/item/%E5%92%96%E5%95%A1/29518", "snippet": "", "tpl": "sg_kg_entity_san" }, { "position": 2, "title": "咖啡的起源与品种", "url": "https://ikan.baidu.com/pedia/", "snippet": "", "tpl": "new_baikan_index" }, "… 7 more" ]}Parameters
| Name | Type | Description |
|---|---|---|
queryquery · required | string | Example: 咖啡. |
limitquery | "10" | "20" | "50" | One of 10, 20, 50. |
pagequery | integer |
Status codes
| Status | Meaning |
|---|---|
200 | Results. |
400 | Invalid input. Nothing was charged. |
401 | Missing or invalid API key. |
402 | Not enough credits, a spend cap was reached, or payment is required. |
403 | The target is private, or the account is suspended. |
404 | Baidu has nothing for that search. |
429 | Too many requests. Wait for Retry-After seconds. |
503 | Baidu is temporarily unavailable. Retryable; nothing was charged. |
Every error has code, message, hint and retryable. All error codes
Questions
More pages?
Baidu sends later pages to a security check for logged-out visitors, so the first page only.
Baidu is a trademark of Baidu, Inc. We are not affiliated with or endorsed by Baidu.