Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places API - Place ID format

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?

like image 776
marko logan Avatar asked Mar 22 '15 23:03

marko logan


3 Answers

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

like image 75
Mark Arnold Avatar answered Dec 07 '22 22:12

Mark Arnold


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
like image 31
Paul Avatar answered Dec 07 '22 22:12

Paul


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.

like image 20
Scott Avatar answered Dec 07 '22 21:12

Scott