Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Places API: Are "place_id" or "id" unique to any city in the world?

When doing a autocomplete API call for a location, I request a JSON response from google.

What is the difference between the "id" and "place_id" string?

Are these two id's unique to any city in the world?

Does google places assign every city in the world an id?

For example, does Somers, NY, USA have the same id as Somers, New York, United States?

Is there an easy way to get an id for a city? (from a google maps url or something?)

Here is the JSON response from a autocomplete api call of Somers NY USA:

    {
   "html_attributions" : [],
   "result" : {
      "address_components" : [
         {
            "long_name" : "Somers",
            "short_name" : "Somers",
            "types" : [ "administrative_area_level_3", "political" ]
         },
         {
            "long_name" : "Westchester County",
            "short_name" : "Westchester County",
            "types" : [ "administrative_area_level_2", "political" ]
         },
         {
            "long_name" : "New York",
            "short_name" : "NY",
            "types" : [ "administrative_area_level_1", "political" ]
         },
         {
            "long_name" : "United States",
            "short_name" : "US",
            "types" : [ "country", "political" ]
         }
      ],
      "adr_address" : "\u003cspan class=\"locality\"\u003eSomers\u003c/span\u003e, \u003cspan class=\"region\"\u003eNY\u003c/span\u003e, \u003cspan class=\"country-name\"\u003eUSA\u003c/span\u003e",
      "formatted_address" : "Somers, NY, USA",
      "geometry" : {
         "location" : {
            "lat" : 41.29963050000001,
            "lng" : -73.7360175
         },
         "viewport" : {
            "northeast" : {
               "lat" : 41.3550988,
               "lng" : -73.65881709999999
            },
            "southwest" : {
               "lat" : 41.2379047,
               "lng" : -73.78000709999999
            }
         }
      },
      "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
      "id" : "8e846f7cdf419380d138e6d605137e739075b777",
      "name" : "Somers",
      "place_id" : "ChIJ6wv7yGixwokRIwjh6OWI4I0",
      "reference" : "CoQBcgAAAKxvwwjlyK3ZaVA5DAM52DU8tMMplyvamYxXVJuMyDplQ3SUs-9ONvZgIN4sDW_sUz9z7wdoBCmPcgWHY9Oi_l0hImvMtiE8s6TKaUCDju2vzlcSEGXtDW0bvixVbbuF35AP2stRw80YjcrnwuMDglKEHKUVdH8vzSVG91WNOcOcEhBda300E-VstT6ZQ1zCx30eGhQBUGcFLuUeB484h1AzDw75Aw5wxA",
      "scope" : "GOOGLE",
      "types" : [ "administrative_area_level_3", "political" ],
      "url" : "https://maps.google.com/maps/place?q=Somers,+NY,+USA&ftid=0x89c2b168c8fb0beb:0x8de088e5e8e10823"
   },
   "status" : "OK"
}
like image 609
dio Avatar asked Nov 29 '14 02:11

dio


1 Answers

"id" and "reference" have been deprecated and will be removed from the results in mid-2015. They were not "unique" in the sense that you could look up somewhere from that info.

Placeid is different - it is both unique to the location and the location generally only has one Placeid. (This is true in most cases. However a "place" can have additional IDs that refer to different scopes (Google scope vs user scope) or if a business has moved to a different place giving it a new place_id. However in all cases, place_id is still persistent.) Furthermore you use the Placeid to access the Details API.

See the deprecation notice here: https://developers.google.com/places/documentation/search

Note: The id and reference fields are deprecated as of June 24, 2014. They are replaced by the new place ID, a unique identifier that can be used to compare places and to retrieve information about a place. The Places API currently returns a place_id in all responses, and accepts a placeid in the Place Details and Place Delete requests. Soon after June 24, 2015, the API will stop returning the id and reference fields in responses. Some time later, the API will no longer accept the reference in requests. We recommend that you update your code to use the new place ID instead of id and reference as soon as possible.

like image 87
Scott Avatar answered Sep 21 '22 02:09

Scott