Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to increase freebase API result limit

Tags:

api

freebase

I can't find anything in freebase's docs about it but it seems they limit the number of results to 100. For example:

[{
  "type":"/base/popstra/celebrity",
  "name":null
}]

Returns only 100 results whereas

[{
  "type":"/base/popstra/celebrity",
  return:"count"
}]

Says there are 6244 results. Does anyone know how to get the rest of them? I know I can limit the queries by some parameter like country and then aggregate the results but I'd prefer something less hacky.

like image 244
Johnny Avatar asked Feb 23 '10 13:02

Johnny


1 Answers

You can use the limit property to request more results. However, fetching large numbers can give you a query timeout.

A more reliable way is to use the cursor property. Pass in a cursor value of true. You'll get a batch of results, but you'll also get a new value for cursor in the response. Repeat your query, but substitute in the new cursor value to get the next batch of results. In this way you can fetch even a very large set of data.

More info: http://www.freebase.com/docs/mql/ch04.html#envelopeparameters

like image 116
Peter Burns Avatar answered Oct 29 '22 02:10

Peter Burns