Baidu Search API Documentation
Baidu is a leading search engine in China, known for its extensive reach and popularity among Chinese internet users. It plays a crucial role in the digital landscape of China, providing a wide range of services including web search, image search, and map services. Unlike Google, which exited the Chinese market in 2010 and is only accessible in Hong Kong, Baidu continues to dominate the search engine market in mainland China.
The Baidu Search API, accessed via the endpoint /api/v1/search?engine=baidu
, allows for the scraping of real-time search results.
API Parameters
Search Query
-
- Name
-
q
- Required
- Required
- Description
-
Parameter defines the query you want to search. You can use anything that you would use in a regular Baidu search. e.g.
intitle:
,site:
,filetype:
and more.
Localization
-
- Name
-
ct
- Required
- Optional
- Description
-
This parameter controls the language of search results. There are three options:
0
- Simplified and Traditional Chinese. (Default)1
- Simplified Chinese.2
- Traditional Chinese.
Filters
-
- Name
-
gpc
- Required
- Optional
- Description
-
Defines the specific time period for search results using Unix Timestamps. The parameter format should be
stf=START_TIME,END_TIME|stftype=1
, whereSTART_TIME
andEND_TIME
are Unix Timestamps marking the start and end of the desired timeframe. For example, usingstf=1683108267,1714730667|stftype=1
would limit results to those within a year.
Pagination
-
- Name
-
num
- Required
- Optional
- Description
-
This parameter specifies the number of results to display per page. Maximum number -
50
. Use in combination with thepage
parameter to implement pagination functionality.
-
- Name
-
page
- Required
- Optional
- Description
-
This parameter indicates which page of results to return. By default, it is set to
1
. Use in combination with the num parameter to implement pagination.
Engine
-
- Name
-
engine
- Required
- Required
- Description
-
Parameter defines an engine that will be used to retrieve real-time data. It must be set to
baidu
.
API key
-
- Name
-
api_key
- Required
- Required
- Description
-
The
api_key
authenticates your requests. Use it as a query parameter (https://www.searchapi.io/api/v1/search?api_key=YOUR_API_KEY
) or in the Authorization header (Bearer YOUR_API_KEY
).
API Examples
Organic Results
https://www.searchapi.io/api/v1/search?engine=baidu&q=Animal+Planet
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "Animal Planet"
}
response = requests.get(url, params=params)
print(response.text)
{
"organic_results": [
...
{
"position": 2,
"title": "【动物星球】动物星球商城_Animal Planet是什么牌子",
"link": "https://pinpai.smzdm.com/59685/",
"displayed_link": "什么值得买",
"snippet": "实时推荐动物星球(Animal Planet)商城正品特价。结合动物星球评测与动物星球最新资讯,全方位介绍Animal Planet是什么牌子?什么值得买综合各类动物星球优惠信息,计算最优购买方案,帮您轻松搞定正品...",
"snippet_highlighted_words": ["Animal", "Planet"],
"thumbnail": "https://t8.baidu.com/it/u=1026803159,4238637210&fm=217&app=126&size=f242,150&n=0&f=JPEG&fmt=auto?s=01F65C9344640CAA12FCF17B0300D030&sec=1714842000&t=c3db150577185f3a818a8bbe73ddd2c4"
},
...
]
}
Answer Box - AI Content
https://www.searchapi.io/api/v1/search?engine=baidu&q=%E6%8B%8D%E7%85%A7%E6%80%8E%E6%A0%B7%E6%89%BE%E8%A7%92%E5%BA%A6
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "拍照怎样找角度"
}
response = requests.get(url, params=params)
print(response.text)
{
"answer_box": {
"title": "拍照怎样找角度",
"link": "http://nourl.ubs.baidu.com/278",
"type": "ai_content",
"answer": "拍照时找角度的关键在于创造视觉上的吸引力和深度,..."
}
}
Answer Box - AI Search
https://www.searchapi.io/api/v1/search?engine=baidu&q=%E7%AC%AC%E4%B8%80%E7%89%9B%E9%A1%BF%E5%AE%9A%E5%BE%8B
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "第一牛顿定律"
}
response = requests.get(url, params=params)
print(response.text)
{
"answer_box": {
"type": "ai_search",
"answer": "牛顿第一定律的5个变形公式 查看全文 \n牛顿第一运动定律,简称牛顿第一定律。又称惯性定律、惰性定律。常见的完整表述:任何物体都要保持匀速直线运...",
"references": [
{
"title": "牛顿第一定律的5个变形公式 查看全文 ",
"snippet": "牛顿第一运动定律,简称牛顿第一定律。又称惯性定律、惰性定律。常见的完整表述:任何物体都要保持匀速直线运动或静止状态,直到外力迫使它改变运动状态为止...",
"source": "百度文库"
},
...
]
}
}
Answer Box - Calculator
https://www.searchapi.io/api/v1/search?engine=baidu&q=5%21%2A4%21
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "5!*4!"
}
response = requests.get(url, params=params)
print(response.text)
{
"answer_box": {
"type": "calculator",
"query": "5!*4!",
"answer": "2880"
}
}
Answer Box - Dictionary
https://www.searchapi.io/api/v1/search?engine=baidu&q=New+York
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "New York"
}
response = requests.get(url, params=params)
print(response.text)
{
"answer_box": {
"title": "new york - 百度翻译",
"type": "dictionary",
"displayed_link": "搜索智能聚合",
"translation_meaning": "纽约",
"pronunciations": {
"uk": {
"phonetic": "[njuː jɔːk]",
"chinese_character": "英",
"audio_link": "https://sensearch.baidu.com/gettts?lan=uk&spd=3&source=alading&text=New%20York"
},
"us": {
"phonetic": "[nuː jɔrk]",
"chinese_character": "美",
"audio_link": "https://sensearch.baidu.com/gettts?lan=en&spd=3&source=alading&text=New%20York"
}
},
"word_definition": [
{
"part_of_speech": "n.",
"text": "纽约;缩写词为NY;"
}
],
"example": {
"english_text": "Could you forward any mail to us in New York?",
"translation": "你能不能把所有信件转寄到纽约给我们?",
"audio_link": "https://sensearch.baidu.com/gettts?lan=en&spd=3&source=alading&text=Could%20you%20forward%20any%20mail%20to%20us%20in%20New%20York%3F"
}
}
}
Ads
https://www.searchapi.io/api/v1/search?engine=baidu&q=Microsoft
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "Microsoft"
}
response = requests.get(url, params=params)
print(response.text)
{
"ads": [
...
{
"position": 3,
"title": "word mac版本下载-简体中文-永久使用-支持M1/M2-Word ..",
"link": "https://mac.mac89.com/mac/2990.html",
"source": "长沙库绒科技有限公司",
"date": "2024-06",
"snippet": "word mac版本最新版的带给大家,word中文版是查看,编辑和创建文档必备的办公软件之一,提供丰富的功能集,有效提高办公效率.永久使用,低至49!安心下载!",
"sitelinks": {
"expanded": [
{
"title": "Word Mac",
"link": "https://mac.mac89.com/mac/2990.html",
"snippet": "简体中文",
"thumbnail": "https://ms.bdimg.com/pacific/0/pic/1494304078_2140388939.jpg?x=0&y=0&h=340&w=510&vh=340.00&vw=510.00&oh=340.00&ow=510.00"
},
...
]
},
"thumbnail": "https://fc1tn.baidu.com/it/u=294194447,3814647998&fm=202&mola=new&crop=v1"
},
...
]
}
Knowledge Graph
https://www.searchapi.io/api/v1/search?engine=baidu&q=ChatGPT
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "ChatGPT"
}
response = requests.get(url, params=params)
print(response.text)
{
"knowledge_graph": {
"title": "ChatGPT(OpenAI发布的聊... - 百度百科",
"link": "https://baike.baidu.com/item/ChatGPT/62446358",
"displayed_link": "百度百科",
"snippet": "ChatGPT(全名:Chat Generative Pre-trained Transformer),是OpenAI研发的一款聊天机器人程序,于2022年11月30日发布。ChatGPT是人工智能技术驱动的自然语言处理工具,它能够基于在预训练阶段所见的模式和统计规律,来生成回答,还能根据聊天的上下文进行...详情",
"snippet_highlighted_words": ["ChatGPT", "ChatGPT"],
"sitelinks": {
"inline": [
{
"title": "发展历程",
"link": "http://www.baidu.com/link?url=YkfAk31SvtGjo0aT7gt_tZFz4NpTd4PCKDv2oYIHG5XPRsEW4aqcMExV1fclhMYbzraJ6sFBcFD98jkYWWQzuYzcGDNf_G4wKl0RCnR4-4a"
},
...
]
},
"thumbnail": "https://gimg3.baidu.com/topone/src=https%3A%2F%2Fbkimg.cdn.bcebos.com%2Fsmart%2F63d9f2d3572c11dfa9ec5d9d5b7f75d0f703918f644e-bkimg-process%2Cv_1%2Crw_1%2Crh_1%2Cmaxl_800%2Cpad_1%3Fx-bce-process%3Dimage%2Fresize%2Cm_pad%2Cw_348%2Ch_348%2Ccolor_ffffff&refer=http%3A%2F%2Fwww.baidu.com&app=2011&size=w931&n=0&g=0n&er=404&q=75&fmt=auto&maxorilen2heic=2000000?sec=1714842000&t=64402f72cb8a4b6b5c759ee3f1b2a236"
}
}
Top Searches
https://www.searchapi.io/api/v1/search?engine=baidu&q=Ford
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "Ford"
}
response = requests.get(url, params=params)
print(response.text)
{
"top_searches": [
{
"position": 1,
"query": "习近平寄语新时代青年",
"link": "https://www.baidu.com/s?wd=%E4%B9%A0%E8%BF%91%E5%B9%B3%E5%AF%84%E8%AF%AD%E6%96%B0%E6%97%B6%E4%BB%A3%E9%9D%92%E5%B9%B4&usm=2&ie=utf-8&rsv_pq=b386609900023cba&oq=Ford&rsv_t=4ac4JiQk6DlFhyCjLy9ZVmNrIlbdj0vQIurBsuBGEh08Gf3%2FI%2Fjlfov%2FeJo&rqid=b386609900023cba&rsf=8b9bda9ccf388a2ae1c8d629c663b434_1_15_1&rsv_dl=0_right_fyb_pchot_20811&sa=0_right_fyb_pchot_20811"
},
...
]
}
Top Stories
https://www.searchapi.io/api/v1/search?engine=baidu&q=%E6%96%B0%E9%97%BB%E7%9B%B4%E6%92%AD
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "新闻直播"
}
response = requests.get(url, params=params)
print(response.text)
{
"top_stories": [
{
"title": "6月6日起,“大皖新闻”现场直播安徽新高考",
"link": "https://baijiahao.baidu.com/s?id=1800996017349062945&wfr=spider&for=pc",
"source": "大皖新闻",
"date": "前天12:57",
"snippet": "本次直播活动从6月6日开启,连续四天。为了让广大考生和家长更加直观地了解考场环境和设施,大皖新闻特别安排了考点探访环节。6月6日下午4时起,记者将实地探访多个考点,介..."
},
...
]
}
Blogs
https://www.searchapi.io/api/v1/search?engine=baidu&q=ChatGPT
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "ChatGPT"
}
response = requests.get(url, params=params)
print(response.text)
{
"blogs": [
...
{
"title": "爆火Chatgpt注册 chatgpt使用 完全指南",
"link": "http://www.baidu.com/link?url=GVNfXt9XPBaR3qUuOTRa-axDhKYmo2gF0rQYc9qBFR9fu6tdlcgtzJUVedvgxEsTZdSJMNzlKSseMPutZRf0bgX09MzbD7DhuKsdpwUWCYu",
"source": "CSDN",
"snippet": "ChatGPT是一种语言模型,它被训练来对对话进行建模。它能够通过学习和理解人类语言来进行对话,并能够生成适当的响应。ChatGPT使用了一种叫做Transformer的神经网络架构...",
"reads": "1万次阅读"
},
...
]
}
Inline Shopping
https://www.searchapi.io/api/v1/search?engine=baidu&q=Iphone+14
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "Iphone 14"
}
response = requests.get(url, params=params)
print(response.text)
{
"inline_shopping": [
{
"position": 1,
"title": "Apple/苹果 iPhone 14 (A2884) 256...",
"link": "http://item.m.jd.com/product/100046043018.html?cu=true&utm_source=baidu-juhe&utm_medium=kong&utm_campaign=t_1000151230_juhe",
"seller": "京东",
"price": "¥5499",
"extracted_price": 5499,
"thumbnail": "https://t14.baidu.com/it/u=2735956988,123407491&fm=224&app=112&size=h200&n=0&f=PNG?sec=1717520400&t=ee28f35d6e8e49618e4496a5c40977e5"
},
...
]
}
Inline Images
https://www.searchapi.io/api/v1/search?engine=baidu&q=Red+Panda
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "Red Panda"
}
response = requests.get(url, params=params)
print(response.text)
{
"inline_images": {
"total_images": 1763,
"suggestions": [
{
"title": "动物",
"link": "http://www.baidu.com/link?url=fk1_f1wVR-5VLuybRMyHaqtVcgbT5f5QZvPMazYupVlqTfQyiR_f-SWBrsLE12Zkg93XPeBsF_fe_EVQHIRPdqaydOuTroZB8L5JtJdDPVVwWzBkkn6B8otUHkX1AX-77J4tglY1XeZRyPhrtk7Zb3Z3NtJEb-AANSh80-rF_M62eSFIg6lueVLS9K2q4TrTaOTtfbjM5XCfRNsixIsKsAHege8PvfgFtxouR1UFmOUECp1LzyNPmxouBuLfGg5bOYnl1HKWJ2s4xY526-pmZINyMdC4pm8y1K2QsffZCA1RqMsz94sGoVTuNKyawDZUbi5AcZh5Z0AUc5aFNZ4v7ed1Pvf1rFlMURuHOaK1ONQTOfJNwg8dBRaBa2-_jCuJmZMdDRCn0DEj9hGo8aS1P83u2UiqckrqTGizF8WJG_hoEfYEh6y6CjoMbun9DWs6pJUutTR5M3eIxS7TVOoBcaRslGcfrDAAtRTYVRBlVIzNhdK2vR4UMfJbymwjr3Mh"
},
...
],
"images": [
{
"title": "40 interesting red pandas facts",
"original": {
"link": "http://www.seriousfacts.com/wp-content/uploads/2017/04/Endangered-Wildlife-min.jpg"
},
"thumbnail": "https://img1.baidu.com/it/u=97579814,1985408671&fm=253&app=138&size=w931&n=0&f=JPEG&fmt=auto?sec=1714842000&t=a98cf748267d44caa6ba1a3f67457a76"
},
...
]
}
}
Inline Videos
https://www.searchapi.io/api/v1/search?engine=baidu&q=%E6%B5%81%E8%A1%8C%E9%9F%B3%E6%A8%82%E8%A6%96%E9%A0%BB
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "流行音樂視頻"
}
response = requests.get(url, params=params)
print(response.text)
{
"inline_videos": [
{
"position": 1,
"title": "【2024抖音流行热门歌曲合集】精选50首好听的...",
"link": "http://www.baidu.com/link?url=9-_GsS1HAsfvn6pNvbPbjRi0no_m9lcnymDPLyrMUvE0Zyma9F4pXEIYwo93uuhF6ToNcC2o2-xQKz0IyEfDY_",
"source": "哔哩哔哩",
"length": "04:09",
"image": "https://t15.baidu.com/it/u=4162299121,3594302814&fm=225&app=113&size=f256,170&n=0&f=JPEG&fmt=auto?s=1E88FF05581176CE989CD9E10300F031&sec=1717866000&t=163be2528c28b03b29f4966d352351be"
},
...
]
}
Related Searches
https://www.searchapi.io/api/v1/search?engine=baidu&q=Airplane
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "Airplane"
}
response = requests.get(url, params=params)
print(response.text)
{
"related_searches": [
{
"query": "飞机飞机plane的英文歌",
"link": "https://www.baidu.com/s?wd=%E9%A3%9E%E6%9C%BA%E9%A3%9E%E6%9C%BAplane%E7%9A%84%E8%8B%B1%E6%96%87%E6%AD%8C&rsf=101631108&rsp=0&f=1&rs_src=0&rsv_pq=cbcaafed000dbb44&rsv_t=7f938BxeOiT%2BfQBj6Pdsmqy%2BcOyhEfh4jyjqb%2FDcvHSj2yt67aEb8CK1aGc"
},
...
]
}
People Also Search For
https://www.searchapi.io/api/v1/search?engine=baidu&q=Python+courses
- Python
- Node
- Ruby
- Java
- Go
- PHP
- Bash
- R
- Kotlin
- Swift
- C#
- C
- C++
- requests
import requests
url = "https://www.searchapi.io/api/v1/search"
params = {
"engine": "baidu",
"q": "Python courses"
}
response = requests.get(url, params=params)
print(response.text)
{
"people_also_search_for": [
{
"query": "python中real的含义",
"link": "https://www.baidu.com/s?wd=python%E4%B8%ADreal%E7%9A%84%E5%90%AB%E4%B9%89&usm=3&ie=utf-8&rsv_pq=fa36f00a000f5182&oq=Python%20tutorial&rsv_t=f80cl92oDNmKaMxE25keFNUHvQsq%2F6XsA99qvN5a%2B%2FcqRrqFqKRtnGwmlmo&rsf=101631108&rsv_dl=0_prs_28608_1"
},
...
]
}