Maton

Google Maps

Access Google Maps Platform with managed authentication. Search places and read their details and photos, compute routes and route matrices, geocode and reverse geocode, validate postal addresses, and look up time zones and elevation. One connection covers several Google APIs, and the gateway routes each call to the right one by its path. Every call is billed to the Google Cloud project that owns the API key, and field masks decide which billing SKU applies. All access runs through the Maton gateway and the maton CLI.

Permissions

Suggested read access

In the Console, Read limits the connection to these 16 read-only endpoints, plus deny rules for any write endpoint a broader rule would otherwise match. Endpoints Maton has found to return credentials, start jobs, or spend credits are left out; a few reads that can change state or return a secret depending on their parameters stay in, and their descriptions say how. It is a suggestion: the saved rules are exactly the ones you see, and you can change them with Custom. See Access policy.

Reference

Places

Search Places by Text

maton api '/google-maps/v1/places:searchText' -X POST \
  -H 'Content-Type: application/json' \
  -H 'X-Goog-FieldMask: places.id,places.displayName,places.formattedAddress' \
  --input - <<'JSON'
{
  "textQuery": "coffee near Googleplex Mountain View",
  "pageSize": 2
}
JSON

Body fields:

  • textQuery (string, required): Free-text query, e.g. a name, category, or address
  • pageSize (integer, optional): 1-20 results per page (default 20)
  • includedType (string, optional): One place type, e.g. restaurant
  • locationBias / locationRestriction (object, optional): A circle or rectangle to prefer or limit results
  • languageCode, regionCode (string, optional)
  • openNow, minRating, priceLevels (optional): Filters
  • pageToken (string, optional): nextPageToken from the previous page

Response:

{
  "places": [
    {
      "id": "ChIJrb8rKgC5j4ARC8tyXckFZE4",
      "displayName": {"text": "Cafe at Mountain View", "languageCode": "en"},
      "formattedAddress": "2000 N Shoreline Blvd Ground Floor, Mountain View, CA 94043, USA"
    }
  ]
}

The X-Goog-FieldMask header is required; without it Google returns 400. Search masks are prefixed with places. (and nextPageToken to get the next page). Common fields: places.id, places.displayName, places.formattedAddress, places.location, places.types, places.googleMapsUri. Fields such as places.rating, places.regularOpeningHours, places.reviews, and places.photos bill at a higher SKU.

Search Nearby Places

maton api '/google-maps/v1/places:searchNearby' -X POST \
  -H 'Content-Type: application/json' \
  -H 'X-Goog-FieldMask: places.id,places.displayName' \
  --input - <<'JSON'
{
  "includedTypes": ["restaurant"],
  "maxResultCount": 5,
  "locationRestriction": {
    "circle": {"center": {"latitude": 37.4220, "longitude": -122.0841}, "radius": 500}
  }
}
JSON

Body fields:

  • locationRestriction.circle (object, required): center (latitude, longitude) and radius in meters (up to 50000)
  • includedTypes / excludedTypes (array, optional): Place types
  • maxResultCount (integer, optional): 1-20
  • rankPreference (string, optional): POPULARITY (default) or DISTANCE

The response has the same places shape as text search. Nearby search has no pagination.

Autocomplete Places

maton api '/google-maps/v1/places:autocomplete' -X POST \
  -H 'Content-Type: application/json' \
  --input - <<'JSON'
{
  "input": "Googlepl",
  "includedRegionCodes": ["us"]
}
JSON

Response (trimmed):

{
  "suggestions": [
    {
      "placePrediction": {
        "placeId": "ChIJj61dQgK6j4AR4GeTYWZsKWw",
        "text": {"text": "Googleplex, Amphitheatre Parkway, Mountain View, CA, USA"},
        "structuredFormat": {
          "mainText": {"text": "Googleplex"},
          "secondaryText": {"text": "Amphitheatre Parkway, Mountain View, CA, USA"}
        },
        "types": ["establishment", "point_of_interest"]
      }
    }
  ]
}

