Home›Developer Center›Google Search API

Google Search API

API DocumentationOpenAI ChatGPT APIAnthropic (Claude) APIGoogle Gemini APIGoogle Search APIGoogle News APIOpenRouter APIAPI Pricing
CLI & Agent Guidescc-switch macOScc-switch Windowscc-switch LinuxOpenCode macOSOpenCode WindowsOpenCode LinuxOpenClaw macOSOpenClaw WindowsOpenClaw LinuxHermes Agent macOSHermes Agent WindowsHermes Agent LinuxClaude Code CLI macOSClaude Code CLI WindowsClaude Code CLI LinuxCodex CLI macOSCodex CLI WindowsCodex CLI Linux
MYAI168 API & MCPMYAI168 MCP CLIMYAI168 MCP Web & App
No matching questions on this page.Search the whole site
Google Search

Google Search API

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/search

Google web search, returns up to 20 results (each with title / link / snippet).

ParameterRequiredDescription
qRequiredSearch keywords (string).
hlOptionalUI language, e.g. en / zh-TW.
glOptionalRegion, e.g. us / tw.
lrOptionalResult language restriction, format lang_xx (e.g. lang_en); join multiple with |.
crOptionalSource country restriction, format countryXX (e.g. countryUS); join multiple with |.
tbmOptionalSearch type: nws news / isch images / vid videos / bks books / shop shopping.
tbsOptionalFilters 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())

Response format

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
}

Error codes

HTTP statusMeaning
401Missing or invalid API key (repeated failures from the same IP are temporarily blocked).
402Insufficient credits (please top up).
400Missing q parameter or invalid parameters.
502Search temporarily failed — never charged.
‹ Previous page: Google Gemini APINext page: Google News API ›
↑
Question link copied.

Other FAQ pages

API Documentation

  • OpenAI ChatGPT API
  • Anthropic (Claude) API
  • Google Gemini API
  • Google News API
  • OpenRouter API
  • API Pricing

CLI & Agent Guides

  • cc-switch macOS
  • cc-switch Windows
  • cc-switch Linux
  • OpenCode macOS
  • OpenCode Windows
  • OpenCode Linux
  • OpenClaw macOS
  • OpenClaw Windows
  • OpenClaw Linux
  • Hermes Agent macOS
  • Hermes Agent Windows
  • Hermes Agent Linux
  • Claude Code CLI macOS
  • Claude Code CLI Windows
  • Claude Code CLI Linux
  • Codex CLI macOS
  • Codex CLI Windows
  • Codex CLI Linux

MYAI168 API & MCP

  • MYAI168 MCP CLI
  • MYAI168 MCP Web & App