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 OverflowGoogle 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.
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
» pip install google-api-helper
» pip install google-api-python-client-stubs