This module allows you to connect to the Google Discovery API Service and query it.

Module Contents



A hook to use the Google API Discovery Service.

class, api_version, gcp_conn_id='google_cloud_default', delegate_to=None, impersonation_chain=None)[source]


A hook to use the Google API Discovery Service.

  • api_service_name (str) – The name of the api service that is needed to get the data for example ‘youtube’.

  • api_version (str) – The version of the api that will be requested for example ‘v3’.

  • gcp_conn_id (str) – The connection ID to use when fetching connection info.

  • delegate_to (str | None) – The account to impersonate using domain-wide delegation of authority, if any. For this to work, the service account making the request must have domain-wide delegation enabled.

  • impersonation_chain (str | Sequence[str] | None) – Optional service account to impersonate using short-term credentials, or chained list of accounts required to get the access_token of the last account in the list, which will be impersonated in the request. If set as a string, the account must grant the originating account the Service Account Token Creator IAM role. If set as a sequence, the identities from the list must grant Service Account Token Creator IAM role to the directly preceding identity, with first account from the list granting this role to the originating account.


Create an authenticated api client for the given api service name and credentials.


the authenticated api service.

Return type


query(endpoint, data, paginate=False, num_retries=0)[source]

Create a dynamic API call to any Google API registered in Google’s API Client Library and queries it.

  • endpoint (str) –

    The client libraries path to the api call’s executing method. For example: ‘analyticsreporting.reports.batchGet’

    See also for more information on what methods are available.

  • data (dict) – The data (endpoint params) needed for the specific request to given endpoint.

  • paginate (bool) – If set to True, it will collect all pages of data.

  • num_retries (int) – Define the number of retries for the requests being made if it fails.


the API response from the passed endpoint.

Return type


Was this entry helpful?