> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stophy.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Google maps search API

> Search places on Google Maps by keyword and location. Call the Google maps search API for JSON. 1 credit per call. Every call returns the same flat shape.

Searches places on Google Maps by keyword and location.

## Request

`query` and `location` are required.

<Note>This endpoint can be called without an API key, subject to per-address limits. Pagination requires a key.</Note>

<CodeGroup>
  ```typescript TypeScript icon="https://mintlify.s3.us-west-1.amazonaws.com/sirathic/images/icons/typescript.svg" theme={null} theme={null}
  import { Stophy } from "stophy";

  const stophy = new Stophy({ apiKey: process.env.STOPHY_API_KEY });
  const result = await stophy.google.maps.search({ query: "coffee", location: "Austin, TX", openNow: true });
  console.log(result.data.results);
  ```

  ```python Python icon="python" theme={null} theme={null}
  from stophy import Stophy

  stophy = Stophy()  # reads STOPHY_API_KEY
  result = stophy.google.maps.search(query="coffee", location="Austin, TX", open_now=True)
  print(result["data"]["results"])
  ```

  ```bash cURL icon="terminal" theme={null} theme={null}
  curl -X POST https://api.stophy.dev/v1/google/maps/search \
    -H "Authorization: Bearer $STOPHY_API_KEY" \
    -H "content-type: application/json" \
    -d '{"query":"coffee","location":"Austin, TX","openNow":true}'
  ```

  ```bash CLI icon="square-terminal" theme={null} theme={null}
  stophy google maps search --query coffee --location "Austin, TX" --openNow
  ```
</CodeGroup>

## Response

If successful, the response body contains the standard envelope. `data.results[]` contains the places, each with its rating, address, contact details and opening hours.

The following example is a real response, truncated: each list shows one item and long strings are cut.

```json theme={null}
{
  "success": true,
  "data": {
    "results": [
      {
        "placeId": "0x865b33ee6a9856e5:0x5064d03fde124e36",
        "googlePlaceId": "ChIJ5VaYau4zW4YRNk4S3j_QZFA",
        "placeUrl": "https://www.google.com/maps?cid=5792983993432559158",
        "name": "Mojo Coffee Lakeline",
        "categories": ["Coffee shop"],
        "address": "12206 Ranch Rd 620 N, Austin, TX 78750",
        "latitude": 30.462303,
        "longitude": -97.817188,
        "rating": 4.7,
        "reviews": 679,
        "photos": 268,
        "phone": "+1 555 0100",
        "website": "http://www.mojodrivethru.com/",
        "hours": [
          {
            "days": "Monday",
            "times": ["5:30 AM–8 PM"]
          }
        ],
        "hoursToday": "5:30 AM–8 PM",
        "openStatus": "Open · Closes 8 PM",
        "timezone": "America/Chicago",
        "thumbnailUrl": "https://lh3.googleusercontent.com/gps-cs-s/AHRPTWlPKARR4YyKDk76jDBsFhgsqjIvxLr7sKpLPhAnAWtgf2_0l9wx3yKJUF1vlNqaEE0Ao_eQ…",
        "attributes": ["Wheelchair accessible entrance", "Wheelchair accessible parking lot"]
      }
    ],
    "page": 1
  },
  "creditsUsed": 1,
  "requestId": "2fe9dbad-fc48-4890-9751-0b24b596035b"
}
```

| Field | Type | Description |
| - | - | - |
| `page` | integer | The page number of this response. |
| `rating` | number | The average star rating, on a scale of 1 to 5. |
| `reviews` | integer | The number of reviews the rating is based on. |
| `openStatus` | string | The current opening status, as displayed by Google. |

For every field, see the response schema on this page.

## Optional parameters

| Parameter | Type | Description |
| - | - | - |
| `minRating` | number | Restricts results to places rated at least this high. Acceptable values are `2`, `2.5`, `3`, `3.5`, `4` and `4.5`. |
| `openNow` | boolean | Restricts results to places open at the time of the search. If unset, defaults to `false`. |
| `country` | string | The country to query, as a two-letter ISO 3166-1 code such as `us`. If unset, defaults to `us`. |
| `language` | string | The language of the results, as a BCP 47 tag such as `en` or `pt-BR`. If unset, defaults to `en`. |
| `page` | integer | The page to return. Pages are numbered from 1. Must be between 1 and 10. If unset, defaults to `1`. |

## Billing

Each successful request consumes 1 credit, regardless of the number of items returned. Requests that fail, or that return no items, are not billed.

## Pagination

Results are paginated. To retrieve the next page, increment `page`. An empty `data.results` indicates the last page. The maximum value of `page` is 10.

## Related methods

* [Google Maps place](/api-reference/endpoint/google-maps-place): Accepts `placeUrl`. Returns a place's address, hours, rating and contact details.
* [Google Maps reviews](/api-reference/endpoint/google-maps-reviews): Accepts `placeUrl`. Returns a place's reviews.


## OpenAPI

````yaml api-reference/openapi.json POST /v1/google/maps/search
openapi: 3.1.0
info:
  title: Stophy API
  version: '1'
  description: >-
    Every endpoint is a POST that takes its input as a JSON object body. Unknown
    fields are rejected with 400.


    Responses leave out empty values: null, empty strings, empty objects and
    empty nested lists are not sent.


    x-credits is what one call costs. Every call costs the same, whatever it
    returns, unless an operation's description says it costs per 10 results, or
    per second of audio. Then x-credits is the lowest price and x-credits-max
    the most one call can cost. Where an operation takes limit, send it to
    return fewer results and pay for fewer.


    When a response has a cursor, send it back unchanged with the same input to
    get the next page. When it has a page, send the next page number.
