title: Filtering statistics from facebook ads api using the python sdk
body: <p>I am trying to use Facebook's ads-api to get data about advertising accounts/campaigns/etc within a specified time range.</p>
  
  <p>Up until now I managed to get overall information (added below) using the official python sdk , 
  but I can't figure out how to insert the time filter condition.</p>
  
  <p>The answer is probably here under "Filtering results", but I don't understand how to translate what they are doing there to python...
  <a href="https://developers.facebook.com/docs/reference/ads-api/adstatistics/v2.2" rel="nofollow">https://developers.facebook.com/docs/reference/ads-api/adstatistics/v2.2</a></p>
  
  <p>I would really appreciate any help you can provide,</p>
  
  <p>Thanks!</p>
  
  <hr>
  
  <p>This is the relevant module (I think) from the official python sdk project:
  <a href="https://github.com/facebook/facebook-python-ads-sdk/blob/master/facebookads/objects.py" rel="nofollow">https://github.com/facebook/facebook-python-ads-sdk/blob/master/facebookads/objects.py</a></p>
  
  <p>My current code is:</p>
  
  <pre><code>from facebookads.session import FacebookSession
  from facebookads.api import FacebookAdsApi
  from facebookads import objects
  from facebookads.objects import (
  AdUser,
  AdCampaign,
  )
  
  my_app_id = 'APP_ID'
  my_app_secret = 'AP_SECRET'
  my_access_token = 'ACCESS_TOKEN'
  my_session = FacebookSession(my_app_id, my_app_secret, my_access_token)
  my_api = FacebookAdsApi(my_session)
  FacebookAdsApi.set_default_api(my_api)
  
  me = objects.AdUser(fbid='me')
  my_accounts = list(me.get_ad_accounts())
  
  
  my_account=my_accounts[1]
  
  print("&gt;&gt;&gt; Campaign Stats")
  for campaign in my_account.get_ad_campaigns(fields=[AdCampaign.Field.name]):
      for stat in campaign.get_stats(fields=[
          'impressions',
          'clicks',
          'spent',
          'unique_clicks',
          'actions',
      ]):
          print(campaign[campaign.Field.name])
      for statfield in stat:
          print("\t%s:\t\t%s" % (statfield, stat[statfield]))    
  </code></pre>
  
  <p>and the output I get is (All caps and xxxx are mine):</p>
  
  <pre><code>Campaign Stats
  CAMPAIGN_NAME1
      impressions:        xxxx
      unique_clicks:      xxxx
      clicks:     xxxx
      actions:        {u'mobile_app_install': xxxx, u'app_custom_event': xxxx,   u'app_custom_event.fb_mobile_activate_app': xxx}
      spent:      xxxx
  CAMPAIGN_NAME2
      impressions:        xxxx
      unique_clicks:      xxxx
      clicks:     xxxx
      actions:        {XXXX}
      spent:      xxxx
  </code></pre>