Is short name returned in response from google places api unique?

1.6k views Asked by At

I am using google places api to fetch the data of a particular location/place and then I maintain my database using the fetched data I have following table structure:

Countries ( 'id' , 'country_name' )

State ( 'id' , 'state_name' , 'country_id' )

localities ( 'id' , 'locality_name' , 'state_id' )

Now the issue is I am inserting values returned from google places API in my current database and in need to maintain my database in two languages that is in English and German. But names of countries or areas could be different in different languages like we have Germany in english and Deutschland in german. Now I need to match the records while insertion that if record (country or city) already exists then do not insert it otherwise insert the particular record (country or city). Now I need something common between two different language version so that I can now that this 'Deutschland' is same as 'Germany' for that I was looking into short_name of location provided by google place api. All I wanted to know that whether we get this all the time and whether its unique or not? Google API Response

Google API Response

1

There are 1 answers

1
not_a_bot On

If you want a unique identifier, you can use the place_id.

For example, if you use

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=germany&language=en&key=[YOUR_API_KEY]

and

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Deutschland&language=de&key=[YOUR_API_KEY]

Both give you place_id "ChIJa76xwh5ymkcRW-WRjmtd6HU". You can check the documentation for more information.