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

# Google Places

> Client-mode REST API connectors for Google Maps Platform: geocoding, elevation, time zone, device geolocation, Routes API ETAs and matrices, Roads API snap to roads and speed limits, Places search, Address Validation, Weather and Air Quality

Technical Preview

## Overview

Client-mode REST API connectors for Google Maps Platform: geocoding, elevation, time zone, device geolocation, Routes API ETAs and matrices, Roads API snap to roads and speed limits, Places search, Address Validation, Weather and Air Quality.

This is one of the templates in the Google Maps Platform REST API app (`google-maps-platform`). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector).

> [!NOTE]
>
> Not yet verified against the live vendor API: No Google Maps Platform API key: every event needs a key. All 18 events were sent to the real Google hosts with a dummy key and got Google's invalid-key answer (classic web services 200 status REQUEST\_DENIED, newer APIs 400 API\_KEY\_INVALID), but no keyed call could run.

## Auth

* **schemes**: \["API key query parameter key= (Geocoding, Elevation, Time Zone, Geolocation, Roads, Address Validation, Weather, Air Quality)", "X-Goog-Api-Key header + required X-Goog-FieldMask header (Routes API, Places API (New))"]
* **secrets**: \["GOOGLE\_MAPS\_API\_KEY"]
* **note**: OAuth 2.0 service accounts not packaged (Fleet Engine and Route Optimization need OAuth).

Auth headers used by the template: `X-Goog-Api-Key: {value.json.apikey}`.

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Google Places connector | no |
| `BaseUrl` | string | Google Places base URL without trailing slash (e.g. [https://places.googleapis.com](https://places.googleapis.com)) | yes |

`BASE_ADDRESS` default: `https://places.googleapis.com`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `SearchText` | POST | `/v1/places:searchText` | `fleet/google-maps/places/search/text` | `fleet/google-maps/places/search/text/response` | `apikey`, `body`, `fieldmask` |
| `SearchNearby` | POST | `/v1/places:searchNearby` | `fleet/google-maps/places/search/nearby` | `fleet/google-maps/places/search/nearby/response` | `apikey`, `body`, `fieldmask` |
| `GetPlace` | GET | `/v1/places/{value.json.placeid}?languageCode=en{value.json.params}` | `fleet/google-maps/places/get` | `fleet/google-maps/places/get/response` | `apikey`, `fieldmask`, `params`, `placeid` |

## Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode GOOGLE_PLACES"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE GooglePlaces WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://places.googleapis.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '30'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT SearchText
        WITH SOURCE_TOPIC "fleet/google-maps/places/search/text"
        WITH DESTINATION_TOPIC "fleet/google-maps/places/search/text/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v1/places:searchText"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "X-Goog-Api-Key" "{value.json.apikey}"
            ADD "X-Goog-FieldMask" "{value.json.fieldmask}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT SearchNearby
        WITH SOURCE_TOPIC "fleet/google-maps/places/search/nearby"
        WITH DESTINATION_TOPIC "fleet/google-maps/places/search/nearby/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/v1/places:searchNearby"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "X-Goog-Api-Key" "{value.json.apikey}"
            ADD "X-Goog-FieldMask" "{value.json.fieldmask}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT GetPlace
        WITH SOURCE_TOPIC "fleet/google-maps/places/get"
        WITH DESTINATION_TOPIC "fleet/google-maps/places/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/v1/places/{value.json.placeid}?languageCode=en{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "X-Goog-Api-Key" "{value.json.apikey}"
            ADD "X-Goog-FieldMask" "{value.json.fieldmask}"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

## Usage example

Call `SearchText` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'fleet/google-maps/places/search/text/response' &
mosquitto_pub -t 'fleet/google-maps/places/search/text' -m '{"apikey": "<apikey>", "body": {}, "fieldmask": "<fieldmask>"}'
```

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps catalog](/latest/lot-language/routes/rest-api-apps)


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