title: How do I create a GOOGLE API script to pull data by the hour?
body: <p>Essentially what I want to do is run this script every hour to pull in data from the last hour only and then the script will run again an hour later.  I want this script to pull all data associated with that last hour and then onwards for every hour of the day. How would I do this as I am only seeing a filter that can do this but I have read that it will only pull a sample and then filter on the hour from that sample.</p>
  
  <pre><code>   def get_report(analytics):
  
         return analytics.reports().batchGet(
            body={
                'reportRequests': [
                 {
                 '    viewId': VIEW_ID,
                         'dateRanges': [{'startDate': 
                                        '1dayAgo','endDate':'today'}],
       'metrics': [{'expression': 'ga:uniquepageviews'},
                      {'expression': 'ga:timeonpage'},
                      {'expression': 'ga:entrances'},
                      {'expression': 'ga:exits'},
                      {"expression": "ga:pageviews"}
                      ],
        'dimensions': [{'name': 'ga:dimension97'},
                      {'name': 'ga:dimension69'},
                      {'name': 'ga:dateHourMinute'},
                      ]
  
                     }]
              }
          ).execute()
  </code></pre>