1

I am using the Google Geocoding API to retrieve place_id (and other) information to use with the Places API. Most addresses return an expected 27-character place_id value, i.e.:

ChIJUXJ61wrsFogR3jv6yBBFlQY

However, a small percentage of addresses which otherwise return seemingly good data (formatted_address, etc.) are returning 50-character values with the prefix E like:

EjA1Mjk1IFB1bGxleWJsYW5rIFN0LCBXaW5kc29yLCBPTiBOOU

These 50-char place_ids throw errors on Google's other APIs (i.e. Distance Matrix using the place_id as origin and/or destination):

Invalid request. Invalid 'origins' parameter. 'EiU5MDAxIFJpbGV5IFN0LCBaZWVsYW5kLCBNSSA0OTQ2NCwgVV' 
is not a valid Place ID.

When I look at Google's responses, I see they all fall into three categories:

  1. location_type=RANGE_INTERPOLATED, types=street_address
  2. location_type=ROOFTOP, types=subpremise
  3. location_type=APPROXIMATE, types=intersection

All three indicate addresses with "issues" in some way (bogus street number, subsection of larger area, approximate location). So, I guess my question is:

Are 50-character place_id values always garbage?

Kristen Waite
  • 1,385
  • 2
  • 15
  • 28

1 Answers1

2

You're truncating these IDs, so that's why the API says they are invalid. They can be more than 50 characters.

If you keep the whole ID intact they E prefix IDs will work with Distance Matrix etc.

spiv
  • 2,458
  • 1
  • 16
  • 20
  • 1
    Do not impose your own size limits on Place IDs, they can be arbitrarily long. – miguev Sep 16 '16 at 15:06
  • So, this seems like a bad question now - clearly a simple mistake on my part. Should I just delete this question? – Kristen Waite Sep 20 '16 at 12:11
  • No, it is a good question, because https://developers.google.com/places/place-id looks like Place IDs are expected to always be 27-character strings. – miguev Sep 20 '16 at 12:57