100 free credits. No credit card required. Get a key

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 failure
import 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

NameTypeDescription
queryquery · requiredstringExample: 咖啡.
limitquery"10" | "20" | "50"One of 10, 20, 50.
pagequeryinteger
Status codes
StatusMeaning
200Results.
400Invalid input. Nothing was charged.
401Missing or invalid API key.
402Not enough credits, a spend cap was reached, or payment is required.
403The target is private, or the account is suspended.
404Baidu has nothing for that search.
429Too many requests. Wait for Retry-After seconds.
503Baidu 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.