← Back to blog

How to Use a Google Search API in 2026: Complete Guide

Learn to use a Google Search API end to end — auth, parameters, pagination and cost control from $0.0003/search, with Python, Node.js and curl code.

2 min read

This is the practical, end-to-end guide to using a Google Search API: authenticate, send a query, read the JSON, paginate, handle errors, and keep costs down. Examples use serp.cheap (the cheapest option in 2026), but the concepts apply to any SERP API.

1. Get an API key

Sign up at app.serp.cheap for 100 free searches (no card), then pass your key in the X-API-Key header. You can also subscribe via Apify or RapidAPI if you prefer marketplace billing.

2. The endpoint in one line

POST https://api.serp.cheap/v1/search
ParameterDefaultDescription
qrequiredThe search query
gl"us"Country (e.g. br, gb, de)
hlcountry defaultUI language override
page1Results page (1-indexed)
tbsnoneTime filter: qdr:h, qdr:d, qdr:w

Full reference: Google Search API parameters.

3. Your first request

curl https://api.serp.cheap/v1/search \
  -H "X-API-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"q": "best electric cars 2026", "gl": "us", "page": 1}'
import requests

r = requests.post(
    "https://api.serp.cheap/v1/search",
    headers={"X-API-Key": "YOUR_KEY"},
    json={"q": "best electric cars 2026", "gl": "us", "page": 1},
)
r.raise_for_status()
data = r.json()
for item in data["organic"]:
    print(item["position"], item["title"], item["link"])

Language-specific guides: Python · Node.js · PHP · Go · curl.

4. Read the response

{
  "search": "best electric cars 2026",
  "page": 1,
  "organic": [
    {
      "position": 1,
      "title": "Best Electric Cars of 2026",
      "link": "https://example.com/best-evs",
      "snippet": "We tested every major EV...",
      "date": "Jan 10, 2026"
    }
  ],
  "stats": { "balance": 99994, "cost": 6, "cached": false }
}

stats.cost is in credits (1 credit = $0.0001). A fresh fetch is 6 credits ($0.0006); a cache hit is 3 ($0.0003). stats.cached tells you which path you got.

5. Pagination

Each page is a separate request — increment page. Only fetch page 2+ when a user actually needs it. See getting 100 results.

6. Error handling

  • 401 — bad/missing API key.
  • 402 — out of credits; top up.
  • 429 — rate limited (free tier 60 req/min = 1 req/s; pay-as-you-go 600/min = 10 req/s, up to 60 req/s on top plans); back off and retry.
  • 5xx — transient; retry with exponential backoff.

Always wrap calls in a retry with backoff for 429/5xx.

7. Keep it cheap

  1. Cache hits are half price — don’t force fresh fetches for repeated queries.
  2. Paginate lazily.
  3. Pick gl precisely to avoid re-runs.

Next steps

Try serp.cheap

Run the requests from this guide against the live endpoint in a couple of minutes. 100 free searches on signup — no card required; pay-as-you-go from $0.75/1k after that, and credits stay valid for 12 months.

Frequently asked questions

How do I call a Google Search API?+

Send an authenticated POST request with your query. With serp.cheap: POST https://api.serp.cheap/v1/search, header X-API-Key, JSON body like {"q": "...", "gl": "us"}. The response is JSON with an organic[] array of results.

Can I call a Google Search API from the browser?+

No — never expose your API key in client-side code. Always proxy requests through your own backend so the key stays secret.

How do I keep Google Search API costs low?+

Lean on caching (repeat queries are served at half price on serp.cheap), only fetch additional pages when needed, and track stats.cost per call.

Get your API key

Cheapest direct, pay by card or crypto, no KYC. Or use a marketplace.