This tutorial shows how to query Google from Python and get clean, structured results — using serp.cheap, the cheapest Google Search API in 2026.
Install
pip install requests
export SERP_CHEAP_API_KEY="your-key"
The endpoint itself is one POST — here it is as curl, so you know what the Python code below is actually doing:
curl -s https://api.serp.cheap/v1/search \
-H "X-API-Key: $SERP_CHEAP_API_KEY" \
-H "Content-Type: application/json" \
-d '{"q": "best electric cars 2026", "gl": "us"}'
Minimal example
import os
import requests
API_KEY = os.environ["SERP_CHEAP_API_KEY"]
resp = requests.post(
"https://api.serp.cheap/v1/search",
headers={"X-API-Key": API_KEY},
json={"q": "best electric cars 2026", "gl": "us", "page": 1},
timeout=30,
)
resp.raise_for_status()
for r in resp.json()["organic"]:
print(f'#{r["position"]} {r["title"]} — {r["link"]}')
Output:
$ python search.py
#1 Best Electric Cars of 2026 — https://www.example.com/best-electric-cars-2026
#2 Electric Cars: Every EV You Can Buy in 2026 — https://www.example-autos.com/ev-buyers-guide
#3 Top-Rated EVs Compared — https://www.example-reviews.org/evs/top-rated
#4 Electric vehicle — Wikipedia — https://en.wikipedia.org/wiki/Electric_vehicle
#5 2026 EV Range and Price Comparison — https://www.example.com/ev-comparison
...
A reusable client with retries
import os
import requests
from requests.adapters import HTTPAdapter, Retry
class SerpClient:
def __init__(self, api_key: str):
self.s = requests.Session()
self.s.headers.update({"X-API-Key": api_key})
retries = Retry(total=4, backoff_factor=1.5,
status_forcelist=[429, 500, 502, 503, 504],
allowed_methods=["POST"]) # Retry skips POST by default
self.s.mount("https://", HTTPAdapter(max_retries=retries))
def search(self, q, gl="us", page=1, tbs=None):
body = {"q": q, "gl": gl, "page": page}
if tbs:
body["tbs"] = tbs
r = self.s.post("https://api.serp.cheap/v1/search", json=body, timeout=30)
r.raise_for_status()
return r.json()
client = SerpClient(os.environ["SERP_CHEAP_API_KEY"])
data = client.search("python web scraping", gl="us")
print(data["stats"]) # balance, cost, cached
Paginate
def all_results(client, q, pages=3, gl="us"):
"""Fetch up to `pages` pages and return one flat list of organic results."""
results = []
for p in range(1, pages + 1):
organic = client.search(q, gl=gl, page=p).get("organic", [])
if not organic:
break # no more results — stop paying for empty pages
results.extend(organic)
return results
top30 = all_results(client, "python web scraping", pages=3)
print(len(top30), "results")
Each page is a separate billed request — fetch lazily. More in pagination.
Cost control
stats.cost is in credits (1 = $0.0001). Cache hits cost 3 credits, fresh 6. Repeated queries are served from cache automatically at half price.
Next
- Build a rank tracker in Python
- Google Search API for AI agents
- Other languages: Node.js · Go · PHP
Try serp.cheap
Every snippet in this tutorial runs as-is once you export your API key. 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).