How can I filter statistics from facebook ads api using the python sdk?
Question: I would like to filter by data ranges, just to see the performance on a daily
basis, or for the last day, last week, last month...etc.

How can I add a date parameter different from start_date or end_date because?
I guess those parameters are just only for the start and end date of the
campaign but they might not give me the result I want.

My current code is this one:

    
    
    from facebookads.api import FacebookAdsApi
    from facebookads import objects
    
    my_app_id = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    my_app_secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    my_access_token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    FacebookAdsApi.init(my_app_id, my_app_secret, my_access_token)
    
    me = objects.AdUser(fbid='10153166606850429')
    my_accounts = list(me.get_ad_accounts())
    
    
    my_account = objects.AdAccount('act_XXXXXXXXXXXX')
    
    params = {
    'start_date': '2015-02-01',
    }
    fields = {
    'impressions',
    'clicks',
    'spent',
    }
    
    stats = my_account.get_ad_campaign_stats(fields=fields, params=params)
    
    # print stats
    for stat in stats:
        print stat
    


Answer: According to the docs [here](https://developers.facebook.com/docs/marketing-
api/adstatistics/v2.2#filtering), It looks like you have the field name wrong.

The API lists `start_time` and `end_time` but also mentions you should have
both a start and end.

    
    
    params = {
        'start_time': '2015-02-01',
        'end_time': '2015-02-02',
    }
    

Hope this helps!

