0

Does anyone know the main difference between AdInsights Vs. Ad Account-Level Rate Limit? Can I use AdInsights to get metrics from specific ads? If yes, does anyone know what would be the syntax? I notice in the Dashboard that AdInsights is calculated based on calls, am I reading this correctly?

Right now I'm importing:

from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.ad import Ad
from facebook_business.adobjects.campaign import Campaign
from facebook_business.adobjects.adaccount import AdAccount

And using:

insights = str(Ad(ad).get_insights(
                    params=kwargs['params'],
                    fields=kwargs['fields']))

This works, but I'm hitting limits very quickly so I had to add a sleep(300) to let the rate "cool-off"

The overall plan is to loop through all AdAccounts (4 in total), and grab all ACTIVE ad insights. As you can imagine, this can be up to 2K+ different ads.

Any suggestions?

Thank you in advance!

CJL89
  • 105
  • 2
  • 15
  • This question (https://stackoverflow.com/questions/47834523/facebook-marketing-api-python-to-get-insights-user-request-limit-reached?noredirect=1&lq=1) has a similar issue like mine. Their workaround was to check the rate limit, but I'm having trouble implementing the check function. This might help, but is not ideal since I'm still having to implement a sleep function; even though it'll be more accurate since I can directly check the rate limit rather than having a default sleep(250). – CJL89 Jul 05 '21 at 21:27

1 Answers1

0

Just a note, my mistake was to get all ads from the campaign and loop through each id individually, which creates an unnecessary amount of calls. By just passing the AdAccounts, grab campaign ids, and then grab the ids of the ads that are within those campaigns; you can by pass the limit 1000 (assuming there are no more than 1K ads in that campaign) and also avoid the rate limits.

CJL89
  • 105
  • 2
  • 15