# Google Maps API

{% hint style="success" %}
To enable this engine, set the **`engine=google_maps`** parameter.
{% endhint %}

Interacting with the Google Maps scraper is quite straightforward. As opposed to the [Google Search API](https://docs.webscrapingapi.com/google-search-api/google-search-engines/google-search-api), which can take a lot of parameters and allows more flexibility in customizing the response, the Google Maps API has fewer options, but the data it returns is still as rich and accurate.

<figure><img src="https://1192456954-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9wbsYOleiAqS785aMtPp%2Fuploads%2FMlCheDoBrAW4MeHmfE36%2Fgoogle-maps-api.png?alt=media&#x26;token=7de3eece-d763-43f0-974c-8d7d20eb947e" alt=""><figcaption><p>Scrape Google Maps Results</p></figcaption></figure>

### Google Maps API Integration Examples

We will use following URL as an example for this request:

```
https://serpapi.webscrapingapi.com/v2?engine=google_maps&api_key=<YOUR_API_KEY>&q=pizza
```

### Ready to Use Google Maps Scraping Scripts:

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```bash
curl --request GET --url "https://serpapi.webscrapingapi.com/v2?engine=google_maps&api_key=<YOUR_API_KEY>&q=pizza"
```

{% endcode %}
{% endtab %}

{% tab title="NodeJS" %}
{% code overflow="wrap" %}

```javascript
const http = require("https");

const options = {
  "method": "GET",
  "hostname": "serpapi.webscrapingapi.com",
  "port": null,
  "path": "/v2?engine=google_maps&api_key=YOUR_API_KEY&q=pizza",
  "headers": {}
};

const req = http.request(options, function (res) {
  const chunks = [];

  res.on("data", function (chunk) {
    chunks.push(chunk);
  });

  res.on("end", function () {
    const body = Buffer.concat(chunks);
    console.log(body.toString());
  });
});

req.end();
```

{% endcode %}
{% endtab %}

{% tab title="Python" %}
{% code overflow="wrap" %}

```python
import http.client

conn = http.client.HTTPSConnection("serpapi.webscrapingapi.com")

conn.request("GET", "/v2?engine=google_maps&api_key=YOUR_API_KEY&q=pizza")

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
```

{% endcode %}
{% endtab %}

{% tab title="PHP" %}
{% code overflow="wrap" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://serpapi.webscrapingapi.com/v2?engine=google_maps&api_key=YOUR_API_KEY&q=pizza",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
]);

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

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

{% endcode %}
{% endtab %}

{% tab title="Go" %}
{% code overflow="wrap" %}

```go
package main

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

func main() {

	url := "https://serpapi.webscrapingapi.com/v2?engine=google_maps&api_key=YOUR_API_KEY&q=pizza"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := ioutil.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code overflow="wrap" %}

```java
HttpResponse<String> response = Unirest.get("https://serpapi.webscrapingapi.com/v2?engine=google_maps&api_key=YOUR_API_KEY&q=pizza")
  .asString();
```

{% endcode %}
{% endtab %}

{% tab title=".NET" %}
{% code overflow="wrap" %}

```csharp
var client = new RestClient("https://serpapi.webscrapingapi.com/v2?engine=google_maps&api_key=YOUR_API_KEY&q=pizza");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

{% endcode %}
{% endtab %}

{% tab title="Ruby" %}
{% code overflow="wrap" %}

```ruby
require 'uri'
require 'net/http'
require 'openssl'

url = URI("https://serpapi.webscrapingapi.com/v2?engine=google_maps&api_key=YOUR_API_KEY&q=pizza")

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
```

{% endcode %}
{% endtab %}
{% endtabs %}

### Google Maps Specific Parameters

#### #1: Query Parameter

<table><thead><tr><th width="187">Parameter</th><th width="107" align="center">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>q</code><br><mark style="color:red;background-color:red;">Required</mark></td><td align="center"><code>string</code></td><td>The keywords that you are searching for on Google (the query).</td></tr></tbody></table>

#### #2: Request Customization Parameters