Autocomplete needs no field mask. Each request is billed on its own unless the calls share a sessionToken (any UUID) that ends with a Place Details call for the chosen place; pass the same sessionToken to both.

Get Place Details

maton api '/google-maps/v1/places/{place_id}?fields=id,displayName,formattedAddress,location'

Note: Use an id from search or a placeId from autocomplete.

Example:

maton api '/google-maps/v1/places/ChIJrb8rKgC5j4ARC8tyXckFZE4?fields=id,displayName,formattedAddress,location'

Response:

{
  "id": "ChIJrb8rKgC5j4ARC8tyXckFZE4",
  "formattedAddress": "2000 N Shoreline Blvd Ground Floor, Mountain View, CA 94043, USA",
  "location": {"latitude": 37.4215996, "longitude": -122.0806343},
  "displayName": {"text": "Cafe at Mountain View", "languageCode": "en"}
}

A field mask is required, either as ?fields= or as an X-Goog-FieldMask header. Details masks have no places. prefix. Add sessionToken= when closing an autocomplete session.

Get a Place Photo

maton api '/google-maps/v1/places/{place_id}/photos/{photo_id}/media?maxWidthPx=400&skipHttpRedirect=true'

Note: Take them from a photo name (places/{place_id}/photos/{photo_id}), which comes back when the search or details mask includes photos (places.photos.name in search).

Response:

{
  "name": "places/ChIJrb8rKgC5j4ARC8tyXckFZE4/photos/{photo_id}",
  "photoUri": "https://lh3.googleusercontent.com/..."
}

maxWidthPx or maxHeightPx (1-4800) is required. With skipHttpRedirect=true the response is JSON carrying a short-lived photoUri; without it Google redirects to the image itself. Photo names expire, so fetch them fresh rather than storing them. Each photo request is billed separately.

Routes

Compute Routes

maton api '/google-maps/directions/v2:computeRoutes' -X POST \
  -H 'Content-Type: application/json' \
  -H 'X-Goog-FieldMask: routes.duration,routes.distanceMeters' \
  --input - <<'JSON'
{
  "origin": {"address": "Googleplex, Mountain View, CA"},
  "destination": {"address": "San Francisco International Airport"},
  "travelMode": "DRIVE"
}
JSON

Body fields:

  • origin, destination (object, required): A waypoint with address, placeId, or location.latLng (latitude, longitude)
  • intermediates (array, optional): Up to 25 stops
  • travelMode (string, optional): DRIVE (default), BICYCLE, WALK, TWO_WHEELER, TRANSIT
  • routingPreference (string, optional): TRAFFIC_UNAWARE (default), TRAFFIC_AWARE, TRAFFIC_AWARE_OPTIMAL. Traffic-aware routing bills at a higher SKU
  • departureTime (string, optional): RFC 3339 timestamp
  • computeAlternativeRoutes (boolean, optional)
  • routeModifiers (object, optional): avoidTolls, avoidHighways, avoidFerries
  • units, languageCode (string, optional)

Response:

{
  "routes": [
    {"distanceMeters": 35453, "duration": "1375s"}
  ]
}

The X-Goog-FieldMask header is required. Other useful fields: routes.polyline.encodedPolyline, routes.legs, routes.legs.steps.navigationInstruction, routes.travelAdvisory. Durations are strings in seconds ("1375s").

Compute Route Matrix

maton api '/google-maps/distanceMatrix/v2:computeRouteMatrix' -X POST \
  -H 'Content-Type: application/json' \
  -H 'X-Goog-FieldMask: originIndex,destinationIndex,duration,distanceMeters,condition' \
  --input - <<'JSON'
{
  "origins": [{"waypoint": {"address": "Mountain View, CA"}}],
  "destinations": [
    {"waypoint": {"address": "Palo Alto, CA"}},
    {"waypoint": {"address": "San Jose, CA"}}
  ],
  "travelMode": "DRIVE"
}
JSON

