Scipion
Scipion

Reputation: 11888

Simple request using googleapis to freebase

I would like to query freebase, to get some basic information about a celebrity. For example, I would like to get the place of birth, and the gender of Madonna.

I achieved to get Madonna's friends by using:

https://www.googleapis.com/freebase/v1/mqlread?&query={"id":"/en/madonna","name":null,"type":"/base/popstra/celebrity","/base/popstra/celebrity/friendship":[{"participant":[]}]}

But, I'm understanding this request pretty badly. How can I change it to get the information I talked above ?

I was thinking about :

https://www.googleapis.com/freebase/v1/mqlread?&query={"id":"/en/madonna","name":null,"type":"/base/popstra/celebrity","/base/popstra/celebrity/gender":[{"gender":}], "/base/popstra/celebrity/place_of_birth":[{"place of birth":}]}

but it's not working ofc.

Upvotes: 1

Views: 424

Answers (1)

Shawn Simister
Shawn Simister

Reputation: 4603

Here is how you build MQL queries for Freebase topics:

  1. Find a sample topic that meets you query (ex. Madonna)
  2. Go the the Query Editor and build a simple query for the ID of that topic:

    [{ "id": "/en/madonna", "name": null }]​

  3. Go to the sample topic page, click on "Edit this topic" and find the facts that you want to query for (ex. Date of birth)

  4. You can see that Date of birth is part of the Person (/people/person) type.
  5. Click on little wrench icon to the right of Person to go to the schema page for that type.
  6. From there, you can see that the property that stores the date of birth is called /people/person/date_of_birth.
  7. Add the properties that you want to your query like so:

    [{ "id" "/en/madonna", "name": null, "/people/person/date_of_birth": null, "/people/person/gender": null }]​

  8. Queries can also specify a default type (ex. /people/person) which makes the property paths shorter:

    [{ "id" "/en/madonna", "name": null, "type": "/people/person", "date_of_birth": null, "gender": null }]​

  9. But each level of query can only have one default type so if you want to mix in properties from other types you'll need to use the full property IDs:

    [{ "id": "/en/madonna", "name": null, "type": "/people/person", "date_of_birth": null, "gender": null, "/base/popstra/celebrity/friendship": [{ "participant": [] }] }]​

  10. When you've got your query working in the query editor, just click the "Link" menu at the top right to get the MQLRead Link that will make that query to our API.

Upvotes: 3

Related Questions