Skip to content

Instantly share code, notes, and snippets.

@olitomas
Created May 5, 2019 17:00
Show Gist options
  • Save olitomas/447e48cca1d5e85e3aaac9fad33efa84 to your computer and use it in GitHub Desktop.
Save olitomas/447e48cca1d5e85e3aaac9fad33efa84 to your computer and use it in GitHub Desktop.
from facebook_business.adobjects.adaccount import AdAccount
from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.adset import AdSet
from facebook_business.adobjects.adsinsights import AdsInsights
import arrow
my_access_token = 'xxx'
my_app_id = 'xxx'
my_app_secret = 'xxx'
FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
my_account = AdAccount('xxx')
fields = [
'impressions',
'spend',
'conversions'
]
params = {
'time_ranges': [
{'since': '2019-05-05', 'until': '2019-06-06'}
]
}
def get_insights():
return insights = my_account.get_insights(fields=fields, params=params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment