how to increase freebase API result limit
Asked Answered
I

2

5

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.

Isoclinal answered 23/2, 2010 at 13:34 Comment(0)
R
8

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

Raddled answered 24/2, 2010 at 21:41 Comment(3)
Using their example I received the following message "Key cursor is a reserved word", doesn't seem to work anymore.Salient
This still works. The cursor goes on the envelope, not in the query itself (follow the link Peter provided to the documentation).Jadejaded
Ah! Thanks Peter, I was wondering how to get the cursor value in the response!Rosalynrosalynd
I
0

A coworker helped me figure this one out. I thought I should use the limit parameter but I didn't put it in the right place. Here's how it's done:

[{
  "type":"/base/popstra/celebrity",
  "name":null,
  "limit":300
}]
Isoclinal answered 23/2, 2010 at 14:32 Comment(1)
You should really update your OP or comment on it, instead of providing an answer!Ling

© 2022 - 2024 — McMap. All rights reserved.