# Google Maps API

Efficiently extract data from Google Maps with the Google Maps Scraper API, facilitated by a mere HTTP request.

Activate this feature by incorporating the `engine=google_maps` parameter in your request.

Utilizing the Google Maps Scraper is a breeze. Contrasting with other scraper APIs that often require numerous parameters and offer extensive response customization, the Google Maps Scraper API streamlines the process with fewer options. Yet, it doesn't compromise on the depth and precision of the data returned, ensuring you receive comprehensive and accurate results.

### Google Maps API Integration Examples

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

```
https://serp.shifter.io/v1?engine=google_maps&api_key=<YOUR_API_KEY>&q=pizza&type=search
```

### Ready to Use Google Maps Scraping Scripts:

{% tabs %}
{% tab title="cURL" %}

```bash
curl --request GET --url "https://serp.shifter.io/v1?engine=google_maps&api_key=<YOUR_API_KEY>&q=pizza&type=search"
```

{% endtab %}

{% tab title="NodeJS" %}

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

const options = {
  "method": "GET",
  "hostname": "serp.shifter.io",
  "port": null,
  "path": "/v1?engine=google_maps&api_key=YOUR_API_KEY&q=pizza&type=search",
  "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();
```

{% endtab %}

{% tab title="Python" %}

```python
import http.client

conn = http.client.HTTPSConnection("serp.shifter.io")

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

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

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

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://serp.shifter.io/v1?engine=google_maps&api_key=YOUR_API_KEY&q=pizza&type=search",
  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;
}
```

{% endtab %}

{% tab title="Go" %}

```go
package main

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

func main() {

	url := "https://serp.shifter.io/v1?engine=google_maps&api_key=YOUR_API_KEY&q=pizza&type=search"

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

}
```

{% endtab %}

{% tab title="Java" %}

```java
HttpResponse<String> response = Unirest.get("https://serp.shifter.io/v1?engine=google_maps&api_key=YOUR_API_KEY&q=pizza&type=search")
  .asString();
```

{% endtab %}

{% tab title=".NET" %}

```vbnet
var client = new RestClient("https://serp.shifter.io/v1?engine=google_maps&api_key=YOUR_API_KEY&q=pizza&type=search");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

{% endtab %}

{% tab title="Ruby" %}

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

url = URI("https://serp.shifter.io/v1?engine=google_maps&api_key=YOUR_API_KEY&q=pizza&type=search")

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