Response:

[
  {"originIndex": 0, "destinationIndex": 0, "distanceMeters": 11264, "duration": "944s", "condition": "ROUTE_EXISTS"},
  {"originIndex": 0, "destinationIndex": 1, "distanceMeters": 24091, "duration": "1410s", "condition": "ROUTE_EXISTS"}
]

The response is a JSON array with one element per origin-destination pair, in no guaranteed order; match them by originIndex and destinationIndex. The field mask is required. Each element is billed, so a matrix of n origins and m destinations costs n x m elements (at most 625 per request, 100 with traffic-aware routing).

Geocoding

Geocode an Address

maton api '/google-maps/v4beta/geocode/address/{address}' \
  -H 'X-Goog-FieldMask: results.placeId,results.formattedAddress,results.location'

Note: URL-encode it.

Example:

maton api '/google-maps/v4beta/geocode/address/1600%20Amphitheatre%20Parkway%2C%20Mountain%20View%2C%20CA' \
  -H 'X-Goog-FieldMask: results.placeId,results.formattedAddress,results.location'

Response:

{
  "results": [
    {
      "placeId": "ChIJiSSC8QK6j4AR98Thup8mqTc",
      "location": {"latitude": 37.4224864, "longitude": -122.0855962},
      "formattedAddress": "Google Building 41, 1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA"
    }
  ]
}

Reverse Geocode a Location

maton api '/google-maps/v4beta/geocode/location/{lat},{lng}' \
  -H 'X-Goog-FieldMask: results.placeId,results.formattedAddress'

Example:

maton api '/google-maps/v4beta/geocode/location/37.4220,-122.0841' \
  -H 'X-Goog-FieldMask: results.placeId,results.formattedAddress'

Returns results ordered from the most specific address to broader ones (plus codes, localities).

Geocode a Place ID

maton api '/google-maps/v4beta/geocode/places/{place_id}'

Returns one result with the place's address components and location. Geocoding v4 also accepts ?fields= instead of the header; without a mask it returns every field.

Geocode with the Web Service

maton api '/google-maps/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA'
maton api '/google-maps/maps/api/geocode/json?latlng=37.4220,-122.0841'

Response (trimmed):

{
  "results": [
    {
      "formatted_address": "Google Building 41, 1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
      "geometry": {"location": {"lat": 37.4224864, "lng": -122.0855962}},
      "place_id": "ChIJiSSC8QK6j4AR98Thup8mqTc"
    }
  ],
  "status": "OK"
}

