WebScrapingAPI Docs
Search Engine APIsGoogle Search APIGoogle Search Engines

Google Search API

Scrape Google Search and get real-time, location-based results without handling captchas, proxies, or SERP parsing yourself.

Scrape Google Search and get real-time, location-based results without worrying about captchas.

To enable this engine, set engine=google.

Scraping Google Search results takes a lot of effort in the background, as Google has multiple ways to detect and prevent scrapers. With the Google Search API, you only need to send a GET request to our endpoint and the engine returns structured search data.

Scrape Google Search Results

Scrape Google Search Results

Google Search API Integration Examples

We will use the following URL as an example request:

https://serpapi.webscrapingapi.com/v2?engine=google&api_key=<YOUR_API_KEY>&q=history

Ready to Use Google Search Scraping Scripts

curl --request GET \
  --url "https://serpapi.webscrapingapi.com/v2?engine=google&api_key=<YOUR_API_KEY>&q=history"
const response = await fetch("https://serpapi.webscrapingapi.com/v2?engine=google&api_key=<YOUR_API_KEY>&q=history", {
  method: "GET"
});

const data = await response.text();
console.log(data);
import http.client

connection = http.client.HTTPSConnection("serpapi.webscrapingapi.com")
connection.request("GET", "/v2?engine=google&api_key=<YOUR_API_KEY>&q=history")

response = connection.getresponse()
data = response.read()

print(data.decode("utf-8"))
<?php

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://serpapi.webscrapingapi.com/v2?engine=google&api_key=<YOUR_API_KEY>&q=history",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_CUSTOMREQUEST => "GET",
]);

$response = curl_exec($curl);
$error = curl_error($curl);

curl_close($curl);

echo $error ? "cURL Error #: " . $error : $response;
package main

import (
	"fmt"
	"io"
	"log"
	"net/http"
)

func main() {
	requestURL := "https://serpapi.webscrapingapi.com/v2?engine=google&api_key=<YOUR_API_KEY>&q=history"

	response, err := http.Get(requestURL)
	if err != nil {
		log.Fatal(err)
	}
	defer response.Body.Close()

	body, err := io.ReadAll(response.Body)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(string(body))
}
HttpResponse<String> response = Unirest
    .get("https://serpapi.webscrapingapi.com/v2?engine=google&api_key=<YOUR_API_KEY>&q=history")
    .asString();

System.out.println(response.getBody());
var client = new RestClient("https://serpapi.webscrapingapi.com/v2?engine=google&api_key=<YOUR_API_KEY>&q=history");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);

Console.WriteLine(response.Content);
require "uri"
require "net/http"
require "openssl"

url = URI("https://serpapi.webscrapingapi.com/v2?engine=google&api_key=<YOUR_API_KEY>&q=history")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
response = http.request(request)

puts response.read_body

Google Search Specific Parameters

Query Parameter

ParameterTypeRequiredDescription
qstringThe keywords that you are searching for on Google.

Request Customization Parameters

ParameterTypeRequiredDescription
tbmstringDefines the search vertical. Use isch for images, vid for videos, nws for news, or shop for shopping. Leave it unset for regular Google Search results.
ibpstringUsed for jobs search. Example: ibp=htl;jobs.

Device and Geolocation Parameters

ParameterTypeRequiredDescription
devicestringDevice type used for the search. Supported values include desktop, mobile, and tablet.
domainstringGoogle domain to use for the search.
uulestringGoogle encoded location to use for the search.
hlstringInterface language for the Google search.
glstringCountry code used to localize the Google search.

Pagination Parameters

ParameterTypeRequiredDescription
startintOffset of the Google Search results. Represents how many results to skip.
numintNumber of results returned on each page.

Response example

{
  "general": {
    "search_engine": "google",
    "results_cnt": 12730000000,
    "search_time": 0.35,
    "language": "en",
    "location": "United States",
    "mobile": false,
    "basic_view": false,
    "search_type": "text",
    "page_title": "history - Google Search",
    "timestamp": "2024-10-08T11:57:01.533Z"
  },
  "input": {
    "original_url": "https://google.com/search?q=history",
    "user_agent": "Mozilla/5.0"
  },
  "navigation": [
    {
      "title": "Images",
      "href": "https://google.com/search?q=history&udm=2"
    },
    {
      "title": "Videos",
      "href": "https://google.com/search?q=history&tbm=vid"
    },
    {
      "title": "News",
      "href": "https://google.com/search?q=history&tbm=nws"
    }
  ],
  "organic": [
    {
      "link": "https://www.history.com/",
      "display_link": "https://www.history.com",
      "title": "HISTORY | Watch Full Episodes of Your Favorite Shows",
      "description": "Watch full episodes of your favorite HISTORY series, and dive into thousands of historical articles and videos.",
      "rank": 1,
      "global_rank": 1
    },
    {
      "link": "https://en.wikipedia.org/wiki/History",
      "display_link": "https://en.wikipedia.org › wiki › History",
      "title": "History",
      "description": "History is the systematic study and documentation of the human past.",
      "rank": 7,
      "global_rank": 11
    }
  ]
}

Google result modules vary by query, locale, device, and search vertical. Treat each response block as optional and read the modules your application needs.

On this page