{% 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 Customisation 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><br> <mark style="color:red;background-color:red;">Required</mark> </td><td align="center"><code>string</code></td><td>The type of search. It can be <code>search</code> or <code>place</code>.</td></tr><tr><td><code>data</code></td><td align="center"><code>string</code></td><td>This parameter is required only if <code>type</code> is set to <code>place</code>. <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 search. Can be set to <code>desktop</code>, <code>mobile</code> or <code>tablet</code>.</td></tr><tr><td><code>google_domain</code></td><td align="center"><code>string</code></td><td>The Google domain that you want to use for your search.</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>ll</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>

<details>

<summary>Response Example</summary>

```javascript
{
  "search_parameters": {
    "google_url": "https://www.google.com/maps/search/pizza",
    "engine": "google_maps",
    "google_domain": "google.com",
    "device": "desktop",
    "query": "pizza",
    "type": "search"
  },
  "search_information": {
    "local_results_state": "Results for exact spelling"
  },
  "place_results": {
    "data_id": "https://ww",
    "user_reviews": {
      "summary": [],
      "most_relevant": []
    }
  },
  "local_results": [
    {
      "data_id": "0x89e379bfc249e031:0x2744a9fd10684eb",
      "gps_coordinates": {
        "latitude": 42.3503877,
        "longitude": -71.115236
      },
      "title": "OTTO",
      "rating": 4.3,
      "reviews": 365,
      "price": "$$",
      "type": "Pizza",
      "address": "888 Commonwealth Avenue",
      "description": "Gourmet pizzeria with takeout & delivery",
      "hours": "Closed · Opens at 11:00 AM",
      "position": 1
    },
    {
      "data_id": "0x89e379ef2236b031:0xf910ef7dd785af82",
      "gps_coordinates": {
        "latitude": 42.3502708,
        "longitude": -71.1137999
      },
      "title": "Boston House of Pizza",
      "rating": 4.2,
      "reviews": 82,
      "price": "$",
      "type": "Pizza",
      "address": "173 Amory St",
      "description": "Basic spot for pies, subs & burgers",
      "hours": "Closed · Opens at 11:00 AM",
      "position": 2
    },
    {
      "data_id": "0x89e379f0f2403581:0x2841b486b884b115",
      "gps_coordinates": {
        "latitude": 42.3496029,
        "longitude": -71.1055847
      },
      "title": "University Grill & Pizza",
      "rating": 4.4,
      "reviews": 76,
      "price": "$",
      "type": "Pizza",
      "address": "712 Commonwealth Avenue #1",
      "description": "Fast-food spot for pies & Greek bites",
      "hours": "Closed · Opens at 10:00 AM",
      "position": 3
    },
    {
      "data_id": "0x89e379e869d71101:0xc67403ae37365829",
      "gps_coordinates": {
        "latitude": 42.351788,
        "longitude": -71.119156
      },
      "title": "Blaze Pizza",
      "rating": 4.5,
      "reviews": 436,
      "price": "$",
      "type": "Pizza",
      "address": "961 Commonwealth Avenue",
      "description": "Hip chain of fast-crisped pizzas",
      "hours": "Closed · Opens at 11:00 AM",
      "position": 4
    },
    {
      "data_id": "0x89e37a1de7fc9e47:0xd429117177ebdbd7",
      "gps_coordinates": {
        "latitude": 42.3477013,
        "longitude": -71.1058545
      },
      "title": "Domino's Pizza",
      "rating": 3.3,
      "reviews": 402,
      "price": "$",
      "type": "Pizza",
      "address": "508 Park Dr",
      "description": "Longtime pizza chain known for delivery",
      "hours": "Closed · Opens at 10:30 AM",
      "position": 5
    },
    {
      "data_id": "0x89e379fcc30f524d:0x8fc1387d9e22dc44",
      "gps_coordinates": {
        "latitude": 42.357672,
        "longitude": -71.107884
      },
      "title": "Cambridge Pizzeria",
      "rating": 4.5,
      "reviews": 115,
      "price": "$",
      "type": "Takeout Restaurant",
      "address": "263, 4517, Brookline St",
      "description": "Old-school option for pies & subs",
      "hours": "Closed · Opens at 11:00 AM",
      "position": 6
    },
    {
      "data_id": "0x89e379c8e4d5cfc1:0x766ed60712c2b507",
      "gps_coordinates": {
        "latitude": 42.3573341,
        "longitude": -71.1077389
      },
      "title": "Dimi's Place",
      "rating": 4.7,
      "reviews": 20,
      "price": "$",
      "type": "Pizza",
      "address": "272 Brookline St",
      "hours": "Closed · Opens at 11:00 AM",
      "description": "Closed · Opens at 11:00 AM",
      "position": 7
    },
    {
      "data_id": "0x89e379c2848683bd:0x14665c2212758099",
      "gps_coordinates": {
        "latitude": 42.3515122,
        "longitude": -71.1215028
      },
      "title": "T Anthony's Pizzeria",
      "rating": 4.3,
      "reviews": 504,
      "price": "$",
      "type": "Pizza",
      "address": "1016 Commonwealth Avenue",
      "description": "Pizza joint with BU sports memorabilia",
      "hours": "Closed · Opens at 10:00 AM",
      "position": 8
    }
  ]
}
```

</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://developers.shifter.io/google-serp-api/search-apis/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.
