13

I need to store some Place IDs in my DB. Unfortunately there is no documentation on the Place ID format. Basically, I mean the maximum (or fixed) length and the valid characters (i.e. a regular expression to validate the formal correctness of a Place ID). In other words, I need to know if I have to use CHAR(n) or VARCHAR(n) and an appropriate check constraint for the column.

It looks like they always are 27 chars of the urlsafe Base64 alphabet (- instead of + and _ instead of /), but I can't be 100% sure as this aspect is not documented.

Can someone shed some light on this?

marko logan
  • 131
  • 1
  • 3
  • I would use VARCHAR. I think it would be safe to set max length to 50. – Verma Mar 23 '15 at 15:48
  • 1
    Possible duplicate of [Google Places API place\_id field length](http://stackoverflow.com/questions/24430241/google-places-api-place-id-field-length) – Vajk Hermecz Apr 14 '16 at 15:56

5 Answers5

3

Unfortunately I can't provide you with documentation on PlaceID - I'd love to see some if Google ever nails it down. I do want to note that current PlaceIDs are 40 characters long right now, not 27.

My advice to you (and the advice I take in my own db) is to not limit the size of your PlaceID field and to use Nvarchar to maximize the characters that Google may choose to use in the future.

Since Google isn't committing to any restrictions at the moment, I think that you would be taking a risk assuming they will keep with the current format.

Scott
  • 3,663
  • 8
  • 33
  • 56
  • You're wrong. Only IDs are 40 chars long, PlaceIDs are 27. – dimention Jul 19 '15 at 13:42
  • 1
    You're wrong. Let me show you Jennifer, aka the PlaceID that just broke my system: EjEyNCBKZW5uaWZlciBIaWxsIFJkLCBMYWdyYW5nZXZpbGxlLCBOWSAxMjU0MCwgVVNB – Vajk Hermecz Apr 14 '16 at 15:54
  • @VajkHermecz your PlaceID does not work anymore. But in the "possible duplicate http://stackoverflow.com/questions/24430241/google-places-api-place-id-field-length" there are some that are even longer. – Klaas Jan 05 '18 at 13:55
  • @VajkHermecz Oh, seems to be a copy&paste error. Copying your place id has a hidden character after "xMjU0" that is not visible in every editor. – Klaas Jan 05 '18 at 14:07
2

The current documentation (last update 20th of June 2019) states that the place ID varies in length and can (currently) span from 27 characters long all the way to 60.

A place ID is a textual identifier that uniquely identifies a place. The length of the identifier may vary. Examples:

ChIJrTLr-GyuEmsRBfy61i59si0

EisxMyBNYXJrZXQgU3RyZWV0LCBXaWxtaW5ndG9uLCBOQyAyODQwMSwgVVNB
Paul
  • 59
  • 5
  • Where did you see that it can span from 27 character all the way to 60? There is no such statement in their documentation. – inafalcao May 05 '20 at 07:25
  • @inafalcao Click on the link I posted, check the examples they provide and measure their lengths. The point is that the length of a `placeID` varies and they don't seem to all follow the same 'format'. I've just checked the docs again and now the longest example is 92 characters long. `EicxMyBNYXJrZXQgU3QsIFdpbG1pbmd0b24sIE5DIDI4NDAxLCBVU0EiGhIYChQKEgnRTo6ixx-qiRHo_bbmkCm7ZRAN` – Paul May 07 '20 at 17:13
  • @Paul that doesn't mean that's the max length, and it shouldn't be phrased in your answer as "The current documentation states that the place ID varies in length and can (currently) span from 27 characters long all the way to 60." It doesn't actually state that. You made assumptions. – John Harding Jul 05 '23 at 22:55
1

PLACE_ID's should be a minimum of 512 in a SQL structure.

Here is a valid ID at 315 length: 'EsIBS0FWLjc2LTc4LCBJbmRvZm9vZCBUb3dlciwgU3VkaXJtYW4gUGxhemEsIEpsLiBKZW5kLiBTdWRpcm1hbiBOby43Ni03OCwgUlQuMy9SVy4zLCBLdW5pbmdhbiwgU2V0aWEgQnVkaSwgS2VjYW1hdGFuIFNldGlhYnVkaSwgS290YSBKYWthcnRhIFNlbGF0YW4sIERhZXJhaCBLaHVzdXMgSWJ1a290YSBKYWthcnRhIDEwMjUwLCBJbmRvbmVzaWEiJRojChYKFAoSCSH20UED9GkuEc707mF-vRHxEglLQVYuNzYtNzg'

Personally I use a SHA256 fixed length unique field for PLACE_ID's with a lookup table. Either way, 512 minimum.

Mark

Mark Arnold
  • 253
  • 3
  • 9
0

There are some changes with placeId in google API. Check Google Doc to know more about it. if need any examples and docs about place autocomplete.

http://www.w3docs.com/learn-javascript/places-autocomplete.html

Hazarapet Tunanyan
  • 2,809
  • 26
  • 30
0

I did the same to register frequent places according to my system of places in services, the recommended thing seeing the variation between 27, 60 and 92.

I left it at 256 (with the possibility of growth or change of archetype).

Red
  • 26,798
  • 7
  • 36
  • 58
ZeaKer J
  • 1
  • 2