Which Google Client Cloud Library is used for Universal Analytics API

I’m rebuilding some python code to download UA data. I have previously used the Google API client library (https://pypi.org/project/google-api-python-client/) and specifically this code fragment from Google’s examples to create the analytics object for the report

from apiclient.discovery import build

def initialize_analyticsreporting():
  credentials = service_account.Credentials.from_service_account_file(

  # Build the service object
  analytics = build('analyticsreporting', 'v4', credentials=credentials)

  return analytics

The Google API Client documentation now says that they now recommend using Google’s Cloud Client Libraries for Python – which would be great as the API library is huge and ultimately this will end up as an AWS Lambda so space is at a premium.

The problem is I cannot find any documentation on which library (if any) I should be using for UA access.

Anyone have any pointers?

>Solution :

You should continue to use the Google apis python client library for accessing all google discovery services apis. Of which the google analytics reporting api is one of them.

All newer libraries that are not listed under the google apis discovery services apis can be found as part of the cloud libraries. For example to extract data from the from GA4 you will be using the google analytics data api. which falls under the cloud library.

So continue using the library you are now, until you want to extract data from ga4.

Leave a Reply