How to get Google search results in Node.js
Checked on 2026-11-24.
The official answer is Google's Custom Search JSON API, and its documentation now says it is closed to new customers and that existing customers have until January 1, 2027 to move. Here is what is left in Node.js: the official API if you already have it, what Google points to instead, why the npm packages that fetched google.com stopped, and an HTTP API that returns the organic results as JSON.
1. The Custom Search JSON API, if you already have it
Google's official API answers from a Programmable Search Engine that you create first, and its REST page names three required parameters: the API key (key), the search engine ID (cx) and the search (q). With fetch:
const url = new URL('https://www.googleapis.com/customsearch/v1');
url.searchParams.set('key', process.env.GOOGLE_API_KEY);
url.searchParams.set('cx', process.env.GOOGLE_SEARCH_ENGINE_ID); // your Programmable Search Engine
url.searchParams.set('q', 'best crm software');
const res = await fetch(url);
if (!res.ok) throw new Error(`Custom Search answered ${res.status}`);
const { items = [] } = await res.json();
for (const item of items) console.log(item.title, item.link, item.snippet);The googleapis package wraps the same request as customsearch('v1').cse.list(). Either way, num is at most 10 results per request, and the reference adds that "The JSON API will never return more than 100 results, even if more than 100 documents match the query." The prices on the overview: "100 search queries per day for free", then "$5 per 1000 queries, up to 10k queries per day".
Where it stops: for anyone new, before it starts. The overview page says: "The Custom Search JSON API is closed to new customers." And: "Existing Custom Search JSON API customers have until January 1, 2027 to transition to an alternative solution." If you depend on it, the Custom Search API alternative page maps its fields to another API, one by one, and lists what does not carry over.
2. What Google points to instead
- Vertex AI Search, which the same overview calls "a favorable alternative for searching up to 50 domains". That is search over sites you choose, not over the whole web.
- Full web search: for a use case that needs it, the overview asks you to contact Google.
- Grounding with Google Search in the Gemini API, which "connects the Gemini model to real-time web content". It is for AI applications: you get an answer written by the model, with the sources it cites.
Where it stops: none of the three hands you Google's ranked results for any search today.
3. npm packages that fetch google.com/search
Several npm packages were written to fetch Google's results page and parse it. Two of them show where that road ends:
google-sris deprecated on npm and its repository is archived. Its maintainer's notice explains that the package's way of fetching the results page no longer works, and the edit of 20 December 2025 says: "I’ve decided to permanently deprecate and archive this package. I don’t see a path forward where it would continue to work."googlethis: the description of its repository says "This project is no longer being maintained." Its latest version on npm, 1.8.0, came out on 18 September 2023.
Writing the same thing yourself meets three obstacles, all published by Google. google.com/robots.txt has Disallow: /search for all crawlers. Google's Terms of Service (effective July 30, 2026) list among the things you must not do "using automated means to access content from any of our services in violation of the machine-readable instructions" on its web pages, robots.txt files among them. And its help page says a network that "seems to be sending automated traffic to Google Search" may get the message "Our systems have detected unusual traffic from your computer network", most likely with a reCAPTCHA; "Search scrapers" are on its list of what counts.
Where it breaks: at that block, and at any change to the page's HTML, which is not a documented format. This guide does not cover getting around the block.
4. An HTTP API that returns the organic results
With Pipefetch a search is one GET request that returns the first page of results as JSON. A plain fetch call, from Node.js 18 or newer or a serverless function:
const url = new URL('https://pipefetch.com/v1/google/search');
url.searchParams.set('q', 'best crm software');
url.searchParams.set('country', 'US');
url.searchParams.set('lang', 'en');
const res = await fetch(url, {
headers: { 'x-api-key': process.env.PIPEFETCH_API_KEY },
signal: AbortSignal.timeout(90_000),
});
if (res.status === 404) {
console.log('Google has no results for this search'); // not charged
} else if (res.status === 502) {
console.log('Google refused this search, send it again'); // not charged
} else if (!res.ok) {
throw new Error(`Pipefetch answered ${res.status}`);
} else {
const { data } = await res.json();
for (const result of data.results) console.log(result.position, result.title, result.url);
for (const related of data.relatedSearches) console.log('related:', related.query);
}The npm client, pipefetch, reaches it through get(), which takes the path of any endpoint. It sends a search Google refused again by itself, twice, with a growing pause:
// npm install pipefetch
import Pipefetch, { NotFoundError } from 'pipefetch';
const pf = new Pipefetch(); // reads PIPEFETCH_API_KEY
try {
const { results } = await pf.get('/v1/google/search', { q: 'site:nodejs.org fetch', country: 'GB' });
for (const r of results) console.log(r.position, r.domain, r.description);
} catch (error) {
if (error instanceof NotFoundError) console.log('No results'); // not charged
else throw error;
}Each result has its position, title, url, displayedUrl, domain, description (the snippet) and, when Google shows one, a date. Google's operators, such as site: and intitle:, work in q. country and lang choose whose Google you get; without a country it is the United States. The reference lists every field.
Where it stops:
- One request is the first page: about 10 organic results. There are no further pages.
- It reads the light results page Google serves to clients without JavaScript, not the full page a desktop browser gets. Ads, AI Overview, People also ask, the featured snippet, the places block, top stories, the knowledge panel, videos and images are not included.
- Results are for a country, not for a city, and for a visitor who is not signed in.
- Google sometimes refuses a search. The request then answers 502
upstream_error, costs nothing and can be sent again. - It is not an official Google API, and Pipefetch is not affiliated with Google. The reading happens on Pipefetch's servers instead of yours, but it is still automated reading of a Google results page, which is what the policies quoted above are about. If you need a route Google itself supports, it is one of the first two.
A request costs 1 credit. A search without results (404) and a refused one (502) cost nothing. A new account has 100 free credits and needs no card, and most requests take 2 to 9 seconds.
Which one should you use?
| Situation | Use |
|---|---|
| You already call the Custom Search JSON API | Keep it until January 1, 2027, and plan the move now |
| Search over your own site or a set of domains | Vertex AI Search, as Google's notice suggests |
| An AI application that needs answers with sources | Grounding with Google Search in the Gemini API |
| The organic results of a search as JSON, today | An HTTP API such as Pipefetch, knowing what it leaves out |
Call it from the server, not the page
Every route here needs a key. Make the call in server code, an API route or a serverless function, and send only the results to the page: a key in browser code can be read and spent by anyone. For the same task in Python, see Google search results in Python.
Try it with 100 free credits. No card needed. No scraper to build or maintain. Get an API key or read the docs.
APIs used in this guide
More Google guides
- How to get Google search results in Python
- pytrends 429 TooManyRequestsError: what it means and what to do
- How to get Google Trends data in Python
- Why is Wyoming first in Google Trends?
- How to get Google search results into Google Sheets
- How to give an LLM live Google results with tool calling
Guides for other sources
Every source
YouTube
- How to get a YouTube transcript in Python
- How to get a YouTube transcript in Node.js
- YouTube API quota exceeded: what the error means and how to fix it
- How to find a YouTube channel ID from a handle or URL
- How to download YouTube subtitles as SRT or VTT
- youtube-transcript-api RequestBlocked or IpBlocked: why it happens and how to fix it
- How to get YouTube comments in Python
- How to search YouTube from Python
- How to list a YouTube channel's videos in Python
- How to summarize a YouTube video with an LLM in Python
- How to get YouTube transcripts and video stats in Google Sheets
- How to get YouTube video views and likes in Python
- How to get YouTube transcripts in n8n, Make and Zapier
- LangChain YoutubeLoader fails on a server: why, and a loader that works
- How to get a YouTube channel's subscriber count in Python
- How to give Claude or Cursor access to YouTube (MCP server)
- How to get YouTube comments in Node.js
- How to analyze YouTube comments with an LLM in Python
- How to list a YouTube channel's Shorts in Python
- How to search YouTube from JavaScript
- How to get an Instagram follower count in Python
- Instagram Basic Display API alternatives: what to use after the shutdown
- Instaloader 401 Unauthorized, 429 and "Login required": what to do
- How to calculate an Instagram engagement rate in Python
- How to get an Instagram follower count in Node.js
- How to get Instagram follower counts in Google Sheets
- How to get Instagram Reel views in Python
Websites
- Clearbit Logo API alternatives: get a company logo from its domain
- How to extract email addresses from a website in Python
- How to turn a web page into Markdown in Python
- How to detect what a website is built with, in Python
- How to get the contact emails and phone numbers of websites in Google Sheets
- How to build a LangChain tool that reads web pages and searches Google
- How to turn a web page into Markdown in JavaScript for RAG
- How to extract social media links from a website in Python
- How to get a website's favicon in Python
- How to check robots.txt in Python before you fetch a page
TikTok
- How to get a TikTok video's views and likes in Python
- How to get the comments of a TikTok video in Python
- How to get a TikTok follower count in Python
- TikTok Research API: who can get access, and what to do if you cannot
- How to get TikTok video views, likes and shares in Node.js
- How to get TikTok views, likes and follower counts in Google Sheets
- How to get a Facebook Page's posts without app review
- Is there a Facebook Marketplace API?
- Facebook Groups API alternatives after its removal in 2024
- How to get a Facebook Page's follower count and contact details in Python
Threads
- How to get LinkedIn company data in Python
- How to search LinkedIn jobs from Python
- How to get a LinkedIn company page's latest posts in Python