Google API for Restaurants Places - google-places-api

I am having problems understanding the Google Places API. I am building an iPhone application with a nearby feature that allows the user to find restaurants located around the user's GPS. How can I obtain a Google API for this? Do I have to have one custom made how does this work? If I also wanted to create an API for points of interest how can I do that?

There is a Google Places API for searching for nearby locations. The documentation is here: https://developers.google.com/places/documentation/search#PlaceSearchRequests
But I'm guessing you already found that. If you ask more specific questions, we can be more helpful.

You can use Google place API , and if you want to display only specific type of places e.g restaurant in your cases you can use request object as shown in the code below
var request = {
location: pyrmont,
type: ['restaurant']
};
infowindow = new google.maps.InfoWindow();
places = new google.maps.places.PlacesService(map);
places.nearbySearch(request, callback);
For more details on type filteration in google place API you can check the Link on Google Developers.
But nearby search taking only one type parameter, and it is only restaurants. Not food, not cafe, only restaurants, which Google API provides, if you are looking for the public catering establishments.

First of all, the Google Paces API should be active.
function displayRestaurantAround() {
return new Promise((resolve, reject) => {
this.service.nearbySearch({
location: currentUserPosition,
radius: 5000,
types: ['restaurant']
}, (res) => {
resolve(res);
});
});
}

Related

Google People API / Other Contacts - how to get photos of other contacts?

Google forces us to migrate from the deprecated Contacts API over new People API.
They even implemented "Other Contacts" feature in the People API which was so demanded.
But now I'm facing another problem - there is no way to get photos of Other Contacts in the People API.
I was digging into this problem and figured out that it's possible to add photos into the readMask (even though it's not documented):
https://people.googleapis.com/v1/otherContacts?access_token=<...>&readMask=emailAddresses,names,photos
...but it doesn't help, because it returns the default picture with the first letter for all contacts, even for contacts who has a real photo. Like this one: https://lh3.googleusercontent.com/cm/ABXenNkcRSTRZU8PEFQfJtaeEBZnxLgN-UO555npUt1idzcMohoSGuJFfKx0JX2AR6Qp=s100
I tried to add coverPhotos into the readMask but it doesn't let it there.
Then I was checking how old Contacts API formats photo urls and figured out the format:
https://www.google.com/m8/feeds/photos/media/<user-email-address>/<contact-id>
But it has 2 disadvantages:
this url has to be requested with access_token
it works only if the contact uploaded a custom photo, otherwise it returns error
So here is my question:
Is there any simpler and cleaner way to get real photos of Other Contacts in People API?
This bug has been solved and now we have a solution!
Updated documentation: https://developers.google.com/people/api/rest/v1/otherContacts/list
There is a new sources[] request parameter. To get the real photos of "other contacts" you need to specify 2 values: READ_SOURCE_TYPE_CONTACT and READ_SOURCE_TYPE_PROFILE.
The request would look like this:
GET https://people.googleapis.com/v1/otherContacts?readMask=photos&key=API_KEY&sources=READ_SOURCE_TYPE_CONTACT&sources=READ_SOURCE_TYPE_PROFILE
Now some contacts will contain 2 entries in the photos array:
photos: [
{
metadata: {
primary: true,
source: {
type: "PROFILE",
id: "11111"
}
},
url: "<THIS IS THE REAL PROFILE PICTURE>"
},
{
metadata: {
source: {
type: "OTHER_CONTACT",
id: "6666666"
}
},
url: "<THIS IS THE DEFAULT PHOTO STUB>",
default: true
}
]
The readMask fields accepted for the otherContacts.list method are the following:
emailAddresses
metadata
names
phoneNumbers
photos
As you can notice, the photos field is an accepted one while making the above request.
However, the returned response should yield a url which redirects you to the user's profile picture. Because of this, I have taken the opportunity to report it on Google's Issue Tracker here. I suggest you star the issue as any updates regarding this will be posted there.
Reference
People API otherContacts.list;
People API Support.

Fetch My Own Alexa Shopping list into a Bootstrap table

