I am using async method to generate the insights report. In order to get data from it, I am iterating over the results where it gives me 25 values at a time. How can I increase this limit?
More details:
Logs:
2017-03-30 09:27:41.926362 DEBUG 171:0 facebook.py:get_ads_insight insights type: <class 'facebookads.api.Cursor'>
2017-03-30 09:27:41.926979 DEBUG 176:0 facebook.py:get_ads_insight insights present: 25
Insights API facebook: https://developers.facebook.com/docs/marketing-api/insights/async/v2.8
Sample code:
from facebookads.adobjects.campaign import Campaign
from facebookads.adobjects.adsinsights import AdsInsights
from facebookads.adobjects.adreportrun import AdReportRun
import time
campaign = Campaign(<CAMPAIGN_ID>)
params = {
'level': AdsInsights.Level.campaign,
}
async_job = campaign.get_insights(params=params, async=True)
async_job.remote_read()
while async_job[AdReportRun.Field.async_percent_completion] < 100:
time.sleep(1)
async_job.remote_read()
time.sleep(1)
print(async_job.get_result())
2
Answers
You can pass parameters to
get_result()
, for example:async_job.get_result(params={'limit': '100',})
Add another entry for
limit
into yourparams
-dict (with declaringlimit = 0
or so before):