Google Analytics API 要求一个名为 `analytics` 的变量?

Google Analytics API asks for a variable called `analytics`?

我正在使用 Google 分析 API 检索数据。在文档中 Google 指的是 analytics.

https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/filters/update

try:
  analytics.management().filters().update(
      accountId='123456',
      filterId='1223334444',
      body={
          'name': 'My Domain Filter',
          'type': 'EXCLUDE',
          'excludeDetails': {
              'field': 'GEO_DOMAIN',
              'matchType': 'EQUAL',
              'expressionValue': 'example.com',
              'caseSensitive': False
              }
      }
  ).execute()

上面有注释:

# Note: This code assumes you have an authorized Analytics service object.
# See the Filters Developer Guide for details.

analytics是服务对象吗?我从代码中的其他地方获取了变量 api_client

# The real code that initialized the client
    credentials = client.GoogleCredentials(access_token=access_token,
                                           refresh_token=refresh_token,
                                           client_id=client_id,
                                           client_secret=client_secret,
                                           token_uri=token_uri,
                                           token_expiry=token_expiry,
                                           user_agent=user_agent)

    # Initialize Http Protocol
    http = lib2.Http()

    # Authorize client
    authorized = credentials.authorize(http)

    # Let's build the client
    api_client = google_build(serviceName=api_name,
                              version=api_version, http=authorized)

没有成功。

您正在使用 API 管理,这是 configuration/account 管理。如果你想要 data/reports 使用报告 API。 https://developers.google.com/analytics/devguides/reporting/core/v4/