Get Google Organic Search Results Instantly with Google Light Fast API
Introduction
If you’re a marketer who wants to monitor keyword rankings for your business, or a developer wanting to pull the latest headlines for your news application, you know how much of a pain this can be. Most online tools are costly, bloated and can’t be customized to your problem. Today, we’ll use SerpApi’s Google Light Fast API to easily and quickly scrape Google search results. We’re going to retrieve the data programmatically, exactly as it appears on Google’s own search results page.
In this tutorial, we’ll write a simple server-side script that checks how a URL ranks for specific keywords on Google. With SerpApi, you don’t have to worry about the usual web scraping headaches, like updating your code for layout changes, dealing with IP blocks, or fighting CAPTCHAs. Instead, you can focus on building your app. Before we start, make sure you’ve signed up for a free account on SerpApi.
Prerequisites and Project Setup
This tutorial assumes you have a basic understanding of JavaScript, Node, and npm. If not, no worries. We also have a no-code solution that can be found here. Alternatively, you can always come back to this post once you gain familiarity with basic JavaScript and Node. Feel free to jump directly to integrating with SerpApi if you already have a basic Node skeleton project set up.
To set up a brand new project, create a new folder, navigate to that folder in your terminal and run the following commands:
npm init -y
We need to install a few dependencies: dotenv
to access environment variables, and serpapi
for the public JavaScript library.
npm i serpapi dotenv
Next, create an index.js
file in your root directory. We also need to store and access the API key that comes with the free SerpApi account. There are several different ways to do this, but for this tutorial let’s create an .env
file and store the key there.
API_KEY=your_key_here
Of course, we’ll need to import the libraries we’ve installed at the top of our file before using them:
import dotenv from "dotenv";
import { getJson } from "serpapi";
dotenv.config();
const apiKey = process.env.API_KEY;
Since we’ll be using ES6 modules in this tutorial, don’t forget to include “type”: "module"
in your package.json
.
"type": "module"
Scraping with JavaScript
Let’s imagine you own Starbucks, and you want to check your ranking for a list of popular coffee-related keywords. We’ll need to put those keywords we want to target into an array. We’ll also define the domain we want to be looking for as “starbucks.com”.
const keywords = [
"coffee",
"iced coffee",
"oat latte",
"best coffee",
"americano",
"latte",
"matcha",
"pumpkin spice latte",
"oat milk latte",
];
const domain = "www.starbucks.com"
All we need to do is call getJson
from the serpapi
library. Note that getJson is an asynchronous function with callback and async/await
support. Before calling an array of keywords, let’s try out the API with the first keyword in our array.
const data = await getJson({
api_key: apiKey, //required
engine: "google_light_fast",//required
google_domain: "google.com",
q: keywords[0],//required
hl: "en",
gl: "us",
});
console.log(data)
The only required parameters for the Google Light Fast API are api_key
, engine
, and q
. For a full list of supported parameters, take a look at our documentation. Also, if you’d like to experiment more with this API, don’t forget to check out our public playground.
Now let's run this!
In your terminal, navigate to the root of this project and run:
node index.js
If everything went well, you should have received a response in your console within a second. The JSON response should resemble something like this:
{
"search_metadata": {
"id": "68d437484c437fdcf83f1897",
"status": "Success",
"json_endpoint": "https://serpapi.com/searches/967ec5090d430149/68d437484c437fdcf83f1897.json",
"created_at": "2025-09-24 18:24:08 UTC",
"processed_at": "2025-09-24 18:24:08 UTC",
"google_light_fast_url": "https://www.google.com/search?q=Coffee&hl=en&gl=us&sourceid=chrome&ie=UTF-8",
"raw_html_file": "https://serpapi.com/searches/967ec5090d430149/68d437484c437fdcf83f1897.html",
"total_time_taken": 0.97
},
"search_parameters": {
"engine": "google_light_fast",
"q": "Coffee",
"google_domain": "google.com",
"hl": "en",
"gl": "us"
},
"search_information": {
"organic_results_state": "Results for exact spelling"
},
"organic_results": [
{
"position": 1,
"title": "Coffee - Wikipedia",
"link": "https://en.wikipedia.org/wiki/Coffee",
"displayed_link": "https://en.wikipedia.org › wiki › Coffee",
"favicon": "https://encrypted-tbn1.gstatic.com/favicon-tbn?q=tbn%3AANd9GcSVMU85vzsP5RTNub9IaAsl7rV0Nyf_xTINCBJZ1nlvBnxTDgf0HU9xmmPaba08IkD_mWLlL8LDthkMoG4tsyqVPp6VYs98tC-e5-E",
"snippet": "Coffee is a beverage brewed from roasted, ground coffee beans. Darkly colored, bitter, and slightly acidic, coffee has a stimulating effect on humans"
},
{
"position": 2,
"title": "Starbucks Coffee Company",
"link": "https://www.starbucks.com/",
"displayed_link": "https://www.starbucks.com",
"favicon": "https://encrypted-tbn3.gstatic.com/favicon-tbn?q=tbn%3AANd9GcRdvxQfPWiafCxH9HD0XtJerZ5FY7ctOVpxK4U9EldMD3SkXwh5oKlsGSS8A_GBPbNYj4_pdsmKya0-XXSG6XkkpircValazFMJsz9o",
"snippet": "More than just great coffee. Explore the menu, sign up for Starbucks® Rewards, manage your gift card and more."
},
{
"position": 3,
"title": "Wonderstate Coffee: Sustainable Coffee Roasters | Specialty ...",
"link": "https://wonderstate.com/?srsltid=AfmBOopAdGD571-IHoJTulurDRLUKETcgkzQfHKQNZPsH8Qq8eDsXRbw",
"displayed_link": "https://wonderstate.com",
"favicon": "https://encrypted-tbn1.gstatic.com/favicon-tbn?q=tbn%3AANd9GcRkkAe_Nr9r_KGO8rsBxg32ryD4lN3GUn5mZd4nByuqHpZ5QJQ1gyWDmiLC58xylF0G8jT5n_xxHic0KO6aCNAIe3UrOAZVr79s_w",
"snippet": "Award-winning, organic coffee roasters in Wisconsin. 100% solar powered. Paying farmers more with a minimum price guarantee that's double the Fair Trade ..."
},
{
"position": 4,
"title": "r/Coffee - Reddit",
"link": "https://www.reddit.com/r/Coffee/",
"displayed_link": "https://www.reddit.com › Coffee",
"favicon": "https://encrypted-tbn2.gstatic.com/favicon-tbn?q=tbn%3AANd9GcRt_ioW2I2eFmqJJLAWQSl7Fa22pXg9CBflQgcrSYXdMzIwWTa8eHdeZ7OKCeCySe9gqu2bcJ6_Fb4ZlTRQWnx9d5z3ide5sGU7",
"snippet": "Welcome to the daily · /r/Coffee. question thread! There are no stupid questions here, ask a question and get an answer! We all have to start somewhere and ..."
},
{
"position": 5,
"title": "Blue Bottle Coffee | Fresh Roasted Specialty Coffee",
"link": "https://bluebottlecoffee.com/?srsltid=AfmBOopxMGf5ASuuIzlP2zEnsmxVUaUpcVIL_Omb2XXZHLoMZIkDNYdf",
"displayed_link": "https://bluebottlecoffee.com",
"favicon": "https://encrypted-tbn3.gstatic.com/favicon-tbn?q=tbn%3AANd9GcQrS-d7qjN2SDnT3GkjE7o8RH7JrmSdLttp1UvAcoXpDs02e0_3g--k76_K93BYNdQb3qy6wIyxKfH1OSN6lW7q5kLmD77Q9DCuSs4Hnw7y",
"snippet": "Blue Bottle Coffee is a specialty coffee roaster with cafes in LA, SF, NYC, & Japan. Shop our freshly roasted specialty coffee online & in-store."
},
{
"position": 6,
"title": "All Coffee - Verve Coffee Roasters",
"link": "https://www.vervecoffee.com/collections/all-coffee?srsltid=AfmBOoqWVxbvNcxCo2cb5WPdO_8jZV2YDfbdabwn9OkQnbOQL3sw6hTo",
"displayed_link": "https://www.vervecoffee.com › collections › all-...",
"favicon": "https://encrypted-tbn0.gstatic.com/favicon-tbn?q=tbn%3AANd9GcQzMum2G8lsDS0YSPwMugOHqS0y9zN2MOXtp-QvDxJCqt9YeGdiZxUqkXmm0ta4_uG17l8u-HeDmVGkS0r2UksQOBS8Dt_9VLkqua0UNnk",
"snippet": "Verve Coffee Roasters - Sermon - So easy to wake up to - Sweet, deep, & soulful - Medium Roast blend - Notes: Blueberry Pie, Cocoa, Candied Pecan"
},
{
"position": 7,
"title": "Buy Coffee, Tea, Powders Online | The Coffee Bean & Tea ...",
"link": "https://www.coffeebean.com/",
"displayed_link": "https://www.coffeebean.com",
"favicon": "https://encrypted-tbn3.gstatic.com/favicon-tbn?q=tbn%3AANd9GcRc9wUBGZNChw_o9jALpdvp8DpUvmKJZBHoi6SjSbIAMxC3dKUta8lOmLQ93yAlgjciko0OlyYYnqxxYe3-er5G0jEMEGv8zpbOXPaZkA",
"snippet": "Buy exceptional coffee, tea, powders, equipment and drinkware at The Coffee Bean & Tea Leaf® online store to enjoy our globally sourced products at home."
},
{
"position": 8,
"title": "Coffee - The Nutrition Source",
"link": "https://nutritionsource.hsph.harvard.edu/food-features/coffee/",
"displayed_link": "https://nutritionsource.hsph.harvard.edu › coffee",
"favicon": "https://encrypted-tbn3.gstatic.com/favicon-tbn?q=tbn%3AANd9GcRobWpRagBKXMoDcfSN3X_img5d8Nq67TuwrAktRwrYtmdaP9mlboWwArcZiFjXnk8ebAjJTKbCjn9UliNZx9AZUMSxGoDrNKyi90c1AaIjO-4Dt8GOYJLeO1yy",
"snippet": "A plain “black” cup of coffee is a very low calorie drink—8 ounces only contains 2 calories! However, adding sugar, cream, and milk can quickly bump up the ..."
},
{
"position": 9,
"title": "Black Rifle Coffee | Home | Veteran Founded",
"link": "https://www.blackriflecoffee.com/?srsltid=AfmBOooqbrXMU1TgC5NfJI3S2N6OArBNRVxOQ0vn2ULhC_pDPuDCIOKh",
"displayed_link": "https://www.blackriflecoffee.com",
"favicon": "https://encrypted-tbn1.gstatic.com/favicon-tbn?q=tbn%3AANd9GcSQ0KPBZYN-E6_-TG395r9g5fduhEk-a1UgURz6gvCdO6_GfUaDSIJLD0ry6J8cxdeATqVju60LM3tsH6fiMPNFxVRiJvWfYd3CX3leJEHkU9Q5vw",
"snippet": "Veteran-founded Black Rifle Coffee Company delivers premium small-batch coffee, gear, and unapologetic American values. Join the mission, fuel your day."
},
{
"position": 10,
"title": "Caribou Coffee® | Life Is Short. Stay Awake For It®",
"link": "https://www.cariboucoffee.com/?srsltid=AfmBOopdVML0bJqbgvRe1RZV9qnofeFKw9oep5TWl_izz84n7_GMualB",
"displayed_link": "https://www.cariboucoffee.com",
"favicon": "https://encrypted-tbn3.gstatic.com/favicon-tbn?q=tbn%3AANd9GcRjjXlKFqUKDV8Z3T69L4YTdEL4lvE5SRtpTzdLjSAMvTDNEyJIgfeF7qemE3qaNhLBzA_lmcQ7ZUIoL-QapePqpBCttfqTcmJGU7iENd48sw",
"snippet": "Caribou Coffee® is more than a premium coffeehouse featuring high-quality, handcrafted beverages and food. Explore our menu, sign up for Caribou Coffee® ..."
}
]
}
The organic_results
array stores the list of unpaid listings on Google’s results page and excludes paid ads, which are marked as “Sponsored”. The values in this array corresponds to the links you see on Google's search results page.
Therefore, the values in organic_results
is what we will look at to find out in which position starbucks.com ranks for each of the keywords. As you can see, the Starbucks domain is the second search result on the page for the keyword “coffee”.
By default, the API will return the first ten search results which reflects what is displayed on the first page of Google's search results. For keyword rankings, oftentimes we'll need to pull search results beyond the first page. Due to recent changes in the number of results served by Google in a single search, many web scraping services on the market are unable to retrieve more than 10 results at a time. This is the case currently with our Google Light Search API, so you'd need to make 10 separate API calls if you wanted 100 results. However, with the new Light Fast API, all you need to do is assign the num
parameter to 100
in our request:
const data = await getJson({
api_key: apiKey, //required
engine: "google_light_fast", //required
google_domain: "google.com",
q: keywords[0],//required
gl: "us",
num: 100
})
As of now, SerpApi's Light Fast API is the only web scraping API on the market that lets you retrieve 100 results at a time.
Getting the Keyword Ranking
We’ll write a helper function to find the ranking for starbucks.com within the organic search results. This function returns the first index of the search result whose displayed_link contains starbucks.com, and it will be called for each of our specified keywords.
const getRanking = (data) => {
const index = data.organic_results.findIndex(result =>
result.displayed_link.includes(domain)
);
return index !== -1 ? index + 1 : "N/A";
}
Since we have an array of keywords we want to check for and not just one, what we need to do now is call this API in a loop:
const responses = keywords.map(async (keyword) =>
getJson({
api_key: apiKey,
engine: "google_light_fast",
google_domain: "google.com",
q: keyword,//required
gl: "us"
})
);
const json = await Promise.all(responses);
Once all the API calls for the keywords are complete, we can then check for the ranking of starbucks.com for each of the results.
keywords.forEach((keyword, i) => {
console.log(`The ranking for "${keyword}" is: ${getRanking(json[i])}`);
});
If all went well, you should see something like this:
This means that, with the given parameters, a link to starbucks.com appears as the second search result on Google if the term “coffee” is used to search. Of course, your exact results may be different since search results change frequently.
For the final version of this script, feel free to clone this GitHub repository. If you wanted to build on top of this, you could also add a feature to export the data into a csv. SerpApi makes it effortless to integrate up-to-date, relevant Google search results into your application. This month, we’ve boosted free plans from 100 to 250 credits. Make sure to give it a try by signing up for a free account and experimenting in our public playground. If you have any questions, don't hesitate to contact us at SerpApi Contact.