Google provides client libraries (SDKs) for all its services.

These libraries are provided by Google in Python, Go, Java, .NET etc.

To facilitate the publication of this matrix of libraries (service*language), Google developed a mechanism that enabled automatic code-generation from service schemas. These schemas are called Discovery documents in Google parlance . Interestingly, there's a Google service called Discovery service too and it has a single method list that you can try on that page. E.g. forms

Given a Discovery document and client library generator, client libraries can be generated on-the-fly.

The (open-sourced) Python API Client Library includes discovery.build which generates the resources for the service that you provide it.

You can simplify your code:

discovery.build("forms", "v1", credentials = credentials)

The API Client library provides this functionality for all Google services. If you scan the page, you'll find the Forms service and that it's version is v1 (per your code). The link will take you to the API's documentation

An alternative way to find doucmentation for a Google service (not by programming language although sometimes examples are provided), is to use APIs Explorer. You can search for and access the REST documentation for Google Forms. This also provides a link to the Discovery document ;-)

Note: The APIs Explorer REST documentation actually documents 2 versions of the API v1 and v1beta (see left hand side). So, you can also discovery.build("forms","v1beta",credentials=credentials) if you need the enhanced methods.

Thanks to the Discovery mechanism and the fact that Google triggers builds for client libraries on API changes, you can be assured that the client libraries are almost always a perfect reflection of the API.

Note: Code-generation from REST-based API schemas is often done using Swagger (aka Open API). Google Discovery predates swagger. I think (!?) Google does not provide Open API schemas for its libraries. Google provides an alternative to REST called gRPC for some of its services. gRPC has its own code-generation mechanism.

Answer from DazWilkin on Stack Overflow
🌐
GitHub
github.com › googleapis › google-api-python-client › blob › main › googleapiclient › discovery.py
google-api-python-client/googleapiclient/discovery.py at main · googleapis/google-api-python-client
from googleapiclient.schema import Schemas · · # The client library requires a version of httplib2 that supports RETRIES. httplib2.RETRIES = 1 · · logger = logging.getLogger(__name__) · URITEMPLATE = re.compile("{[^}]*}") VARNAME = re.compile("[a-zA-Z0-9_-]+") DISCOVERY_URI = ( "https://www.googleapis.com/discovery/v1/apis/" "{api}/{apiVersion}/rest" ) V1_DISCOVERY_URI = DISCOVERY_URI ·
Author   googleapis
🌐
Google
developers.google.com › google api discovery service › use the discovery api
Use the Discovery API | Google API Discovery Service | Google for Developers
April 15, 2024 - If you are building a client library, this can help you effectively model the objects of an API in your data model classes. In the EnableServiceResponse example above, the service property is a reference to a schema with ID GoogleApiServiceusageV1Service, another schema in the Service Usage API Discovery document.
🌐
GitHub
googleapis.github.io › google-api-python-client › docs › epy › googleapiclient.discovery.Resource-class.html
googleapiclient.discovery.Resource
A class for interacting with a resource · Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__
Top answer
1 of 2
9

Google provides client libraries (SDKs) for all its services.

These libraries are provided by Google in Python, Go, Java, .NET etc.

To facilitate the publication of this matrix of libraries (service*language), Google developed a mechanism that enabled automatic code-generation from service schemas. These schemas are called Discovery documents in Google parlance . Interestingly, there's a Google service called Discovery service too and it has a single method list that you can try on that page. E.g. forms

Given a Discovery document and client library generator, client libraries can be generated on-the-fly.

The (open-sourced) Python API Client Library includes discovery.build which generates the resources for the service that you provide it.

You can simplify your code:

discovery.build("forms", "v1", credentials = credentials)

The API Client library provides this functionality for all Google services. If you scan the page, you'll find the Forms service and that it's version is v1 (per your code). The link will take you to the API's documentation

An alternative way to find doucmentation for a Google service (not by programming language although sometimes examples are provided), is to use APIs Explorer. You can search for and access the REST documentation for Google Forms. This also provides a link to the Discovery document ;-)

Note: The APIs Explorer REST documentation actually documents 2 versions of the API v1 and v1beta (see left hand side). So, you can also discovery.build("forms","v1beta",credentials=credentials) if you need the enhanced methods.

Thanks to the Discovery mechanism and the fact that Google triggers builds for client libraries on API changes, you can be assured that the client libraries are almost always a perfect reflection of the API.

Note: Code-generation from REST-based API schemas is often done using Swagger (aka Open API). Google Discovery predates swagger. I think (!?) Google does not provide Open API schemas for its libraries. Google provides an alternative to REST called gRPC for some of its services. gRPC has its own code-generation mechanism.

2 of 2
2

The discovery.build() method builds a service object (your resource variable) for the Google Python API client which allows you to easily use built-in methods to access API endpoints for a given API (in your case the forms API).

In your specific case, you can leverage your service object resource to make calls to any of the Google Forms APIs in a much simpler way than specifying all the API endpoints directly.

