Google Ads Ad Manager API Client Library

0.9.0 · active · verified Tue Apr 14

This is an official Python client library for interacting with the Google Ad Manager API. It provides a programmatic interface to manage ad campaigns, inventory, and other Ad Manager features. The current version is 0.9.0 and it is part of the broader `googleapis/google-cloud-python` monorepo, which typically sees frequent updates, though this specific client's release cadence appears less frequent.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate the `NetworkServiceClient` and retrieve information about the current Ad Manager network. It assumes Application Default Credentials (ADC) are configured, typically via `GOOGLE_APPLICATION_CREDENTIALS` environment variable or `gcloud auth application-default login`.

import os
from google.ads.admanager_v202311.services.network_service import NetworkServiceClient

def get_admanager_network_info():
    try:
        # Authenticate using Application Default Credentials (ADC).
        # Ensure GOOGLE_APPLICATION_CREDENTIALS env var is set or gcloud is configured.
        # For Ad Manager, ensure your credentials have the necessary Ad Manager scope.
        client = NetworkServiceClient()

        # Get the current network.
        network = client.get_current_network()

        print(f"Current Ad Manager Network:")
        print(f"  Network Code: {network.network_code}")
        print(f"  Display Name: {network.display_name}")
        print(f"  Time Zone: {network.time_zone}")
        print(f"  Primary Ad Exchange Id: {network.primary_ad_exchange_id}")

    except Exception as e:
        print(f"An error occurred: {e}")
        # Consider detailed error handling based on API response codes.

if __name__ == '__main__':
    get_admanager_network_info()

view raw JSON →