servers:
  - url: https://api.stophy.dev
security:
  - apiKey: []
paths:
  /v1/google/maps/search:
    post:
      summary: Search places on Google Maps by keyword and location
      description: Costs 1 credit per call. Pages with page.
      operationId: googleMapsSearch
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  minLength: 1
                  maxLength: 200
                location:
                  type: string
                  minLength: 2
                  maxLength: 200
                minRating:
                  type: number
                  enum:
                    - 2
                    - 2.5
                    - 3
                    - 3.5
                    - 4
                    - 4.5
                openNow:
                  default: false
                  description: >-
                    Google Maps' own Hours filter, Open now: only places open at
                    the moment of the search.
                  type: boolean
                country:
                  default: us
                  type: string
                  pattern: ^[A-Za-z]{2}$
                  description: >-
                    ISO 3166-1 alpha-2 country code, e.g. us. Any case is
                    accepted.
                language:
                  default: en
                  type: string
                  pattern: ^[A-Za-z]{2,3}(?:[-_][A-Za-z0-9]{2,4})?$
                  description: BCP 47 language tag, e.g. en or pt-BR. Any case is accepted.
                page:
                  default: 1
                  description: Page number, starting at 1.
                  type: integer
                  minimum: 1
                  maximum: 10
              required:
                - query
                - location
              additionalProperties: false
            example:
              query: coffee
              location: Austin, TX
              openNow: true
      responses:
        '200':
          description: The data, and the credits this call used.
          headers:
            X-Request-ID:
              $ref: '#/components/headers/RequestId'
            x-credits-used:
              $ref: '#/components/headers/CreditsUsed'
            X-RateLimit-Limit:
              $ref: '#/components/headers/RateLimitLimit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/RateLimitRemaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/RateLimitReset'
            x-cache:
              $ref: '#/components/headers/Cache'
            x-cache-age:
              $ref: '#/components/headers/CacheAge'
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                  - creditsUsed
                  - requestId
                properties:
                  success:
                    const: true
                  data:
                    type: object
                    additionalProperties: false
                    properties:
                      results:
                        type: array
                        items:
                          type: object
                          additionalProperties: false
                          properties:
                            placeId:
                              type: string
                            googlePlaceId:
                              type: string
                            placeUrl:
                              type: string
                              format: uri
                            name:
                              type: string
                            categories:
                              type: array
                              items:
                                type: string
                            address:
                              type: string
                            latitude:
                              type: number
                              minimum: -90
                              maximum: 90
                            longitude:
                              type: number
                              minimum: -180
                              maximum: 180
                            rating:
                              type: number
                            reviews:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                            photos:
                              type: integer
                              minimum: -9007199254740991
                              maximum: 9007199254740991
                            phone:
                              type: string
                            website:
                              type: string
                              format: uri
                            description:
                              type: string
                            hours:
                              type: array
                              items:
                                type: object
                                additionalProperties: false
                                properties:
                                  days:
                                    type: string
                                  times:
                                    type: array
                                    items:
                                      type: string
                                required: []
                            hoursToday:
                              type: string
                            openStatus:
                              type: string
                            timezone:
                              type: string
                            thumbnailUrl:
                              type: string
                              format: uri
                            reservationUrl:
                              type: string
                              format: uri
                            attributes:
                              type: array
                              items:
                                type: string
                          required:
                            - placeUrl
                            - latitude
                            - longitude
                      page:
                        type: integer
                        minimum: 1
                        maximum: 9007199254740991
                    required:
                      - results
                      - page
                  creditsUsed:
                    type: integer
                  requestId:
                    type: string
        4XX:
          $ref: '#/components/responses/Error'
        5XX:
          $ref: '#/components/responses/Error'
      security:
        - apiKey: []
components:
  headers:
    RequestId:
      description: The request id. Quote it when you report a problem.
      schema:
        type: string
    CreditsUsed:
      description: Credits this call used.
      schema:
        type: integer
    RateLimitLimit:
      description: Requests allowed in the current window.
      schema:
        type: integer
    RateLimitRemaining:
      description: Requests left in the current window.
      schema:
        type: integer
    RateLimitReset:
      description: Unix time in seconds when the current window resets.
      schema:
        type: integer
    Cache:
      description: hit if this result came from the cache, miss if it was fetched live.
      schema:
        type: string
    CacheAge:
      description: Seconds since the returned result was written to the cache.
      schema:
        type: integer
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
  responses:
    Error:
      description: The request failed. retryable says whether trying again can help.
      headers:
        X-Request-ID:
          $ref: '#/components/headers/RequestId'
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - success
        - error
      properties:
        success:
          const: false
        error:
          type: object
          required:
            - code
            - message
            - retryable
            - requestId
          properties:
            code:
              type: string
              enum:
                - cliSessionCompleted
                - cliSessionExists
                - cliSessionNotFound
                - forbidden
                - insufficientCredits
                - internalError
                - inviteClaimed
                - inviteDisabled
                - inviteExpired
                - inviteUsedUp
                - invalidCliSession
                - invalidCliVerifier
                - invalidRequest
                - notFound
                - rateLimited
                - sourceChanged
                - sourceRefused
                - sourceTimeout
                - sourceUnavailable
                - tooManyInFlight
                - unauthorized
                - unsupportedMediaType
            message:
              type: string
            retryable:
              type: boolean
            retryAfterSeconds:
              type: integer
            requestId:
              type: string
            requiredCredits:
              type: number
            availableCredits:
              type: number
            billingUrl:
              type: string
              const: https://stophy.dev/billing
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.