Google Search Console API not returning enough data

Refresh

April 2019

Views

172 time

1

https://developers.google.com/webmaster-tools/search-console-api-original/v3/searchanalytics/query

Google Analytics tells me ~20k pages were visited from Google search, but the Google Search Console API returns just under 5k urls. Changing startRow doesn't help.

What's really odd is I've connected Google Search Console to Google Analytics, and when viewing GSC data in GA (Acquisition -> Search Console -> Landing Pages) the GSC data there also gives me ~20k rows.

How do I get all ~20k rows out of the Google Search Console API?

date_str = '2017-12-20'
start_index = 0
row_limit = 5000
next_index = 5000
rows = []
while next_index == row_limit:
  req = webmasters_service.searchanalytics().query(
      siteUrl='https://tenor.com/',
      fields='responseAggregationType,rows',
      body={
          "startDate": date_str,
          "endDate": date_str,
          "searchType": search_type,
          "dimensions": [
              "page",
          ],
          "rowLimit": row_limit,
          "startRow": start_index,
      },
  )
  try:
      resp = req.execute()
      next_rows = resp['rows']
      rows += next_rows
      next_index = len(next_rows)
      start_index += next_index
  except Exception as e:
      print(e)
      break
return rows

0 answers