Example using your resource service object to retrieve all responses to a Google form:

# Prints the responses of your specified form:
form_id = '<YOUR_FORM_ID>'
result = resource.forms().responses().list(formId=form_id).execute()
print(result)

For more detailed examples with the Google Forms API see the official developer documentation

🌐
Google
docs.cloud.google.com › documentation › google apis discovery service
Overview of the Discovery API | Google APIs Discovery Service | Google Cloud Documentation
June 16, 2025 - where API is the identifier for a Discovery Document resource, and VERSION is the identifier of the particular version of the API. Here are a couple of examples of how this works in the Google APIs Discovery Service.
🌐
DEV Community
dev.to › schttrj › accessing-the-google-api-discovery-api-and-its-associated-discovery-documents-48aj
Accessing the Google Discovery API and its Associated Discovery Documents - DEV Community
March 24, 2025 - from googleapiclient.discovery import build service = build('translate', 'v2') # API methods can now be accessed via 'service'
🌐
GitHub
github.com › googleapis › google-api-python-client
GitHub - googleapis/google-api-python-client: 🐍 The official Python client library for Google's discovery based APIs.
Discovery documents will no longer be retrieved dynamically when you call discovery.build(). The discovery documents will instead be retrieved from the client library directly. New versions of this library are released weekly.
Starred by 8.8K users
Forked by 2.6K users
Languages   Python 94.1% | Shell 5.7% | Makefile 0.2%
Find elsewhere
🌐
GitHub
google.github.io › google-api-javascript-client › docs › discovery.html
API Discovery Document | google-api-javascript-client
After loading an API Discovery Document, the JavaScript client library automatically generates JavaScript methods for interacting with the API. For each method defined in the API Discovery Document, a corresponding method is constructed on the gapi.client object. For example, The People API’s methods are under gapi.client.people.
🌐
Google Cloud
cloud.google.com › ai platform › ai platform prediction › documentation › using the python client library
Using the Python client library | AI Platform Prediction | Google Cloud
from googleapiclient import discovery from googleapiclient import errors # Store your full project ID in a variable in the format the API needs. project_id = 'projects/{}'.format('YOUR_PROJECT_ID') # Build a representation of the Cloud ML API. ...
🌐
GitHub
googleapis.github.io › google-api-python-client › docs › epy › index.html
Package googleapiclient
🐍 The official Python client library for Google’s discovery based APIs.
🌐
Google
developers.google.com › google api discovery service › build a client library
Build a client library | Google API Discovery Service | Google for Developers
For example, if the user of the library makes a choice that sets var to the value foo, the new URL will be /example/path/foo. Also note that the path property is a relative URI. In order to calculate the absolute URI, follow these steps: If ...
🌐
Google
developers.google.com › discovery
Google API Discovery Service | Google for Developers
Use the Google API Discovery Service to build client libraries, IDE plugins, and other tools that interact with Google APIs. The Discovery API provides a list of Google APIs and a machine-readable "Discovery Document" for each API. Features of the Discovery API:
🌐
PyPI
pypi.org › project › google-api-helper
google-api-helper · PyPI
import googleapiclient.discovery from oauth2client.service_account import ServiceAccountCredentials credentials = ServiceAccountCredentials.from_json_keyfile_name("service_account.json", ["https://www.googleapis.com/auth/compute"]) compute = googleapiclient.discovery.build('compute', 'v1', credentials=credentials)
      » pip install google-api-helper
    
Published   Apr 23, 2019
Version   0.3.1
🌐
PyPI
pypi.org › project › google-api-python-client-stubs
google-api-python-client-stubs · PyPI
Note that since the types don't exist at runtime, they're not compatible with libraries that evaluate annotations at runtime. For example, you can't use them to annotate a field in a Pydantic model. The stubs contain a separate overload of googleapiclient.discovery.build for each service and version (see discovery.pyi).
      » pip install google-api-python-client-stubs
    
Published   Apr 17, 2026
Version   1.35.0
🌐
Google
developers.google.com › comparison-shopping-services › api › code-samples › gapi
Comparison Shopping Service API | Google for Developers
July 23, 2024 - These examples are written in python, but they may be similar in other programming languages, such as PHP. For using the Google API clients, you will need both an API key and a service account document, as described in the Permissions section in quickstart ... from googleapiclient.discovery import build from google.oauth2 import service_account # This must be a valid service json document SERVICE_ACCOUNT_FILE="/.../google.....json" SCOPES=["https://www.googleapis.com/auth/content"] credentials = service_account.Credentials.from_service_account_file( SERVICE_ACCOUNT_FILE, scopes=SCOPES) url="ht
🌐
Google Cloud
cloud.google.com › documentation › google apis discovery service › build a client library
Build a client library | Google APIs Discovery Service | Google Cloud
For example, if the user of the library makes a choice that sets var to the value foo, the new URL will be /example/path/foo. Also note that the path property is a relative URI. In order to calculate the absolute URI, follow these steps: If ...