Image search
Search Baidu Images for original image URLs, thumbnails, sizes and the pages that show each image.
Loading / 加载中…
Baidu Search API · Search & SEO data
The Baidu Search API offers six operations over Baidu's search results: web search with filters and result groups, news, images, videos, query suggestions and redirect link resolution. Queries can be written in Chinese, English or any other language.
JSON in, a structured response out. Every public gateway endpoint uses POST.
Search Baidu Images for original image URLs, thumbnails, sizes and the pages that show each image.
Search Baidu News for headlines, article URLs, publishers and publish times, by relevance or newest first.
Turn a Baidu redirect link into the destination URL and domain it points to.
Search Baidu web results with time, site, file type and title or URL filters, plus ads, top stories, shopping cards and a knowledge panel.
Get the query completions Baidu offers while a query is being typed.
Search Baidu Video for video titles, video page URLs, durations, platforms and publish dates.
Baidu Search is the core product of Baidu, the Beijing-based technology company incorporated in January 2000. Because Google is blocked in China, most Chinese internet users rely on Baidu as their default search engine. Its results pages draw on Baidu's own content products, including Baike (an encyclopedia), Zhidao (question and answer), Tieba (discussion forums) and Wenku (document sharing), and advertisers bid for keywords so that paid placements appear alongside the results.
baidu-search returns the parts of a Baidu results page as separate groups inside data:
| Field | What it tells you |
|---|---|
organic_results | the ranked web results, each with a title, snippet, source and date |
ads | paid placements that Baidu shows beside the web results |
top_stories | news cards with headline, publisher, date, snippet and thumbnail |
shopping_results | product cards with price, currency, store and sales |
knowledge_graph | the Baidu Baike panel for the topic, as one object |
ai_overview | Baidu's AI answer, split into headed sections |
related_searches | related query phrases, each row pairing a query with a link |
Inside ai_overview, each entry of sections pairs a heading with its text. Each entry of sources names a title, a source and a link. The knowledge_graph object carries a title, a type, a description, an image and a link.
baidu-suggest returns suggestions, the completions Baidu offers while a query is being typed, in Baidu's order, which gives Chinese keyword research a starting point. The completions, like the rows of related_searches, are query phrases that can be sent back as body.q to open results of their own.
Organic rows carry two addresses: url is the real destination page, while link is Baidu's redirect for the same result. For results whose real address Baidu does not print, such as widget cards and top stories, setting body.resolve_links to true makes the call follow Baidu's redirect to the destination.
Web results need no such step because url already holds the destination. The option defaults to false and can add up to a second to the call.
Three optional inputs of baidu-search narrow a query without extra operators in the text:
body.site limits results to one site or domainbody.file_type limits results to documents of one typebody.scope sets where the query words must appearbody.file_type takes one of these document types:
pdf: PDF documentsdoc: Word files, in doc and docx formxls: Excel files, in xls and xlsx formppt: PowerPoint files, in ppt and pptx formrtf: RTF documentstxt: plain text filesbody.scope takes all, the default, for a match anywhere on the page, title for a match in the page title and url for a match in the address.
Each media operation returns rows built for a different job, and position gives a row's place in its list.
| Field | What it tells you |
|---|---|
original | the address of the image file itself |
source_page | the page where the image was found |
is_gif | whether the image is a GIF |
source | the publisher of a news article, or the platform of a video |
date | when a news article or video was published |
duration | the length of a video |
baidu-images rows add thumbnail, width, height and format, and total_results holds Baidu's total image count. In baidu-news, url holds the real article address and total_results is Baidu's own count of matching articles. In baidu-videos, url holds the real video page on platforms such as Bilibili, Haokan, iQIYI and Xigua.
The paging values of baidu-search sit in a pagination group of data:
| Field | What it tells you |
|---|---|
current_page | the page the response holds |
results_per_page | the number of results on each page |
page_offset | where the returned page begins |
total_pages | the number of pages |
In baidu-search, body.page counts pages of body.num results. The names pn and start are accepted for body.offset, and rn and results_per_page for body.num.
baidu-news returns a smaller pagination with current_page and next_page_offset. The has_more field of baidu-images shows whether more pages exist, while baidu-suggest and baidu-resolve-link take no paging input.
POST /api/v1/baidu/<action> with x-api-key, Content-Type: application/json and a required Idempotency-Key.ok: true: data is the result of the operation, meta.requestId identifies the recorded request and meta.chargedCreditUnits is the amount charged. Otherwise ok is false and error.code names the reason; read ok and error.code rather than relying on the HTTP status alone. Every gateway reply carries a request id for support: meta.requestId, or a top-level requestId in a reply without meta (such as a refusal before admission).position and domain of each organic result on every run.baidu-news, saving each article's URL, publisher and publish time.rank and query of hot_searches, or price and store reports built from shopping_results.body.page runs from 1 to 76 in baidu-search, baidu-news and baidu-images, and from 1 to 30 in baidu-videos; values outside the range are rejected by the operation.body.num runs from 10 to 50 and defaults to 10; a value outside the range is clamped to it, and an invalid value is ignored with the default applied.body.offset runs from 0 to 750, and body.site takes a domain written with letters, digits, dots and hyphens.baidu-images returns 30 rows per page, baidu-news returns 10 and baidu-videos returns about 10.baidu-resolve-link resolves Baidu redirect links only; ad click links are not followed.Send the keyword as body.q to baidu-search. query, keyword and wd are accepted as alternative names for body.q. The ranked web results arrive in organic_results inside data, while ads, related searches, top stories and the other results arrive in groups of their own. Add body.page to read a later page of results.
Set body.sort to date when calling baidu-news; the default is relevance, which puts the most relevant articles first. Every row of news_results has a date for its publish time beside the title, url and source, so successive runs can be compared row by row. Use body.page to move on to further articles.
Pass the redirect link, as returned in the link field of a result, to baidu-resolve-link in body.url; link is also accepted as the input name. The returned data holds the destination in url and its domain in domain, so the real page can be stored without the redirect.
Use body.time_period with day, week, month or year to keep pages from the past 24 hours, 7 days, 30 days or 365 days. For a custom range, send body.date_from and body.date_to as YYYY-MM-DD dates; the start is read as China time and the end date is inclusive. Callers who already build Baidu's raw epoch filter can send it in body.gpc instead.
Yes. Baidu's own operators work inside body.q, for example site:zhihu.com, intitle:word, filetype:pdf, an "exact phrase" in quotation marks, or -word to exclude a term. If the domain, the file kind or the title match comes from separate settings, the dedicated site, file type and scope inputs add the matching operator to the query for you.
body.page counts from 1, so increase it by one and keep the rest of the query unchanged, or give body.offset as an absolute start position instead. In baidu-search, the pagination group returns next_page_offset, the offset to continue with, so a loop can follow it from page to page.
Call baidu-search and read hot_searches in data. Each entry has a rank, a query and a pinned field that shows whether Baidu pins the entry in its list. A hot query can be sent back as body.q to see the results Baidu shows for it, and the list can be saved with each run to follow how the ranking changes.
They arrive in separate lists of data: organic_results holds the ranked web results and ads holds the sponsored ones. An ad row has a placement of top, middle or bottom for its place on the page and a landing_url for the advertiser's page, while an organic row has a url for the real destination. Both kinds of row number themselves with position.