Facebook Rate limit solutions - facebook

Im trying to create ads in facebook using python sdk. (15000 ads to be exact)
Im hiting rate limit after I create 10 ads (i.e 10 create-ad requests)
I tried putting delay between each request. (1 second delay)
The error im getting is:
message':
'Calls to this api have exceeded the rate limit.', 'code': 613, 'error_subcode': 1487742
Do you know what delay I should put. Or better, what I should do to avoid rate limit.
It'll be very helpfull to know any experience on this.

Related

Is there a rate limit for using Facebook Ad Library API?

I'm using Facebook Ad Library API but I can't figure out how rate limit works.
On the application dashboard under "Application-Level Rate Limiting" the chart is always showing zero calls and when I make a new API call the header just shows this (the 'call_count' field is missing):
{
'total_time' : 0,
'total_cputime' : 0
}
I've read on a report by Mozilla developers that there is a rate limit (they were blocked a few times), someone can help?
Thanks
I was running into a similar issue and worked out the following solution:
You can see the current usage of your rate limit for the Ad Library API by looking at the "object_count_pct" in the header. API calls are blocked once it reaches a value of 100 (%).
Avoiding the limit is then possible by pausing calls at a certain percentage until the object_count_pct goes down again. You can also build your API calls so that they use the "estimated_time_to_regain_access" value to restart the calls after Facebook unblocks your app.
Unfortunately I could not find any documentation regarding the actual rate limit or at what speed the object_count_pct goes down once calls to the API are halted. The 200 calls per hour as stated in the official docs is definitively not accurate as I have managed to make over 5.000 calls in ca. 8 hours.

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
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.
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.

In Facebook Graph API - Is LIMIT parameter realy functional?

I'm trying to collect all the posts of my company page with this kind of query
https://graph.facebook.com/v2.2//feed?limit=250&fields=id,type,status_type,comments{id},likes{id},shares
Problem is that I'm not collecting all posts.
I will have a better result with limit=20 and some time with limit=100
Most of the pages (from the pagination mechanism point of view) will not have 100 items.
I know some posts may not be exposed because of privacy settings.
My issue is that a call with limit=20 is not returning once going through pagination the same amount of data as limit=250.
How could it be?
How providers of Facebook Analytics can garanty the quality of data they collect ?
The Facebook graph api only allow the max of 100 items per request, despite you specify more than that.
Afaik the limit parameter is indeed buggy. But 250 would be a very high value, there is a max value for the parameter too - i assume it depends on the API call how high it is, could be fixed too.
Better donĀ“t use limit at all and use paging to get more results: https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2#paging

Facebook FQL posts limit issue

Currently i am using following FQL query :-
https://api.facebook.com/method/fql.query?query=select post_id,likes FROM stream WHERE source_id=XXXXXXXX LIMIT 0,10000&access_token=XXXXXXXXXXXXX&format=json
I have two Facebook Accounts / pages & able to download data using above API. Able to retrieve posts & post likes count.
But, from last three days, for one Facebook account above FQL query is not working. it is returning message :- "error": "Request failed" . For other account it is working fine.
For each facebook Account / pages i have generated separate Access Tokens.
But, if i update limit from : -
Limit 0,50
Limit 50,100
then it is working & returning posts from page but not returning all post which i have previously getting from Limit 0,10000
Please help me, if any one have idea about this issue ?
Thanks
Facebook will cancel queries which take too long or too many resources to execute. In general, I would never use LIMITs which are that high. There's a high probability that they will fail, and you can't really incfuence the query execution "load" other than setting the LIMIT to a reasonable number (which means implementing a paging mechanism).

restfb: encountering 504 while uploading video sized 950 mb

Using restfb-1.6.12
Creating client as:
facebookClient = new DefaultFacebookClient(accessToken, new CustomWebRequestor(), new DefaultJsonMapper());
In CustomWebRequestor, customizeConnection() is overridden and following is specified:
connection.setChunkedStreamingMode(5242880);
Uploading video as:
facebookClient.publish("me/videos", FacebookType.class, BinaryAttachment.with(mediaFileName, mediaFileStream), Parameter.with("description", msg), Parameter.with("target_id", "me"), Parameter.with("metadata", 1));
Encountering following:
com.restfb.exception.FacebookNetworkException: A network error occurred while trying to communicate with Facebook: Facebook request failed (HTTP status code 504)
at com.restfb.DefaultFacebookClient.makeRequestAndProcessResponse(DefaultFacebookClient.java:625)
Upload happens as I can find the video on Facebook, but the reponse received from API doesn't tell me so. API works for videos of lesser size, like 400-500 MB. Recent change log doesn't mention any change around this either. Some help please.
Have you had a look at https://developers.facebook.com/docs/graph-api/reference/v2.0/user/videos#publish
There, Facebook states that
Videos must be encoded as multipart/form-data and published to
graph-video.facebook.com instead of the regular Graph API URL.
Also, other rules are
The aspect ratio of the video must be between 9x16 and 16x9, and the
video cannot exceed 1024MB or 180 minutes in length
Does RestFB use the correct endpoint?
Facebook fixed the problem under bug developers.facebook.com/bugs/791781120839901