48 of 51 hard targets returned a real page in production. Read the run

Blog / Search

What a SERP API Is, and How to Choose One

A SERP API returns Google's results as structured JSON instead of HTML you have to parse. Here is what one actually does, what breaks without it, and how to pick.

Scrapengine Team//7 min read

A SERP API takes a search query, runs it against a search engine the way a real browser would, and hands you back the results as structured JSON — ranked organic results, ads, People Also Ask, local packs, knowledge panels — instead of a page of HTML you have to parse yourself.

That sounds like a thin wrapper. It isn't, and the reason is worth understanding before you pick one.

Why you cannot just fetch google.com

The obvious implementation is two lines:

Python
import requests
html = requests.get("https://www.google.com/search?q=serp+api").text

This works exactly once, from your laptop, while you are watching it. In production it fails in four distinct ways, and each one fails differently:

  1. You get a consent interstitial instead of results. Google serves a cookie wall before results in most regions. Your parser sees a page, finds no results, and reports "0 results found" rather than an error.
  2. You get a soft block. A 429, a redirect to /sorry/index, or a CAPTCHA page — often returned with HTTP 200, so naive code treats the block page as a successful empty result.
  3. The layout changes. Google ships SERP markup changes constantly. Class names are obfuscated and rotate. A CSS selector that worked in March returns nothing in April, silently.
  4. Results are personalised. Without pinned location, language and device, two identical queries return different rankings, which makes your data non-reproducible — fatal if you are tracking positions over time.

Points 1 and 2 are the expensive ones. A scraper that returns an empty list on a block looks healthy on every dashboard you have. You find out weeks later when someone asks why a competitor disappeared from your rank tracker.

Watch out

The failure mode that costs the most money is not the request that errors. It is the request that returns 200 OK with a block page in the body. Whatever you build, make it distinguish "served" from "refused" explicitly.

What a SERP API gives you

A SERP API moves four concerns off your side of the line:

Exit addresses. Requests leave from addresses that look like ordinary users, rotated so that your volume does not concentrate on one IP. This is the part people underestimate — in our own audit of production failures, the exit address, not the browser fingerprint, was the cause in the large majority of cases.

Consent and interstitial handling. The cookie wall, the regional redirect, the "did you mean" bounce — all resolved before you see a response.

Parsing. Google's markup becomes a stable schema. When Google reshuffles their DOM, the provider's parser changes; your code does not.

Pinned context. Location, language, device and domain are explicit request parameters, so the same query returns comparable results tomorrow.

With ScrapEngine that is a single GET:

Shell
curl -X GET "https://api.scrapengine.io/api/v1/google/search?q=best%20coffee%20shops&gl=us&num=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

Pin the context explicitly when you are tracking rankings rather than exploring:

Shell
curl -X GET "https://api.scrapengine.io/api/v1/google/search?q=restaurants&location=New%20York%2C%20USA&device=mobile" \
  -H "Authorization: Bearer YOUR_API_KEY"

The parameters that matter most for reproducibility are gl (country), hl (interface language), location (the geographic point results are served from), device (desktop or mobile) and googleDomain. Set them on every call. A rank you cannot reproduce is not a rank, it is an anecdote.

For large jobs, pass async=true and collect the result by job ID rather than holding a connection open:

JavaScript
const params = new URLSearchParams({ q: "serp api", gl: "us", num: "10" });
 
const response = await fetch(
  `https://api.scrapengine.io/api/v1/google/search?${params}`,
  { headers: { Authorization: "Bearer YOUR_API_KEY" } }
);
 
const data = await response.json();

How to choose one

Most SERP APIs describe themselves identically. These five questions separate them:

1. What happens on a block?

Ask for the exact response shape when the engine refuses. A provider that returns an empty results array on a block is pushing a silent-failure bug into your codebase. You want a distinct, machine-readable refusal — and you want to know whether you are billed for it. We are not: a wall we could not get through is not a result, so it is not charged.

2. Can you pin location to a real place?

"Country" is not enough for local intent. If you cannot specify a city, the local pack you get back is not the one your customer sees.

3. What is the latency distribution, not the average?

Averages hide the retries. Ask for p50 and p95. Across our own 59-site benchmark corpus the median response is 4.1 seconds; a provider that quotes only "fast" is quoting nothing.

4. Is the schema versioned?

If the provider reshapes their JSON when Google reshapes their DOM, your pipeline breaks anyway and you have bought nothing.

5. Does it cover more than organic results?

Ads, People Also Ask, local packs, shopping, images, news. tbm selects the vertical. If you only need ten blue links today, you will need the rest within a quarter.

When you need a scraper instead

A SERP API answers "what does the engine return for this query". It does not fetch the pages behind those results. If your workflow is search, then read the top results, you need both — the search endpoint for the ranking, and a general scraping endpoint for the destination pages:

Shell
curl -X POST "https://api.scrapengine.io/api/v1/scrape" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/the-ranked-page",
    "render": true,
    "format": "markdown"
  }'

format: "markdown" is the one to use when the consumer is a language model — it strips navigation, scripts and styling down to the prose. We wrote about that pipeline in HTML to Markdown.

Start here

Pull one query, inspect the shape, then decide:

Shell
curl -X GET "https://api.scrapengine.io/api/v1/google/search?q=your%20query&gl=us&num=10" \
  -H "Authorization: Bearer YOUR_API_KEY"

Full parameter reference is at docs.scrapengine.io, and you can get a key from dashboard.scrapengine.io.

FAQ

Frequently asked questions

A SERP API runs a query against a search engine from a real browser context and returns the results page as structured JSON — organic results, ads, People Also Ask, local packs — rather than raw HTML you have to parse yourself.

Keep reading

The pages you need are already refusing you

Start with a thousand pages. No proxy pool to rent, no browser fleet to run, and nothing billed for a wall we could not get through.