<table><thead><tr><th width="184">Parameter</th><th width="106" align="center">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td align="center"><code>string</code></td><td>The type of search. It can be <code>hotels</code> or <code>vacation_rentals</code>.</td></tr><tr><td><code>data</code></td><td align="center"><code>string</code></td><td>This parameter is required only if <code>q</code> is not provided.<br><br>It has to be constructed in the next sequence: <code>!4m5!3m4!1s</code> + <code>data_id</code> + <code>!8m2!3d</code> + <code>latitude</code> + <code>!4d</code> + <code>longitude</code></td></tr></tbody></table>

#### #3: Device and Geolocation Parameters

<table><thead><tr><th width="184">Parameter</th><th width="106" align="center">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>device</code></td><td align="center"><code>string</code></td><td>The device used for your Google Maps search. Can be set to <code>desktop</code>, <code>mobile</code> or <code>tablet</code>.</td></tr><tr><td><code>hl</code></td><td align="center"><code>string</code></td><td>The language you want to use for your Google Maps search. <a href="https://developers.google.com/custom-search/docs/xml_results_appendices#interfaceLanguages">List of supported languages</a></td></tr><tr><td><code>gl</code></td><td align="center"><code>string</code></td><td>The country you want to use for your Google Maps search. <a href="https://developers.google.com/custom-search/docs/xml_results_appendices#countryCodes">List of supported countries</a></td></tr><tr><td><code>ll</code></td><td align="center"><code>string</code></td><td>Parameter defines GPS coordinates of location where you want your <code>q</code> (query) to be applied. It has to be constructed in the next sequence: <code>@</code> + <code>latitude</code> + <code>,</code> + <code>longitude</code> + <code>,</code> + <code>zoom</code>.</td></tr></tbody></table>

#### #4: Pagination Parameters

<table><thead><tr><th width="185">Parameter</th><th width="106" align="center">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>start</code></td><td align="center"><code>int</code></td><td>The offset of the Google Maps results. Represents the number of results that you want to skip.</td></tr><tr><td><code>num</code></td><td align="center"><code>int</code></td><td>The number of results returned on each page.</td></tr></tbody></table>

<details>

<summary>Response Example</summary>

```json
{
    "general": {
        "query": "coffee",
        "language": "en",
        "country": "United States",
        "country_code": "US",
        "gl": "US"
    },
    "organic": [
        {
            "title": "Fika Fika",
            "display_link": "fikafikacoffee.com",
            "link": "http://fikafikacoffee.com/",
            "address": "1731 E Colorado Blvd, Pasadena, CA 91106",
            "phone": "+16263142081",
            "open_hours": {
                "Monday": "7 AM–6 PM",
                "Tuesday": "7 AM–6 PM",
                "Wednesday": "7 AM–6 PM",
                "Thursday": "7 AM–6 PM",
                "Friday": "7 AM–6 PM",
                "Saturday": "7 AM–6 PM",
                "Sunday": "7 AM–6 PM"
            },
            "category": [
                {
                    "id": "coffee_shop",
                    "title": "Coffee shop"
                },
                {
                    "id": "cafe",
                    "title": "Cafe"
                },
                {
                    "id": "dessert_shop",
                    "title": "Dessert shop"
                }
            ],
            "tags": [
                {
                    "group_id": "service_options",
                    "group_title": "Service options",
                    "key_id": "/geo/type/establishment_poi/has_seating_outdoors",
                    "key_title": "Outdoor seating",
                    "value": 1,
                    "value_title": "Has outdoor seating",
                    "value_title_short": "Outdoor seating"
                },
                {
                    "group_id": "service_options",
                    "group_title": "Service options",
                    "key_id": "/geo/type/establishment_poi/has_delivery",
                    "key_title": "Delivery",
                    "value": 1,
                    "value_title": "Offers delivery",
                    "value_title_short": "Delivery"
                },
                {
                    "group_id": "service_options",
                    "group_title": "Service options",
                    "key_id": "/geo/type/establishment_poi/has_takeout",
                    "key_title": "Takeout",
                    "value": 1,
                    "value_title": "Offers takeout",
                    "value_title_short": "Takeout"
                },
...
```

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.webscrapingapi.com/google-search-api/google-search-engines/google-maps-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
