skip to Main Content

I’m working on a project which provide businesses to manage their facebook page, thus it will have tons of api call to Facebook. Is that possible to increase the rate limit by special request?

3

Answers


  1. No, there is no way to increase the limits by special request. If you really hit the limits, you are most likely doing something you are not supposed to. It is no problem to let businesses manage their FB Page with their own Page Token.

    Login or Signup to reply.
  2. Actually this is now possible…

    1. Go to your Facebook App Developer Dashboard
    2. Scroll down to Application Level Rate Limiting
    3. Click Request for Rate Increase
    4. Fill out the request advising why you require the rate increase

    Facebook App Developer Dashboard

    API Limit increase request

    Login or Signup to reply.
  3. 2022 Update :

    Looks like there’s no way to increase limits for your app :

    Based on Facebook best practices and on
    Goutham answer

    1 – When the limit has been reached, stop making API calls. Continuing to make calls will continue to increase your call count, which will increase the time before calls will be successful again.

    2 – Check the X-Business-Use-Case-Usage HTTP header to see how close your ad account is to its limit and when you can resume making calls.

    3 – Verify the error code and API endpoint to confirm the throttling type.

    4 – Switch to other ad accounts and come back to this account later.

    5 – It is better to create a new ad than to change existing ones.

    6 – Spread out queries evenly between two time intervals to avoid sending traffic in spikes.

    7 – Use filters to limit the data response size and avoid calls that request overlapping data.

    Personally, I have developed this little snippet to never reach the limit but I can make your execution extremely long. (it’s C#)

        private void TrySleepIfApiLimitIsClose(HttpResponseMessage response)
        {
            try
            {
                IEnumerable<string> businessUsage = response.Headers.FirstOrDefault(header => header.Key == "x-business-use-case-usage").Value;
                IEnumerable<string> appUsage = response.Headers.FirstOrDefault(header => header.Key == "x-app-usage").Value;
                IEnumerable<string> adAccountUsage = response.Headers.FirstOrDefault(header => header.Key == "x-ad-account-usage").Value;
                IEnumerable<string> insightsUsage = response.Headers.FirstOrDefault(header => header.Key == "x-fb-ads-insights-throttle").Value;
    
                if (businessUsage != null)
                {
                    IEnumerable<FacebookBusinessUseCaseUsage> usages = JsonConvert.DeserializeObject<IEnumerable<FacebookBusinessUseCaseUsage>>($"[{Regex.Match(businessUsage.First(), @"[.{1,}]").Groups[0].Value.Replace("[", string.Empty).Replace("]", string.Empty)}]");
    
                    foreach (var usage in usages)
                    {
                        if (usage.CallCount >= 80 ||
                            usage.TotalCpuTime >= 80 ||
                            usage.TotalTime >= 80)
                            Delay();
                    }
                }
    
                if (appUsage != null)
                {
                    FacebookBusinessUseCaseUsage usage = JsonConvert.DeserializeObject<FacebookBusinessUseCaseUsage>(appUsage.First());
    
                    if (usage.CallCount >= 80 ||
                        usage.TotalCpuTime >= 80 ||
                        usage.TotalTime >= 80)
                        Delay();
                }
    
                if (adAccountUsage != null)
                {
                    int usage = int.Parse(Regex.Match(adAccountUsage.First(), @"d{1,}").Groups[0].Value);
    
                    if (usage >= 80)
                        Delay();
                }
    
                if (insightsUsage != null)
                {
                    FacebookAdInsightsThrottle usage = JsonConvert.DeserializeObject<FacebookAdInsightsThrottle>(insightsUsage.First());
    
                    if (usage.AppIdUtilPct >= 80 || usage.AccIdUtilPct >= 80)
                        Delay();
                }
            }
            catch { }
        }
    

    Delay a few minutes :

    private void Delay() => Thread.Sleep(1000 * 200);
    

    Note that I swallow the exception because I don’t want to break my execution, in my case it’s better to reach the limit than break the execution. Also be careful with Thread.Sleep you have to consider your context (multi-thread ? async ? … ).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search