Skip to content
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

31 lines (16 sloc) 2.12 KB

API Discovery Document

An API Discovery document describes the surface for a particular version of an API. The information includes API name, API version, API description, resource schemas, method definitions, authentication requirements, and more. The JavaScript client library uses the information to generate corresponding JavaScript methods that applications can use.

Finding an API's Discovery Document URL

If an API explicitly documents its discovery URL, always use it as-is to load the JavaScript client library. For example, the People API documents its discovery URL as:$discovery/rest?version=v1

Use this URL to load your JavaScript client.

If there's no discovery URL in the API's documentation, you can construct the default discovery URL using the API name and the API version as follows:

For example, the Discovery URL of Translate API v2 is:

See Google API Discovery Service for details.

Discovering generated methods

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. The People API has the methods people.get and people.connections.list, the generated methods can be called as follows:



You can view API methods on APIs Explorer. Alternatively, you can view the generated methods interactively in a browser's console (such as by using the Inspect command in Chrome) by printing the generated object console.log(gapi.client.people).

You can’t perform that action at this time.