Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook graph API response size limiting (error code 1)

Just sharing some information I came across while testing my application.

Facebook Graph API implements rate limiting as described on their documentation page. Today I was trying to retrieve the feed from CNN facebook page and I got the following 500 error:

{"error":{"code":1,"message":"Please reduce the amount of data you're asking for, then retry your request"}}

This is the query I was trying to test:

https://graph.facebook.com/v2.3/5550296508/feed?fields=id,actions,application,caption,created_time,description,from,icon,is_hidden,link,message,message_tags,name,object_id,picture,place,privacy,properties,source,status_type,story,story_tags,to,type,updated_time,with_tags,shares,likes.limit(50),comments.filter(stream).limit(50){attachment,created_time,from,id,like_count,message,message_tags,comments{attachment,created_time,from,id,like_count,message,message_tags}}&access_token=xxxxxxx

like image 414
Dieghito Avatar asked Apr 19 '16 22:04

Dieghito


2 Answers

I tried to set different limit values to reduce the size, and eventually it worked. By inspecting the response size and playing around with it a bit, I found that the error is thrown when the response reaches (roughly) the 200k threshold.

I tested with Graph API versions 2.3 - 2.4 - 2.5 - 2.6

I found no documentation about this response size limit on the facebook APIs documentation, so it's possible that it will be changed in the future.

Just thought it might be useful to share if you are modelling something using their API.

like image 98
Dieghito Avatar answered Oct 20 '22 10:10

Dieghito


I originally misready the error message Please reduce the amount of data you're asking for, then retry your request and assumed I was getting rate-limited -- i.e. making too many API calls in a short time period. Thanks Dieghito for your answer, which helped me realize the error is about the response size.

In my case it was fetching /comments that was exceeding the response size limit. I had the limit set to 1000, which was fine for most posts. But for posts with a lot of lengthy comments, the response size grew too large. I had paging already setup, so simply requesting fewer comments per page (limit: 50 or 100) solved the problem for me. Just posting that here for people whose problem could be related to comments.

like image 26
Todd Price Avatar answered Oct 20 '22 09:10

Todd Price