Sign inDemoInstall

Package Overview
File Explorer

Install Socket

Protect your apps from supply chain attacks


Package api is the root of the packages used to access Google Cloud Services. See for a full list of sub-packages. Within api there exist numerous clients which connect to Google APIs, and various utility packages. All clients in sub-packages are configurable via client options. These options are described here: All the clients in sub-packages support authentication via Google Application Default Credentials (see, or by providing a JSON key file for a Service Account. See the authentication examples in for more details. Due to the auto-generated nature of this collection of libraries, complete APIs or specific versions can appear or go away without notice. As a result, you should always locally vendor any API(s) that your code relies upon. Google APIs follow semver as specified by The code generator and the code it produces - the libraries in the subpackages - are beta. Note that versioning and stability is strictly not communicated through Go modules. Go modules are used only for dependency management. Many parameters are specified using ints. However, underlying APIs might operate on a finer granularity, expecting int64, int32, uint64, or uint32, all of whom have different maximum values. Subsequently, specifying an int parameter in one of these clients may result in an error from the API because the value is too large. To see the exact type of int that the API expects, you can inspect the API's discovery doc. A global catalogue pointing to the discovery doc of APIs can be found at This field can be found on all Request/Response structs in the generated clients. All of these types have the JSON `omitempty` field tag present on their fields. This means if a type is set to its default value it will not be marshalled. Sometimes you may actually want to send a default value, for instance sending an int of `0`. In this case you can override the `omitempty` feature by adding the field name to the `ForceSendFields` slice. See docs on any struct for more details. An error returned by a client's Do method may be cast to a *googleapi.Error or unwrapped to an *apierror.APIError. The type is useful for getting the HTTP status code: The type is useful for inspecting structured details of the underlying API response, such as the reason for the error and the error domain, which is typically the registered service name of the tool or product that generated the error: If an API call returns an Operation, that means it could take some time to complete the work initiated by the API call. Applications that are interested in the end result of the operation they initiated should wait until the Operation.Done field indicates it is finished. To do this, use the service's Operation client, and a loop, like so:


Version published


# Google APIs Client Library for Go

## Getting Started

$ go get
$ go get
$ go get
... etc ...

and using:

package main

import (


func main() {
        ctx := context.Background()
        svc, err := urlshortener.NewService(ctx)
        // ...

* For a longer tutorial, see the [Getting Started guide](
* For examples, see the [examples directory](
* For support, use the [golang-nuts]( mailing list.

## Status

[![Go Reference](](

These are auto-generated Go libraries from the Google Discovery Service's JSON description files.

Due to the auto-generated nature of this collection of libraries they may contain breaking changes from one release to
the next. The generator itself and the code it produces are considered beta for this reason.

These client libraries are officially supported by Google.  However, the libraries are considered complete and are in
maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.

If you're working with Google Cloud Platform APIs such as Datastore or Pub/Sub, please use the
[Cloud Client Libraries for Go]( instead. These are the new and idiomatic
Go libraries targeted specifically at Google Cloud Platform Services.

## Authorization

By default, each API will use [Google Application Default Credentials](
for authorization credentials used in calling the API endpoints. This will allow your application to run in many
environments without requiring explicit configuration.

// import ""
client, err := sheets.NewService(ctx)

To authorize using a [JSON key file](, pass
[`option.WithCredentialsFile`]( to the `NewService`
function of the desired package. For example:

client, err := sheets.NewService(ctx, option.WithCredentialsFile("path/to/keyfile.json"))

You can exert more control over authorization by using the [``](
package to create an `oauth2.TokenSource`. Then pass [`option.WithTokenSource`](
to the `NewService` function:

tokenSource := ...
svc, err := sheets.NewService(ctx, option.WithTokenSource(tokenSource))

## More information

For some more information related to all of the generated clients please read through our
[package documentation](


Last updated on 27 Nov 2023

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.


Related posts

SocketSocket SOC 2 Logo


  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc