Google Ads API Client Library for Python

repository·main·Indexed 20 days ago

https://github.com/googleads/google-ads-python

A Python client library (version 31.2.0) for the Google Ads API. It provides the GoogleAdsClient for managing credentials, authentication, and accessing API services and types. The library supports multiple transport protocols including gRPC (synchronous and asynchronous) and REST, and includes specialized service clients such as AccountBudgetProposalServiceClient and CampaignBudgetService.

Tokens
44.2K
Snippets
26
Records
187
Agent score
71%

What's inside google-ads-python

  1. Understand the AdGroupAdLabelService transport inheritance structure

    main

    The AdGroupAdLabelService uses a specific inheritance hierarchy to support different communication protocols (gRPC vs. REST) and execution models (Synchronous vs. Asynchronous). When choosing a transport, select the class that matches your required protocol and concurrency model.

    Available Transports

    • gRPC (Synchronous): Use AdGroupAdLabelServiceGrpcTransport for standard synchronous gRPC calls. Defined in grpc.py.
    • gRPC (Asynchronous): Use AdGroupAdLabelServiceGrpcAsyncIOTransport for non-blocking asynchronous gRPC calls using asyncio. Defined in grpc_asyncio.py.
    • REST (Synchronous): Use AdGroupAdLabelServiceRestTransport for standard synchronous REST calls. Defined in rest.py. This class uses METHOD inner classes derived from the private _BaseMETHOD classes.
    • REST (Base/Internal): _BaseAdGroupAdLabelServiceRestTransport serves as the base for REST implementations and is not intended for direct public use. It is defined in rest_base.py.
  2. Understand the AdGroupLabelService transport inheritance structure

    main

    The AdGroupLabelService uses a hierarchy of transport classes to handle different communication protocols (gRPC vs REST) and execution models (Synchronous vs Asynchronous).

    • AdGroupLabelServiceTransport: The Abstract Base Class (ABC) that defines the interface for all transports.
    • gRPC Transports:
      • AdGroupLabelServiceGrpcTransport: Used for synchronous gRPC communication (defined in grpc.py).
      • AdGroupLabelServiceGrpcAsyncIOTransport: Used for asynchronous gRPC communication (defined in grpc_asyncio.py).
    • REST Transports:
      • AdGroupLabelServiceRestTransport: The public class for synchronous REST communication (defined in rest.py). It uses METHOD inner classes derived from the base implementation.
      • _BaseAdGroupLabelServiceRestTransport: A private base class for REST transports that provides the underlying logic via _BaseMETHOD inner classes (defined in rest_base.py).
  3. Understand the ProductLinkInvitationService transport hierarchy

    main

    The ProductLinkInvitationService uses a transport inheritance structure to support different communication protocols (gRPC vs REST) and execution models (Synchronous vs Asynchronous).

    • gRPC (Synchronous): Use ProductLinkInvitationServiceGrpcTransport for standard synchronous gRPC calls.
    • gRPC (Asynchronous): Use ProductLinkInvitationServiceGrpcAsyncIOTransport for asynchronous gRPC calls using asyncio.
    • REST (Synchronous): Use ProductLinkInvitationServiceRestTransport for standard synchronous REST calls.

    Note that _BaseProductLinkInvitationServiceRestTransport and its inner class _BaseMETHOD are private base classes used to implement the REST logic.

  4. Understand the KeywordPlanAdGroupService transport inheritance structure

    main

    The KeywordPlanAdGroupService uses a transport inheritance hierarchy to support different communication protocols (gRPC vs. REST) and execution models (Synchronous vs. Asynchronous).

    • gRPC Transports: Used for high-performance communication via gRPC.
      • KeywordPlanAdGroupServiceGrpcTransport: Public class for synchronous gRPC operations (defined in grpc.py).
      • KeywordPlanAdGroupServiceGrpcAsyncIOTransport: Public class for asynchronous gRPC operations (defined in grpc_asyncio.py).
    • REST Transports: Used for standard HTTP/REST communication.
      • KeywordPlanAdGroupServiceRestTransport: Public class for synchronous REST operations (defined in rest.py). It uses METHOD inner classes derived from the base REST implementation.
      • _BaseKeywordPlanAdGroupServiceRestTransport: A private base class for REST transports that defines the core logic and _BaseMETHOD inner classes (defined in rest_base.py).
  5. Understand the transport inheritance structure for ConversionValueRuleSetService

    main

    The ConversionValueRuleSetService uses a hierarchical transport structure to support different communication protocols (gRPC vs. REST) and execution models (Synchronous vs. Asynchronous).

    Depending on your requirements, you can choose from the following transport implementations:

    • gRPC (Synchronous): Use ConversionValueRuleSetServiceGrpcTransport for standard synchronous gRPC calls.
    • gRPC (Asynchronous): Use ConversionValueRuleSetServiceGrpcAsyncIOTransport for non-blocking asynchronous gRPC calls using asyncio.
    • REST (Synchronous): Use ConversionValueRuleSetServiceRestTransport for standard synchronous REST calls. This implementation uses METHOD inner classes for API operations.

    All transports inherit from the abstract base class ConversionValueRuleSetServiceTransport.

  6. Understand the CustomerManagerLinkService transport inheritance structure

    main

    The CustomerManagerLinkService uses a hierarchical transport structure to support different communication protocols (gRPC vs. REST) and execution models (Synchronous vs. Asynchronous).

    • CustomerManagerLinkServiceTransport: The Abstract Base Class (ABC) that defines the interface for all transports.
    • gRPC Transports:
      • CustomerManagerLinkServiceGrpcTransport: Use this for synchronous gRPC communication (defined in grpc.py).
      • CustomerManagerLinkServiceGrpcAsyncIOTransport: Use this for asynchronous gRPC communication (defined in grpc_asyncio.py).
    • REST Transports:
      • CustomerManagerLinkServiceRestTransport: Use this for synchronous REST communication (defined in rest.py). It uses METHOD inner classes derived from the base REST implementation.
      • _BaseCustomerManagerLinkServiceRestTransport: A private base class for REST transports that defines the core logic and _BaseMETHOD inner classes (defined in rest_base.py).
  7. Understand the BrandSuggestionService transport inheritance structure

    main

    The BrandSuggestionService uses a hierarchical transport structure to support different communication protocols (gRPC vs. REST) and execution models (Synchronous vs. Asynchronous).

    • gRPC (Synchronous): Use BrandSuggestionServiceGrpcTransport for standard synchronous gRPC calls. It is defined in grpc.py.
    • gRPC (Asynchronous): Use BrandSuggestionServiceGrpcAsyncIOTransport for non-blocking asynchronous gRPC calls using asyncio. It is defined in grpc_asyncio.py.
    • REST (Synchronous): Use BrandSuggestionServiceRestTransport for standard synchronous REST calls. It is defined in rest.py and uses METHOD inner classes derived from the base REST implementation.
    • REST (Base/Internal): _BaseBrandSuggestionServiceRestTransport serves as the private base for REST implementations, defining _BaseMETHOD classes in rest_base.py.
  8. Understand the CustomerLifecycleGoalService transport inheritance structure

    main

    The CustomerLifecycleGoalService uses a transport inheritance hierarchy to support different communication protocols (gRPC vs. REST) and execution models (Synchronous vs. Asynchronous).

    Depending on your application's requirements, you should choose one of the following public transport implementations:

    • Synchronous gRPC: Use CustomerLifecycleGoalServiceGrpcTransport for standard synchronous gRPC calls (defined in grpc.py).
    • Asynchronous gRPC: Use CustomerLifecycleGoalServiceGrpcAsyncIOTransport for non-blocking asynchronous gRPC calls using asyncio (defined in grpc_asyncio.py).
    • Synchronous REST: Use CustomerLifecycleGoalServiceRestTransport for standard synchronous REST calls (defined in rest.py). This implementation uses METHOD inner classes derived from the base REST implementation.

    Note that CustomerLifecycleGoalServiceTransport serves as the Abstract Base Class (ABC) for all these implementations, and _BaseCustomerLifecycleGoalServiceRestTransport is a private base class used for REST logic.

  9. Understand the CampaignAssetSetService transport inheritance structure

    main

    The CampaignAssetSetService uses a hierarchical transport structure to support different communication protocols (gRPC and REST) and execution models (synchronous and asynchronous).

    • CampaignAssetSetServiceTransport: The Abstract Base Class (ABC) that defines the interface for all transports.
    • gRPC Transports:
      • CampaignAssetSetServiceGrpcTransport: A public class for synchronous gRPC communication (defined in grpc.py).
      • CampaignAssetSetServiceGrpcAsyncIOTransport: A public class for asynchronous gRPC communication (defined in grpc_asyncio.py).
    • REST Transports:
      • CampaignAssetSetServiceRestTransport: A public class for synchronous REST communication (defined in rest.py). It uses METHOD inner classes derived from the base REST implementation.
      • _BaseCampaignAssetSetServiceRestTransport: A private base class for REST transports that provides the underlying logic via _BaseMETHOD inner classes (defined in rest_base.py).
  10. Understand the BatchJobService transport inheritance structure

    main

    The BatchJobService uses a hierarchical transport structure to support different communication protocols (gRPC vs. REST) and execution models (Synchronous vs. Asynchronous).

    • BatchJobServiceTransport: The Abstract Base Class (ABC) that defines the interface for all transports.
    • gRPC Transports:
      • BatchJobServiceGrpcTransport: A public class for synchronous gRPC communication (defined in grpc.py).
      • BatchJobServiceGrpcAsyncIOTransport: A public class for asynchronous gRPC communication (defined in grpc_asyncio.py).
    • REST Transports:
      • BatchJobServiceRestTransport: A public class for synchronous REST communication (defined in rest.py). It uses METHOD inner classes derived from the base REST implementation.
      • _BaseBatchJobServiceRestTransport: A private base class for REST transports (defined in rest_base.py) which contains the _BaseMETHOD inner classes.
  11. Understand the ShareablePreviewService transport hierarchy

    main

    The ShareablePreviewService uses a transport inheritance structure to support different communication protocols (gRPC vs REST) and execution models (Synchronous vs Asynchronous).

    • gRPC (Synchronous): Use ShareablePreviewServiceGrpcTransport for standard synchronous gRPC calls. Defined in grpc.py.
    • gRPC (Asynchronous): Use ShareablePreviewServiceGrpcAsyncIOTransport for asynchronous gRPC calls using asyncio. Defined in grpc_asyncio.py.
    • REST (Synchronous): Use ShareablePreviewServiceRestTransport for standard synchronous REST calls. Defined in rest.py.
    • REST (Internal Base): _BaseShareablePreviewServiceRestTransport is a private base class used to implement the REST logic. Defined in rest_base.py.
  12. Understand the CustomerNegativeCriterionService transport inheritance structure

    main

    The CustomerNegativeCriterionService uses a specific inheritance hierarchy to provide different communication protocols (gRPC vs. REST) and execution models (Synchronous vs. Asynchronous).

    • gRPC Transports: Used for high-performance RPC communication.
      • CustomerNegativeCriterionServiceGrpcTransport: Synchronous gRPC transport (defined in grpc.py).
      • CustomerNegativeCriterionServiceGrpcAsyncIOTransport: Asynchronous gRPC transport (defined in grpc_asyncio.py).
    • REST Transports: Used for standard HTTP/REST communication.
      • CustomerNegativeCriterionServiceRestTransport: Synchronous REST transport (defined in rest.py). It uses METHOD inner classes derived from the private base class.
      • _BaseCustomerNegativeCriterionServiceRestTransport: The private base class for REST transports (defined in rest_base.py).

    All transports inherit from the Abstract Base Class (ABC) CustomerNegativeCriterionServiceTransport.