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
| Parameter | Default | Description |
|---|---|---|
q | required | The search query |
gl | "us" | Country (e.g. br, gb, de) |
hl | country default | UI language override |
page | 1 | Results page (1-indexed) |
tbs | none | Time 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
- Cache hits are half price — don’t force fresh fetches for repeated queries.
- Paginate lazily.
- Pick
glprecisely to avoid re-runs.
Next steps
- Build something real: a Python rank tracker or Google Search for AI agents.
- Compare providers: cheapest SERP API 2026.
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.
- Get your free API key →
- Prefer paying by card? serp.cheap is also on RapidAPI (
$0.90/1k) and Apify ($1.50/1k).