Overview
Here is the list of the different parameters you can use with ScrapingBee's Google API.
You can also discover this API using our Postman collection covering every ScrapingBee's features.
type
]
(default
)string
]
("us"
)"classic" | "news" | "maps"
]
("classic"
)Getting Started
Our Google Search API allows you to scrape search results pages in realtime.
To scrape the results, you only need two things:
- your API key, available here
- a search query ( learn more about search query )
Then, simply do this.
curl "https://app.scrapingbee.com/api/v1/store/google?api_key=YOUR-API-KEY&search=YOUR-SEARCH"
# Install the Python Requests library:
# `pip install requests`
import requests
def send_request():
response = requests.get(
url="https://app.scrapingbee.com/api/v1/store/google",
params={
"api_key": "YOUR-API-KEY",
"search": "pizza new-york",
},
)
print('Response HTTP Status Code: ', response.status_code)
print('Response HTTP Response Body: ', response.content)
send_request()
// request Axios
const axios = require('axios');
axios.get('https://app.scrapingbee.com/api/v1/store/google', {
params: {
'api_key': 'YOUR-API-KEY',
'search': 'pizza new york',
}
}).then(function (response) {
// handle success
console.log(response);
})
import java.io.IOException;
import org.apache.http.client.fluent.*;
public class SendRequest
{
public static void main(String[] args) {
sendRequest();
}
private static void sendRequest() {
// Classic (GET )
try {
// Create request
Content content = Request.Get("https://app.scrapingbee.com/api/v1/store/google?api_key=YOUR-API-KEY&search=pizza%20new%20york")
// Fetch request and return content
.execute().returnContent();
// Print content
System.out.println(content);
}
catch (IOException e) { System.out.println(e); }
}
}
require 'net/http'
require 'net/https'
# Classic (GET )
def send_request
uri = URI('https://app.scrapingbee.com/api/v1/store/google?api_key=YOUR-API-KEY&search=pizza%20new%20york')
# Create client
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
# Create Request
req = Net::HTTP::Get.new(uri)
# Fetch Request
res = http.request(req)
puts "Response HTTP Status Code: #{ res.code }"
puts "Response HTTP Response Body: #{ res.body }"
rescue StandardError => e
puts "HTTP Request failed (#{ e.message })"
end
send_request()
<?php
// get cURL resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, 'https://app.scrapingbee.com/api/v1/store/google?api_key=YOUR-API-KEY&search=pizza%20new%20york');
// set method
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
// return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// send the request and save response to $response
$response = curl_exec($ch);
// stop if fails
if (!$response) {
die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
}
echo 'HTTP Status Code: ' . curl_getinfo($ch, CURLINFO_HTTP_CODE) . PHP_EOL;
echo 'Response Body: ' . $response . PHP_EOL;
// close curl resource to free up system resources
curl_close($ch);
?>
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func sendClassic() {
// Create client
client := &http.Client{}
// Create request
req, err := http.NewRequest("GET", "https://app.scrapingbee.com/api/v1/store/google?api_key=YOUR-API-KEY&search=pizza%20new%20york", nil)
parseFormErr := req.ParseForm()
if parseFormErr != nil {
fmt.Println(parseFormErr)
}
// Fetch Request
resp, err := client.Do(req)
if err != nil {
fmt.Println("Failure : ", err)
}
// Read Response Body
respBody, _ := ioutil.ReadAll(resp.Body)
// Display Results
fmt.Println("response Status : ", resp.Status)
fmt.Println("response Headers : ", resp.Header)
fmt.Println("response Body : ", string(respBody))
}
func main() {
sendClassic()
}
The API will then respond with formatted JSON data:
{
"bottom_ads": [],
"knowledge_graph": {},
"local_results": [
{
"position": 1,
"review": 4.6,
"review_count": 62,
"title": "NY Pizza Suprema"
},
...
],
"meta_data": {
"location": null,
"zero_results_for_original_query": false,
"number_of_ads": 0,
"number_of_organic_results": 20,
"number_of_page": 363000000,
"number_of_results": 363000000,
"url": "https://www.google.com/search?q=pizza+new+york&hl=en&num=20"
},
"organic_results": [
{
"date": null,
"date_utc": null,
"description": null,
"displayed_url": "https://www.tripadvisor.com › ... › New York City",
"domain": "www.tripadvisor.com",
"position": 1,
"rich_snippet": {},
"sitelinks": [],
"title": "THE 10 BEST Pizza Places in New York City (Updated 2023)",
"url": "https://www.tripadvisor.com/Restaurants-g60763-c31-New_York_City_New_York.html"
},
{
"date": null,
"date_utc": null,
"description": "New York–style pizza is pizza made with a characteristically large hand-tossed thin crust, often sold in wide slices to go. The crust is thick and crisp ...",
"displayed_url": "https://en.wikipedia.org › wiki › New_York–style_pizza",
"domain": "en.wikipedia.org",
"position": 2,
"rich_snippet": {
"top": {
"attributes": [
{
"name": "Main ingredients",
"value": "Pizza dough, tomato sauce, ..."
},
{
"name": "Region or state",
"value": "New York City, New York"
}
],
"attributes_flat": "Main ingredients: Pizza dough, tomato sauce, ..., Region or state: New York City, New York",
"detected_extensions": {}
}
},
"sitelinks": [],
"title": "New York–style pizza",
"url": "https://en.wikipedia.org/wiki/New_York%E2%80%93style_pizza"
},
...
],
"questions": [
{
"answer": "New York-style pizza has slices that are large and wide with a thin crust that is foldable yet crispy. It is traditionally topped with tomato sauce and mozzarella cheese, with any extra toppings placed on top of the cheese. Pizza without additional toppings is called “plain,” “regular,” or “cheese.”",
"position": null,
"text": "What pizza is New York famous for?"
},
...
],
"related_queries": [
{
"position": 0,
"title": "best pizza in new york manhattan",
"url": "https://www.google.com/search?num=20&hl=en&q=Best+pizza+in+New+York+Manhattan&sa=X&ved=2ahUKEwjctLPoq4uAAxWUmWoFHRs4DmgQ1QJ6BAgxEAE"
},
...
],
"related_searches": [
{
"link": "https://www.google.com/search?num=20&hl=en&q=Best+pizza+in+New+York+Manhattan&sa=X&ved=2ahUKEwjctLPoq4uAAxWUmWoFHRs4DmgQ1QJ6BAgxEAE",
"position": 0,
"query": "best pizza in new york manhattan",
"type": "standard"
},
...
],
"top_ads": [
{
"description": "Cheap UK Pizza: Compare pizza in the UK",
"domain": "uk-go-pizza.com",
"position": 1,
"sitelinks": [],
"snippet": null,
"title": "Compare UK Pizza - Pizza - UK Pizza",
"tracking_url": "https://www.google.com/aclk?sa=l&ai=DChcSEwjU1qrRrYuAAxUVn1oFHdLZBI8YABAAGgJ2dQ&ae=2&sig=AOD64_3CFgH0bQFdqiC1kwZfEpVChxRd4g&q&adurl",
"url": "https://uk-go.com/home-insurance/",
"visual_url": "uk-go.com"
}
],
"bottom_ads": [
{
"description": "Cheap UK Pizza: Compare pizza in the UK",
"domain": "uk-go-pizza.com",
"position": 1,
"sitelinks": [],
"snippet": null,
"title": "Compare UK Pizza - Pizza - UK Pizza",
"tracking_url": "https://www.google.com/aclk?sa=l&ai=DChcSEwjU1qrRrYuAAxUVn1oFHdLZBI8YABAAGgJ2dQ&ae=2&sig=AOD64_3CFgH0bQFdqiC1kwZfEpVChxRd4g&q&adurl",
"url": "https://uk-go.com/home-insurance/",
"visual_url": "uk-go.com"
}
],
"top_stories": [
{
"date": "2023-07-12T13:25:12.298Z",
"link": "https://www.grubstreet.com/2023/07/the-best-of-the-year-i-ate-ny-so-far.html",
"position": 2,
"source": "Grub Street",
"title": "The Best of NYC Eating in 2023 (So Far)"
}
],
"news_results": [
{
"date": "2023-07-11T09:23:18.283Z",
"domain": "www.cnbc.com",
"link": "https://www.cnbc.com/2023/07/10/pizza-delivery-driver-why-tipping-is-crucial.html",
"position": 1,
"snippet": "No week of pay is the same for pizza delivery driver Brendan Madden of Lincroft, New Jersey, because \"not everyone tips fairly.\"",
"source": "CNBC",
"title": "Tipping is 'not a sustainable system,' says 25-year-old pizza delivery driver: My income 'relies on the goodwill of others'"
}
],
"map_results": [
{
"address": "New York, NY",
"category": "pizza",
"link": "https://www.google.com/aclk?sa=l&ai=DChcSEwiH9968tNmBAxWrNa0GHQPvDw4YABAAGgJwdg&gclid=EAIaIQobChMIh_fevLTZgQMVqzWtBh0D7w8OEBAYAiAAEgJekvD_BwE&sig=AOD64_32J9Tmh5PKoq6WWVAXNhjXb9jvqA&q=&ctype=99&ved=2ahUKEwjgzNe8tNmBAxVxHDQIHUznDkAQhKwBegQIGxAZ&adurl=",
"phone": "(212) 831-0300",
"position": 2,
"price": "$",
"rating": "4.7",
"reviews": 2301,
"title": "Domino's Pizza"
}
],
"hotel_results": [
{
"name": "Hampton Inn by Hilton Los Angeles Airport",
"review": 4.3,
"position": 1
}
]
}
Keep in mind that each successful API call will cost you 25 api credits.
Every search that failed will be tried as many times as possible for 30 seconds.
So please be aware of this maximum timeout when writing your own code.
API key
api_key
[string
]
(default= ""
)
required
All requests are authenticated by using your private API key.
To get access to your API key, just create an account here and confirm your email.
Search
search
[string
]
(default= ""
)
required
The search
parameter is the text you would put in the Google search bar. You can use anything that you would use in a regular Google search. (e.g., inurl:, site:, intitle:, etc.)
Never forget to correctly encode this parameter before calling the API, especially if you are using special characters such as +
or :
.
If you need help encoding your parameter you can find more information below:
sudo apt-get install gridsite-clients
urlencode "YOUR SEARCH"
import urllib.parse
encoded_url = urllib.parse.quote("YOUR SEARCH")
encoded_url = encodeURIComponent("YOUR SEARCH")
String encoded_url = URLEncoder.encode("YOUR SEARCH", "UTF-8");
require 'uri'
encoded_url = URI::encode("YOUR SEARCH")
<?php
$url_encoded = urlencode("YOUR SEARCH");
?>
package main
import (
"net/url"
)
func main() {
encoded_url := url.QueryEscape("YOUR SEARCH")
}
Geolocation
country_code
[string
]
(default= "us"
)country_code
is the ISO 3166 country code from which you would like the request to come from, here are the most popular supported country codes.
You can find the full list of supported country codes here .
country_code | Country Name |
---|---|
br | Brazil |
in | India |
mx | Mexico |
... | ... |
ru | Russia |
us | UnitedStates |
gb | UnitedKingdom |
Device
device
["desktop" | "mobile"
]
(default= "desktop"
)device
is the device you would like to use to make the request. You can use desktop
or mobile
.
search_type=news
is not available withdevice=mobile
.
Search Type
search_type
["classic" | "news" | "maps"
]
(default= "classic"
)With the ScrapingBee Google API you can scrape different types of Google searches. By default, the API will scrape regular Google searches: search_type=classic
.
You can also scrape Google News searches: search_type=news
.
search_type=news
is not available withdevice=mobile
.search_type=maps
doesn't support anb_results
value greater than 20.
Number of results
nb_results
[integer
]
(default= 100
)The number of results you want to get back from Google Search.
By default this number is 100, you can change it by using the nb_results
parameter. And it cannot surpass 100 as it is the max possible value.
For example, if you only need the first 20 results, use nb_results=20
Warning: if you are looking to get ads informations, you will need to use nb_results=20
as Google do not show ads on page with more than 20 results.
Page Number
page
[integer
]
(default= 1
)The page number you want to extract results from.
By default this number is 1, you can change it by using the page
parameter.
If you want to get search information from the second page of results, juste use page=2
.
Language
language
[string
]
(default= "en"
)The language the search results will be displayed in.
By default the language is en (english), you can change it by using the language
parameter.
The list of supported languages is available here .
Autocorrection
nfpr
[boolean
]
(default= false
)If you want to disable Google's autocorrection feature, you can use nfpr=true
.
Using this parameter will prevent Google from including autocorrected results in the response.
Extra params
extra_params
[string
]
(default= ""
)If you want to forward URL parameters not yet supported by the API you can do it using extra_params
.
For example, if you want to use UULE, you can pass one to the API using extra_params=uule%3DYOUR-UULE
.
Important: youd need to URL encode this parameter correctly.
You can also pass multiple parameters, separated by &
(%26
when encoded).
For example, using extra_params=uule%26YOUR-UULE%26hl%3Dgb
with the Google API will add uule=YOUR-UULE&hl=gb
to the URL we will fetch.
Full HTML
add_html
[boolean
]
(default= false
)Adding the full html of the page available in the results. Useful if you want to get some information we don't return in the JSON response.
By default this parameter's value is false
, use add_html=true
if you want to enable it.
Our API will return you a JSON object that will look like this
{
"statusCode": 200,
"body": {
"meta_data": {
"url": "https://www.google.com/search?q=pizza%20new%20york&hl=en&gl=us&num=20&start=0",
"number_of_results": 615000000,
"location": "",
"number_of_organic_results": 22,
"number_of_ads": 0,
"number_of_page": 7
},
"local_results": [{
"title": "Joe's Pizza",
"review": 4.5,
"position": 0,
"review_count": 5422
},
...
],
"organic_results": [{
"url": "https://ny.eater.com/maps/nyc-best-iconic-pizza-pizzeria",
"displayed_url": "ny.eater.com › maps › nyc-best-iconic-pizza-pizzeria",
"description": "Jan 17, 2020 - Roberto Paciullo's Bronx trattoria serves wood-fired pizzas that have puffy brown crusts and floppy centers. Some pizza geeks think that Zero Otto ...",
"position": 0,
"title": "New York City's 27 Most Iconic Pizzerias - Eater NY"
},
...
{
"url": "https://www.timeout.com/newyork/restaurants/best-new-york-pizza",
"displayed_url": "www.timeout.com › restaurants › best-new-york-pizza",
"description": "Aug 2, 2019 - There's nothing that says “I love NY” more than eating a classic slice of New York pizza in view of the Brooklyn Bridge. And who better to provide ...",
"position": 17,
"title": "29 Best Pizzas in NYC for Life-Changing Slices To Eat Today"
}],
"top_ads": [],
"bottom_ads": [],
"related_queries": [{
"title": "best pizza new york",
"position": 0
},
...
{
"title": "joe's pizza new york",
"position": 7
}],
"questions": [{
"text": "What is the best pizza in NY?",
"position": 0
},
...
{
"text": "How much is a slice of pizza in New York City?",
"position": 3
}]
"full_html": # HTML of the page since full_html=true
}
}