Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The supported way to retrieve Google results as JSON is the Custom Search JSON API. Send an HTTPS GET request to https://www.googleapis.com/customsearch/v1 with an API key (key), a Programmable Search Engine ID (cx) and a URL-encoded query (q). The important limitation in 2026 is availability: Google says the Custom Search JSON API is closed to new customers, and existing customers must transition by January 1, 2027. If you already have access, the implementation below is runnable; if you are starting a new project, evaluate Vertex AI Search or a commercial SERP provider before designing around this API.

What Google’s search API actually returns

This API is not a browser scraper for google.com. It queries a configured Programmable Search Engine and returns web or image results in JSON. Your engine can be limited to selected sites or configured for a broader supported web scope. The response normally includes query metadata, timing information and an items array. Each item can contain a result title, URL and snippet, along with additional fields for some result types.

That distinction matters. A Programmable Search Engine response is not guaranteed to reproduce every live Google Search page, feature box, local result or personalization signal. If your requirement is exact, real-time SERP replication, compare a commercial SERP API separately and verify its current coverage, price and terms.

Availability, limits and cost

Situation What the documented Google program means
Existing Custom Search JSON API customer Documented legacy allowance is 100 free queries per day, then $5 per 1,000 additional requests, with a 10,000-query-per-day cap.
New project Google’s current overview says the Custom Search JSON API is closed to new customers. Assess Vertex AI Search or a commercial SERP provider instead.
Transition deadline Existing customers have until January 1, 2027 to move to an alternative solution.

These figures describe Google’s documented legacy program and can change. Recheck the current Google overview before putting a price in a proposal or committing to a production volume. Track requests yourself so a retry loop cannot silently exhaust a daily limit.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prerequisites: an API key and a cx engine ID

1. Configure the Programmable Search Engine

Open the Programmable Search control panel, create or select an engine, and define the sites or web scope it should search. Record the engine identifier shown as cx. The API reference treats cx as a required parameter; it is not interchangeable with a project ID or an API-key value.

2. Create an API key

Create credentials in Google Cloud, enable the Custom Search API for the relevant project, and restrict the key where practical (for example, to your server, expected APIs and network origins). Keep the key on a server or in a secret manager. Do not place it in browser JavaScript, a public repository or a URL that you expose to untrusted users.

3. Confirm the deployment’s terms

Use of the API requires acceptance of Google’s API, Programmable Search Engine and additional Custom Search terms. If your application displays results, follow Google’s attribution and branding placement rules: the required attribution must be adjacent to the relevant search box or result presentation. Have counsel review data retention, user-location and jurisdiction questions for your deployment.

The request: required parameters and encoding

The request is an HTTPS GET to https://www.googleapis.com/customsearch/v1. At minimum, provide:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • key: your Google API key.
  • cx: the Programmable Search Engine identifier.
  • q: the search text, URL-encoded.

Google’s REST guide documents a 2,048-character request-length limit. Let your HTTP client encode the query rather than concatenating raw spaces, ampersands or non-ASCII characters into the URL.

GET https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=SEARCH_ENGINE_ID&q=how+to+scrape+google+search+results

For production code, pass parameters through your client library. That avoids malformed queries and keeps secrets out of logs where your logging system records complete URLs.

Complete examples

cURL

curl -G "https://www.googleapis.com/customsearch/v1" 
  --data-urlencode "key=$GOOGLE_API_KEY" 
  --data-urlencode "cx=$SEARCH_ENGINE_ID" 
  --data-urlencode "q=how to scrape google search results"

Use environment variables in a shell or CI secret store. Add -sS for quiet output with errors, and save the JSON with -o results.json when a later process will parse it.

Python

import os
import requests

endpoint = "https://www.googleapis.com/customsearch/v1"
params = {
    "key": os.environ["GOOGLE_API_KEY"],
    "cx": os.environ["SEARCH_ENGINE_ID"],
    "q": "how to scrape google search results",
}

response = requests.get(endpoint, params=params, timeout=30)
response.raise_for_status()
data = response.json()

for item in data.get("items", []):
    print(item.get("title"), item.get("link"))

# Useful operational metadata
print(data.get("queries", {}))
print(data.get("searchInformation", {}))

raise_for_status() turns HTTP failures into exceptions, while get("items", []) correctly handles a valid response with no results.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Node.js (18 or newer)

const endpoint = "https://www.googleapis.com/customsearch/v1";
const params = new URLSearchParams({
  key: process.env.GOOGLE_API_KEY,
  cx: process.env.SEARCH_ENGINE_ID,
  q: "how to scrape google search results"
});

const response = await fetch(`${endpoint}?${params}`);
const data = await response.json();
if (!response.ok) {
  throw new Error(`Google API ${response.status}: ${JSON.stringify(data)}`);
}

for (const item of (data.items ?? [])) {
  console.log(item.title, item.link);
}
console.log(data.queries, data.searchInformation);

Parsing results without brittle assumptions

Handle zero results as a normal outcome

Do not assume items exists. A query can legitimately return no result items, and an error response has a different shape. Check the HTTP status first, then iterate over items only when it is an array.

Use metadata for pagination and auditing

Inspect the queries object for the request and any next-page information rather than inventing offsets. Log the query, timestamp, engine ID, HTTP status and a request identifier if Google supplies one. searchInformation can contain result-count and formatted-time metadata useful for diagnostics, but it is not a promise of a fixed ranking or count.

