Niv
Niv

Reputation: 2312

The limit of Facebook's graph api "limit" parameter

I'm fetching a large amount of comments from a public page using Facebook's Graph API.
By default facebook returns 25 comments per response, and uses paging. This causes the need for multiple requests, which is uneccesery as I know ahead there will be a lot of comments.

I read about the "limit" parameter that you can pass to ask for a certain amount of items per response.

I was wondering, what is the limit of that parameter? I'm assuming I can't pass &limit=10000.

Upvotes: 18

Views: 40826

Answers (5)

Steven Buehler
Steven Buehler

Reputation: 26

Old question, but this is in the current Facebook documentation in case anyone finds this question via search (emphasis mine):

Some edges may also have a maximum on the limit value for performance reasons. In all cases, the API returns the correct pagination links.

In other words, even if you specify a limit above what's allowed by the endpoint, the "pagination.previous" and "pagination.next" elements will always provide the correct URL to resume where it left off.

Upvotes: 1

user3233199
user3233199

Reputation: 41

I think they have changed this. For /feed? I only get 200-225 posts back but for comments I get as many as 2000 back

Upvotes: 1

Andreas Lundberg
Andreas Lundberg

Reputation: 109

I would recommend you to use FQL instead.

FQL provide a more flexible approach where you can combine data types (posts, users, pages, etc..) as you please. You can also query for comments belonging to a list of stories instead of just one limiting your number of requests even more.

There are a couple of drawbacks though:
1. There is a limit on 5000 comments. Here you would use a query looking something like: "SELECT id, ...... FROM comments, ... WHERE parent_id in (1,2,3....) ORDER BY time LIMIT 0, 5000". Even though you split this up in several queries with "LIMIT 0, 1000", "LIMIT 1000, 1000", LIMIT 2000, 1000, etc.., you would never get anything over 5000 comments("LIMIT 5000, 1000" would return empty).
2. All real requests made on Facebooks server counts as one request. You can send of something that is actually a combination of requests, this will be counted as multiple requests.
3. Facebook does not like to heavy requests. You can end up with getting blocked for a shorter time periods(minutes -> hours, not days). If this happens, act on it.

Upvotes: -1

twonkeys
twonkeys

Reputation: 551

There's a different way for fetching comments:

https://graph.facebook.com/<PAGE_ID>_<POST_ID>/comments?limit=500

The maximum value for the limit parameter is 500.

Upvotes: 13

Smita
Smita

Reputation: 4634

yes, with limit parameter you can pass what number of certain resource you want in one call. default limit is 25.

for ex. if you want 100 comment in one call for a post having id POST_ID, you can query like this:

https://graph.facebook.com/POST_ID?fields=comments.limit(100) 

Upvotes: 9

Related Questions