Did research on SOW & Alexa Documentation but iam a bit overwhelmed.
What i wanted to do is access my own alexa shopping list and list the items in a simple bootstrap table.
So i can style it my way and have it ready for printing.
My Idea was using ajax and then look how the data is delivered and then style it accordingly.
Is Ajax the right way to do it or where could i research to finally get my dream Idea to work.
function fetchAlexaList() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("shoppinglist").innerHTML = this.responseText;
}
};
xhttp.open("GET", "https://api.amazonalexa.com/myshoppinglist", true);
xhttp.send();
}
I found docs on how to create my own skill and then you get tokkens and so on but i basically only want to access my own list, hope this is possible without creating a custom alexa skill. didnt found the right api address for my own shopping list tho.
Thx for being a awesome community welcoming newcomers <3
Kind regards
You'll want to use the skill messaging API. You'll need to include a Login with Amazon authorization flow in your web site to get the token.
Start here (
https://developer.amazon.com/en-US/docs/alexa/custom-skills/access-the-alexa-shopping-and-to-do-lists.html#out-of-session-interaction) to find out where to get the client ID and client secret needed to implement the authorization flow and then follow down the page for more on implementing it and then querying the API for your list.

Google Places API for Hospitals

I am using Google Places API to search nearby hospitals from a location. My problem is that I want to get famous and big hospitals but the problem is the API is fetching clinics and even dental clinics too. How I can be more specific?
Query URL : https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=24.9044526,67.077706&type=hospital&radius=500&key=[API_KEY]
Although they are not famous even the medical facilities provided there are not sufficient for emergency case.
I have also tried increasing the radius but got same response.
I know this post is a bit old but this worked for me:
var request = {
location: location,
rankBy: google.maps.places.RankBy.DISTANCE,
type: "hospital",
keyword: "(emergency) AND ((medical centre) OR hospital) AND (24 hours)",
};
service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);

How to create interest in interest category?

As per below link create interest functionality is nto avaialable.
http://developer.mailchimp.com/documentation/mailchimp/reference/lists/interest-categories/interests/#
But using API playgroung you can create interest. Even tried with REST api and I am able to create interest. Please let me know if "create interest " API has been removed from above page.
I think it never wasn't on that page. This new API Documentation lacks many things that are possible.
If you want to create new interest you can just POST to this endpoint:
/lists/{list_id}/interest-categories/{interest_category_id}/interests
Example request body:
{
"list_id": "id_of_the_list",
"name": "name of the interest",
"display_order": 1
}
So the answer for your question is that I am pretty sure they just haven't created documentation for that one yet.

Google places api restaurant types

When you search for a restaurant in Google places and go to the business profile (i.e.:
https://plus.google.com/107507038669791289691/about?hl=en) the restaurant has a tag (in this case Mexican Restaurant). But when using the Google places api all I can see is a types list
"types" : [ "restaurant", "food", "establishment" ]
Anyone know if it's possible to get the tag "Mexican Restaurant" somehow?
I know about the supported types (https://developers.google.com/places/documentation/supported_types). It is not super helpful.
I was also working in a project which need to get more details about a place using Google Maps and Google Places APIs, and I really spent many hours trying to find something that can help ( Google Places API, Google Maps API, google+ APIs, ... ) but nothing ... the only things that I found is theses 2 issues ( feature requests ) which I hope that Google will add to their APIs someday :
Issue N° 5260 with 13 stars.
Issue N°7878 with 4 stars.
I hope with this SO question that we get more interested persons to get the feature in a soon future version of Google Map or Google Places APIs.
For the Google Places for Work API, I didn't find any information to confirm or not that it contains such feature, but I don't think so.
Hope that can help.
I think you would probably have to revert to the text search method on the api..
https://developers.google.com/places/documentation/search#TextSearchRequests
So your request would end up looking something like the below, restricted down to a specific area
https://maps.googleapis.com/maps/api/place/textsearch/json?query=Mexican+Restaurant&sensor=true&location=40.846,-73.938&radius=20&key=yourKeyHere
However this will return all other Mexican restaurants in the area, so if you just want to return the one result I would use the Place Details request instead.
Separate your place types by PIPE symbol "|"
try like this :
String types = "cafe|restaurant|museum" // Listing places only cafes, restaurants and museums.

Resources