Search code examples
web-servicesmapsgoogle-places-api

Unsupported field name 'website' (Find Place - Google Places API)


I am trying to find place listings that have a website. So something like "cafe in New York" should return multiple places that has website URLs. I understand the website field falls under contact SKU.

However, whenever I make a call with the website field (exactly as mentioned in the Find Places API Doc), it throws this error:

{
   "candidates" : [],
   "error_message" : "Error while parsing 'fields' parameter: Unsupported field name 'website'. ",
   "status" : "INVALID_REQUEST"
}

Here is the URL that returns this error:

https://maps.googleapis.com/maps/api/place/findplacefromtext/json?fields=formatted_address%2Cname%2Crating%2Copening_hours%2Cwebsite&input=Cafes%20in%20NewYork&inputtype=textquery&key=MYAPIKEY

Note that I have removed my API key here in the above URL and replaced with text "MYAPIKEY".

Can anyone see the above query and see why the field name website is invalid when it is already mentioned in the "Find Place" docs that "website" indeed is a valid field?

Or am I doing something wrong?

Here is the Find Place API Doc that I referred to: https://developers.google.com/maps/documentation/places/web-service/search-find-place#Place-website

All I want is to get at least 5+ results with a single API call that has a website. So places with website is what I am looking for.

Appreciate your help greatly!


Solution

  • Place Search / Find Place requests only return a subset of the fields that are returned by Place Details requests

    If the field you want is not returned by Place Search, you can use Place Search to get a place_id, then use that Place ID to make a Place Details request.

    ref: https://developers.google.com/maps/documentation/places/web-service/search-find-place#fields

    If you check the Place Data Fields documentation, it says this:

    Place Search, Nearby Search, and Text Search requests all return a subset of the fields that are returned by Place Details requests. These methods do NOT return the following fields:

    address_component, adr_address, curbside_pickup, current_opening_hours, delivery, dine_in, editorial_summary, formatted_phone_number, international_phone_number, opening_hours.periods, opening_hours.special_days, opening_hours.type, opening_hours.weekday_text, reservable secondary_opening_hours, reviews, serves_beer, serves_breakfast, serves_brunch, serves_dinner, serves_lunch,
    serves_vegetarian_food, serves_wine, takeout, type, url,
    user_ratings_total, utc_offset_minutes, vicinity, website,
    wheelchair_accessible_entrance,

    As you can see, website is included in the list, and the only way for you to fetch them is to use Place Details. You can fetch the place_id using Find Place first, then use Place Details with the place_id you had to get the website.

    https://maps.googleapis.com/maps/api/place/findplacefromtext/json?fields=place_id&input=Cafes%20in%20NewYork&inputtype=textquery&key=API_KEY

    This will return the place_id: ChIJcaZiKLVZwokRmPzP29O2DNU

    Then use that place_id for Place Details Request:

    https://maps.googleapis.com/maps/api/place/details/json?fields=name%2Crating%2Cformatted_address%2Cwebsite%2Copening_hours&place_id=ChIJcaZiKLVZwokRmPzP29O2DNU&key=API_KEY

    And this will return everything you wanted, including the website.

    But since you mentioned that you want to fetch at least five results, you must take note that Find Place is not for you since it is used with the sole purpose of finding a single place in relation to your query. So I would suggest that you use Text Search, since it is able to return more than one result in relation to your text query. But this does not have fields support so this could cost more. If you want to cut some cost, you can just follow the aforementioned solution.

    I hope this helps!