Baidu Autocomplete
curl --request GET \
--url https://scrapebadger.com/v1/baidu/autocomplete \
--header 'X-API-Key: <x-api-key>'import requests
url = "https://scrapebadger.com/v1/baidu/autocomplete"
headers = {"X-API-Key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<x-api-key>'}};
fetch('https://scrapebadger.com/v1/baidu/autocomplete', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://scrapebadger.com/v1/baidu/autocomplete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://scrapebadger.com/v1/baidu/autocomplete"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://scrapebadger.com/v1/baidu/autocomplete")
.header("X-API-Key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://scrapebadger.com/v1/baidu/autocomplete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"query": "<string>",
"suggestions": [
{
"query": "<string>",
"type": "<string>"
}
]
}Search
Baidu Autocomplete
Baidu search-box suggestions for a partial term — the cheapest call in the Baidu API at 1 credit.
GET
/
v1
/
baidu
/
autocomplete
Baidu Autocomplete
curl --request GET \
--url https://scrapebadger.com/v1/baidu/autocomplete \
--header 'X-API-Key: <x-api-key>'import requests
url = "https://scrapebadger.com/v1/baidu/autocomplete"
headers = {"X-API-Key": "<x-api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<x-api-key>'}};
fetch('https://scrapebadger.com/v1/baidu/autocomplete', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://scrapebadger.com/v1/baidu/autocomplete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://scrapebadger.com/v1/baidu/autocomplete"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<x-api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://scrapebadger.com/v1/baidu/autocomplete")
.header("X-API-Key", "<x-api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://scrapebadger.com/v1/baidu/autocomplete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"query": "<string>",
"suggestions": [
{
"query": "<string>",
"type": "<string>"
}
]
}Baidu’s search-box suggestions for a partial term — what the dropdown on
baidu.com would show as you type. At 1 credit this is the cheapest call in
the Baidu API and the fastest way to turn a seed term into real Chinese queries
people actually search.
Credits: 1
Authorization
string
required
Your ScrapeBadger API key.
Query Parameters
string
required
Partial search term, e.g.
咖啡 or coff. URL-encode as UTF-8.Response
string
Echo of the partial term.
Suggestion[]
Example
curl "https://scrapebadger.com/v1/baidu/autocomplete?query=%E5%92%96%E5%95%A1" \
-H "X-API-Key: YOUR_API_KEY"
const res = await fetch(
"https://scrapebadger.com/v1/baidu/autocomplete?" + new URLSearchParams({ query: "咖啡" }),
{ headers: { "X-API-Key": process.env.SCRAPEBADGER_API_KEY } },
);
const data = await res.json();
import requests
res = requests.get(
"https://scrapebadger.com/v1/baidu/autocomplete",
headers={"X-API-Key": "YOUR_API_KEY"},
params={"query": "咖啡"},
)
data = res.json()
Response
{
"query": "咖啡",
"suggestions": [
{ "query": "咖啡品牌排行榜", "type": "sug" },
{ "query": "咖啡机", "type": "sug" },
{ "query": "咖啡品牌", "type": "sug" },
{ "query": "咖啡豆", "type": "sug" },
{ "query": "咖啡斑", "type": "sug" }
]
}
Keyword expansion
Autocomplete is the cheap half of a two-step keyword workflow:- Call
/autocompleteon the seed term (1 credit) to get Baidu’s real query variants. - Call
/searchon each variant (5 credits) and merge results onurl.
related_searches block on every /search
response feeds the same loop for free.
Suggestions are prefix-driven, so the seed’s ending changes the whole set:
咖啡 returns brand and bean queries, while 咖啡机 returns machine queries.
Fan out over a few seeds rather than trusting one.Latin input works —
coff returns suggestions — but Baidu’s suggestion index
is overwhelmingly Chinese, so Chinese seeds return far more.Errors
| Status | Meaning |
|---|---|
422 | Anti-bot challenge — not billed. Retry; it succeeds. |
502 | Baidu’s suggestion API returned an unparseable payload. Retry. |

