google analytics api - dateRanges limit in Core Reporitng API -


what maximum number of days can included in daterange when querying core reporting api v4? far i'm aware there no hardcoded limit, if query more 7 days api doesn't return results.

what mean that, given same query, when choose last 7 days range 20,000 records, when select last 180 days 256 records. i'm using exponential back-off algorithm avoid hitting quota limits. i'm using nextpagetoken access more result pages.

def _make_request(self, resource, customer_ids):     """send batch request corereporting api v4.     args:         resource: [googleapiclient.discovery.resource] service object         interracting corereporting api.         customer_ids: [list(<str>)] list of customer ids representing         countries want retrieve performance.     returns:         [namedtuple] query results.     """     query = {"reportrequests": [{         "pagesize": 10000,         "viewid": view_id,         "dateranges": [             {"startdate": "180daysago", "enddate": "yesterday"}         ],         "dimensions": [             {"name": "ga:date"},             {"name": "ga:adwordscustomerid"},             {"name": "ga:adwordscampaignid"},             {"name": "ga:adwordsadgroupid"},             {"name": "ga:adwordscriteriaid"},             {"name": "ga:admatchtype"},             {"name": "ga:admatchedquery"}         ],         "metrics": [             {"expression": "ga:adclicks"},             {"expression": "ga:adcost"},             {"expression": "ga:uniquepurchases"},             {"expression": "ga:itemrevenue"}         ],         "dimensionfilterclauses": [             {"filters": [                 {"dimensionname": "ga:adwordscustomerid",                  "operator": "in_list",                  "expressions": []}                 ]}             ],         "metricfilterclauses": [             {"filters": [                 {"metricname": "ga:adcost",                  "operator": "greater_than",                  "comparisonvalue": "0"}             ]}         ],         "orderbys": [             {"fieldname": "ga:adclicks",              "sortorder": "descending"}         ],         "pagetoken": "0",         "samplinglevel": "large"}     ]}     query.get('reportrequests')[0]['dimensionfilterclauses'][0]\             ['filters'][0]['expressions'] = customer_ids      # retrieve data api until new nextpagetoken provided     new_token = none     performance_data_list = []     while true:         response = resource.reports().batchget(body=query).execute()         performance_data_list.extend(response.get('reports')[0].\                 get('data').get('rows'))         new_token = response.get('reports')[0].get('nextpagetoken')         if not new_token:             break         # add nextpagetoken query body next request         query.get('reportrequests')[0]['pagetoken'] = new_token     unformatted_headers = response['reports'][0]['columnheader']      # unpack adtarget dimensions , metrics list of lists     adtargets_data = []     adtarget in performance_data_list:         adtarget_data = [*adtarget['dimensions'],                          *adtarget['metrics'][0]['values']]         adtargets_data.append(adtarget_data)     logging.info("processing historical data {} keywords".\                  format(len(adtargets_data)))      # create namedtuple output of query     headers = self._extract_headers(headers=unformatted_headers)     record = namedtuple("record", headers)     performance_tuple = map(record._make, adtargets_data)     return performance_tuple 

sorry ugly code. i'm working on refactoring it.

i'm opening question here because couldn't find answer in official documentation.


Comments