The classic Geocoding API takes address, latlng, place_id, or components (e.g. components=postal_code:94043|country:US), plus language and region. Like every maps/api/* service it answers HTTP 200 even on failure; check status (see Notes).

Address Validation

Validate an Address

maton api '/google-maps/v1:validateAddress' -X POST \
  -H 'Content-Type: application/json' \
  --input - <<'JSON'
{
  "address": {
    "regionCode": "US",
    "addressLines": ["1600 Amphitheatre Pkwy, Mountain View, CA"]
  }
}
JSON

Response (trimmed):

{
  "result": {
    "verdict": {
      "inputGranularity": "PREMISE",
      "validationGranularity": "PREMISE",
      "geocodeGranularity": "PREMISE",
      "addressComplete": true,
      "hasInferredComponents": true,
      "possibleNextAction": "ACCEPT"
    },
    "address": {
      "formattedAddress": "1600 Amphitheatre Parkway, Mountain View, CA 94043-1351, USA"
    }
  },
  "responseId": "{response_id}"
}

result also carries address.addressComponents, geocode (location and place ID), metadata, and, for US addresses, uspsData. verdict.possibleNextAction is ACCEPT, CONFIRM, CONFIRM_ADD_SUBPREMISES, or FIX. Add "enableUspsCass": true for USPS CASS processing of US addresses. Pass previousResponseId (the first call's responseId) when re-validating the same address after a correction. An address is personal data: validate only the addresses the user gave for this task.

Send Validation Feedback

maton api '/google-maps/v1:provideValidationFeedback' -X POST \
  -H 'Content-Type: application/json' \
  --input - <<'JSON'
{
  "conclusion": "VALIDATED_VERSION_USED",
  "responseId": "{response_id}"
}
JSON

Note: Use the responseId of the first validation in the sequence.

conclusion is VALIDATED_VERSION_USED, USER_VERSION_USED, UNVALIDATED_VERSION_USED, or UNUSED. The response is an empty object.

Time Zone

Get the Time Zone for a Location

maton api '/google-maps/maps/api/timezone/json?location=37.42,-122.08&timestamp=1700000000'

Response:

{
  "dstOffset": 0,
  "rawOffset": -28800,
  "status": "OK",
  "timeZoneId": "America/Los_Angeles",
  "timeZoneName": "Pacific Standard Time"
}

timestamp (Unix seconds, required) decides whether daylight saving applies; local time is timestamp + rawOffset + dstOffset.

Elevation

Get Elevation

maton api '/google-maps/maps/api/elevation/json?locations=39.7391536,-104.9847034'

Response:

{
  "results": [
    {
      "elevation": 1608.637939453125,
      "location": {"lat": 39.7391536, "lng": -104.9847034},
      "resolution": 4.771975994110107
    }
  ],
  "status": "OK"
}

elevation is in meters. Pass several points as locations=lat,lng|lat,lng (up to 512 per request), or sample along a line with path=lat,lng|lat,lng&samples=10.

Pagination

Text search returns nextPageToken when more results exist and the mask includes it (X-Goog-FieldMask: places.id,places.displayName,nextPageToken). Send the same body with "pageToken": "{next_page_token}" to get the next page, up to 60 results in total. Each page is a separate billed request, so page only as far as the task needs. Nearby search, autocomplete, routes, and geocoding are not paginated.

Notes

  • Billing: every call is billed to the user's Google Cloud project per SKU, and Google's monthly free usage per SKU is the only free tier. Place Details and search SKUs depend on the field mask; traffic-aware routing and route-matrix elements cost more than basic routes. Point the user at Google Cloud Console → Billing for spend and budgets.
  • Field masks are required for Places search and details and for Routes (X-Goog-FieldMask header, or ?fields= on Place Details and Geocoding v4). Use only the fields the task needs; * returns everything at the highest SKU.
  • API not enabled: a 403 with {"error": {"code": 403, "status": "PERMISSION_DENIED"}} means that API (Places API (New), Routes API, Geocoding API, Address Validation API, Time Zone API, or Elevation API) is not enabled on the key's Cloud project, or the key's API restrictions leave it out. The user enables it in Google Cloud Console → APIs & Services → Library, or adds it to the key's restrictions; the change can take a few minutes to apply.
  • Invalid key: 400 INVALID_ARGUMENT with reason API_KEY_INVALID means the key was deleted or mistyped; reconnect with a working key.
  • maps/api/* services report errors in the body. They answer HTTP 200 with status: OK, ZERO_RESULTS (a valid request with no match), INVALID_REQUEST (missing or bad parameter), REQUEST_DENIED (API not enabled, key restricted, or billing off; read error_message), OVER_QUERY_LIMIT, OVER_DAILY_LIMIT, or UNKNOWN_ERROR (retry once). Always check status, not just the HTTP code.
  • Legacy services: maps/api/place/*, maps/api/directions/json, and maps/api/distancematrix/json are routed, but Google no longer enables the legacy Places, Directions, and Distance Matrix APIs on new Cloud projects; on those projects they return REQUEST_DENIED ("You're calling a legacy API"). Use Places API (New) and Routes API instead.
  • Coordinates are WGS84 decimal degrees; Routes and Places (New) use latitude/longitude objects, maps/api/* uses lat,lng strings.
  • Google's terms limit caching Maps content: place IDs may be stored, but other place data and photo URIs should not be kept beyond the task.

Resources

On this page