Store only the fields you need

A practical normalized record is {title, link, snippet}, plus the query and retrieval time. Treat snippets as display text, not canonical page content: they can change, contain markup in some response variants, or be absent. Escape titles and snippets before inserting them into HTML, and validate links before making them clickable.

Pagination, batching and reliability

Pagination

Follow the pagination links or metadata returned by Google and stop when no next request is advertised. Respect the API’s documented limits and your daily allowance. A crawler that requests every page for every keyword can hit the cap quickly; cache identical queries and set a maximum page count per job.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Retries

Retry transient network failures and eligible 5xx responses with exponential backoff and jitter. Do not blindly retry authentication, invalid-parameter or quota errors. Give each job a deadline, and make retries idempotent by recording the query and page you already processed.

Caching and monitoring

  • Cache responses for a period appropriate to your product and Google’s terms.
  • Track request totals, status classes, latency, empty-result rate and quota responses.
  • Alert before the daily cap, not after users begin seeing failures.
  • Version your parser so a newly absent field does not break the entire pipeline.

Common errors and fixes

Symptom Likely cause Fix
HTTP 400 with an invalid request message Missing key, cx or q, malformed encoding, or an overlong URL. Pass all required parameters through a URL-encoding library and keep the request under Google’s 2,048-character limit.
HTTP 401/403 or key-related error Wrong key, disabled API, restrictive key policy or unauthorized project. Check the project, enable the API, verify restrictions and keep the key server-side.
Quota or rate-limit response Daily allowance exhausted or too many requests in a short period. Stop retries, inspect usage, add caching/backoff and verify the account’s documented limit.
200 response but no items No matching results or a response variant without item records. Treat it as an empty result set and inspect queries and searchInformation.
Results differ from google.com Your engine scope, configuration, location, personalization and the public Google page are different products. Verify the engine’s site/web scope and choose a SERP provider if live-page fidelity is a hard requirement.
Displayed results violate branding expectations Required attribution was omitted or placed away from the search UI. Review Google’s Programmable Search branding guidance and place attribution adjacent to the box or results.

API retrieval versus direct browser scraping

Automating a browser against google.com result pages is a separate compliance and engineering question. It introduces bot checks, changing HTML, consent dialogs, localization and heavier resource usage. The supported product described here returns structured data from a configured search engine. Google’s help and terms do not provide a single jurisdiction-independent legal answer for every form of direct HTML scraping, so obtain current legal advice for your location, users and data-retention design.

Choosing an approach for a new project

Path Best fit Main trade-off
Custom Search JSON API An existing enrolled customer needing JSON from a configured Programmable Search Engine. Closed to new customers and subject to legacy limits and a January 1, 2027 transition deadline.
Vertex AI Search A new Google project willing to assess Google’s named alternative. Different product and integration model; confirm capabilities and pricing for your use case.
Commercial SERP API Teams that need live Google SERP-oriented data and managed infrastructure. Features, pricing, retention and terms vary by vendor and must be verified individually.
Direct browser automation A controlled internal workflow where you explicitly accept browser and compliance overhead. Fragile selectors, bot defenses, consent UI, high resource cost and greater maintenance.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your actual task is making clean visual captures of result pages or other URLs—not extracting structured Google result data—ScreenshotNeo provides a website screenshot API and MCP server. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP tools—take_screenshot, get_page_info and capture_pdf—work with Claude, Cursor and other MCP clients.

One GET request returns PNG, JPEG, WebP or PDF. The API supports full-page and CSS-element captures, lazy-image loading, device presets, dark mode, retina scale, custom CSS and JavaScript, clicks, waits, blocking rules, headers, cookies, user agents, authorization, timezone, geolocation, transparency, resizing, chosen-TTL caching, signed links, asynchronous webhooks and bulk capture of up to 100 URLs per call. Every feature is on every plan: 1,000 screenshots per month are free with no card; paid plans start at $5 for 3,000. See the ScreenshotNeo documentation for parameters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Create a free ScreenshotNeo account to try the 1,000 monthly screenshots without a card.

Implementation checklist

  • Confirm whether your account is an existing Custom Search customer.
  • Configure and record the correct cx engine ID.
  • Restrict and protect the API key.
  • URL-encode every query and enforce the 2,048-character request limit.
  • Handle missing items, pagination metadata and non-2xx errors.
  • Add bounded retries, caching, quota monitoring and parser tests.
  • Apply attribution rules when displaying results.
  • Reassess the migration path before January 1, 2027.

Frequently Asked Questions

Is there an official Google SERP API for new developers?

Google’s supported Custom Search JSON API is closed to new customers. Existing customers can use the documented service while planning the required transition; new projects should assess Vertex AI Search or commercial SERP providers.

What does cx mean?

cx is the identifier of your Programmable Search Engine. It tells the API which configured site collection or supported web scope to query.

Can I put the API key in frontend JavaScript?

Avoid it. Browser-visible keys can be copied and abused. Make requests on your server or use a secret-management design that matches Google’s current guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why are my API results not identical to Google Search?

The API queries a configured Programmable Search Engine, while google.com may apply different scope, ranking, location, personalization and SERP features.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.