Query Google web search results by keyword, returned as structured JSON (title, link, snippet). Authenticate with an Authorization: Bearer YOUR_API_KEY header (an X-Dev-Key header is also accepted), or a logged-in web session; never place keys in URL query strings (they end up in server logs). GET only; the q (query, string) parameter is required. Successful calls deduct credits automatically; failed or empty results are not charged. For news articles, see the Google News API page.
GET https://www.myai168.com/en/api/google/searchGoogle web search, returns up to 20 results (each with title / link / snippet).
| Parameter | Required | Description |
|---|---|---|
q | Required | Search keywords (string). |
hl | Optional | UI language, e.g. en / zh-TW. |
gl | Optional | Region, e.g. us / tw. |
lr | Optional | Result language restriction, format lang_xx (e.g. lang_en); join multiple with |. |
cr | Optional | Source country restriction, format countryXX (e.g. countryUS); join multiple with |. |
tbm | Optional | Search type: nws news / isch images / vid videos / bks books / shop shopping. |
tbs | Optional | Filters such as time: qdr:d past day / qdr:w past week / qdr:m past month / sbd:1 sort by date. |
Optional parameters that fail format validation are silently ignored; the backend always composes the Google search URL itself (arbitrary URLs are not accepted).
curl "https://www.myai168.com/en/api/google/search?q=Trump&hl=en&gl=us" \
-H "Authorization: Bearer YOUR_DEV_KEY"
import requests
r = requests.get(
"https://www.myai168.com/en/api/google/search",
headers={"Authorization": "Bearer YOUR_DEV_KEY"},
params={"q": "Trump", "hl": "en", "gl": "us"},
)
print(r.json())
Success returns HTTP 200 with a JSON object: the effective query parameters (q / hl / gl / lr / cr / tbm / tbs; unused ones are empty strings), url (the composed Google search URL), count (number of results), results (result array, each with title / link / snippet), cost (points charged) and credits (balance after the call); the response also carries X-Cost-Points (points charged) and X-Credits-Remaining (balance) headers.
{
"q": "Trump",
"hl": "en",
"gl": "us",
"url": "https://www.google.com/search?q=Trump&hl=en&gl=us",
"count": 10,
"results": [
{"title": "...", "link": "https://...", "snippet": "..."}
],
"cost": 66,
"credits": 12345
}
| HTTP status | Meaning |
|---|---|
401 | Missing or invalid API key (repeated failures from the same IP are temporarily blocked). |
402 | Insufficient credits (please top up). |
400 | Missing q parameter or invalid parameters. |
502 | Search temporarily failed — never charged. |