Google Knowledge Graph API Usage - google-api

I'd like to clarify how to use the Google knowledge graph API to obtain more specific information about an entity, such as the height or birthday of a person.
For instance, the documentation provides the following search for Taylor Swift:
https://kgsearch.googleapis.com/v1/entities:search?query=taylor+swift&key=API_KEY&limit=1&indent=True
This request returns some basic information, such as description, name, type, and id. However, the documentation sadly does not explain how to query specific properties for that person (even though the Person schema certainly contains that information).
I've tried changing the "query" value to "taylor+swift+birthday" but that returns something completely unrelated. I've also tried searching by the returned "id" (/m/0dl567 for the above example) but that doesn't give any extra information.
Some guidance on how to use the API in this way would be much appreciated! If however it's not possible to do this, what would be the best alternative?
Thanks!

According to the Knowledge Graph Search API reference, information such as height or DOB is not included in the response.
The most reliable source of such information currently is Wikidata. Using the Wikidata Query Service, you can query the data you need for the entity with the given Freebase ID or Google Knowledge Graph ID:
SELECT ?item ?itemLabel ?birthdate
WHERE
{
?item wdt:P646 "/m/0dl567".
?item wdt:P569 ?birthdate .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Related

Graph API filter

how to recreate this LINQ:
applications.Where(x => x.Owners.Any(y=>y.Id == "user_object_id"));
to Graph API filter string, something like
graphServiceClient.Applications.Request().Filter("Owners/any(x:x/Id eq 'user_object_id'")).GetAsync();
If you haven't used the Graph Explorer I highly recommend it to test queries. You can use it on your own data.
For your query I would start here with GET /applications
From there you can filter with something like displayName or in your case, userID:
GET https://graph.microsoft.com/v1.0/applications?$filter=startswith(displayName, 'a')&$count=true&$top=1&$orderby=displayName
ConsistencyLevel: eventual
Please let me know if you have any questions or are stuck and I can help you further!
Best,
James

Get a list of all author IDs for a given given university with pybliometrics

I am trying to get the complete list of author IDs associated with a given University.
I tried to do it from the Scopus web page but my request exceeded the allowed quota.
Any possible solution for this?
You'd use the AuthorSearch class for that. Scopus hides the documentation for this API here, so it's a bit tricky to find all the allowed fields.
What you want is the key "AF-ID":
from pybliometrics.scopus import AuthorSearch
q = "AF-ID(60105007)"
s = AuthorSearch(q)
print(s)
The results are in s.authors.

Google Books API - Book Details not Returned

So I started using the Google Books API for an application that I am building and I am fairly happy with the results.
But I have noticed a strange behaviour sometimes. Some ISBNs do not return any book details even though the book exists in the database.
For example, if I give: https://www.googleapis.com/books/v1/volumes?q=isbn:0262527359,I get the following response:
{
"kind": "books#volumes",
"totalItems": 0
}
I digged around the internet regarding this problem and found this link:
https://productforums.google.com/forum/#!topic/books-api/R5DvlRh-EKo
They suggest a workaround by not mentioning isbn: in the search query. So, the query becomes: https://www.googleapis.com/books/v1/volumes?q=0262527359
This method is not perfect but it's the only workaround I found.
That's when I noticed another problem. There is a mismatch between the description given on the webpage and the one in the response to the API call.
Can someone explain these strange behaviours to me? Are there any better solutions?
So i did some digging around and found out about this strange behaviour, when your query is of the form ...?q=isbn:0262527359, the results you get are the books that have this same isbn only and when you use the query of the form ...?q=0262527359, the results you get are the books that have any instance of this number in the record fields of any book. It can be either in editions isbn array or any other, this query will search all fields for matching results whereas the former query will only search isbn for matching results

iOS Mapkit, identifying "type of business"

I've looked through numerous answers (most were slightly outdated), and I was wondering if Apple had some sort of way to identify the type of business it queried?
From the reference guide, MKMapItem has 5 variables, none of which tell me a place is a "Thai Restaurant" or something like that.
placemark
isCurrentLocation
name
phoneNumber
url
I think its interesting how when you do a MKMapkit query on "thai", it'll give you a list of thai restaurants but thats a one way street and no where later can I take a result from the query on "thai" to verify that it is indeed a "thai" restaurant. More importantly, what I am particularly interested in is if a business is a "Thai" restaurant and a "Bar" as well, I want to be able to do a MKMapKit query on "Bar" OR "Thai" and be able to get both of those tags
I can see a solution of getting the coordinates of a business then using Google Maps API or even Yelp API and doing a search on there to get the "type of business" but that seems extremely cumbersome and inefficient.
Thanks for any advice! One of my first questions so please so easy on me =)
First, take a look with this link : http://www.raywenderlich.com/13160/using-the-google-places-api-with-mapkit
The google API will send back the name, type, location of business location near you.
It's also send icons(via image link) of business location, so you can display it on the map, which can help you which is market, which is coffeeshop...
But the "Thai Restaurant" maybe too detail so google doesn't want to show it.
Sorry about my bad english.
Hope it help.
For that you should use google near by place search or place search api. you can pass thailand as place name and restaurant to type and it will return you all the restaurant in thailand.

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