|
||
---|---|---|
.. | ||
abusiveexperiencereport/v1 | ||
acceleratedmobilepageurl/v1 | ||
accesscontextmanager | ||
adexchangebuyer | ||
adexchangebuyer2/v2beta1 | ||
adexchangeseller | ||
adexperiencereport/v1 | ||
admin | ||
adsense | ||
adsensehost/v4.1 | ||
alertcenter/v1beta1 | ||
analytics | ||
analyticsreporting/v4 | ||
androiddeviceprovisioning/v1 | ||
androidenterprise/v1 | ||
androidmanagement/v1 | ||
androidpublisher | ||
appengine | ||
appsactivity/v1 | ||
appstate/v1 | ||
bigquery/v2 | ||
bigquerydatatransfer/v1 | ||
bigtableadmin | ||
binaryauthorization/v1beta1 | ||
blogger | ||
books/v1 | ||
calendar/v3 | ||
chat/v1 | ||
civicinfo/v2 | ||
classroom/v1 | ||
cloudasset | ||
cloudbilling/v1 | ||
cloudbuild | ||
clouddebugger/v2 | ||
clouderrorreporting/v1beta1 | ||
cloudfunctions | ||
cloudidentity | ||
cloudiot/v1 | ||
cloudkms/v1 | ||
cloudprivatecatalog/v1beta1 | ||
cloudprivatecatalogproducer/v1beta1 | ||
cloudprofiler/v2 | ||
cloudresourcemanager | ||
cloudscheduler/v1beta1 | ||
cloudsearch/v1 | ||
cloudshell | ||
cloudtasks | ||
cloudtrace | ||
commentanalyzer/v1alpha1 | ||
composer | ||
compute | ||
consumersurveys/v2 | ||
container | ||
containeranalysis | ||
content | ||
customsearch/v1 | ||
dataflow/v1b3 | ||
dataproc | ||
datastore | ||
deploymentmanager | ||
dfareporting | ||
dialogflow | ||
digitalassetlinks/v1 | ||
discovery/v1 | ||
dlp/v2 | ||
dns | ||
docs/v1 | ||
doubleclickbidmanager/v1 | ||
doubleclicksearch/v2 | ||
drive | ||
driveactivity/v2 | ||
examples | ||
factchecktools/v1alpha1 | ||
file | ||
firebasedynamiclinks/v1 | ||
firebasehosting/v1beta1 | ||
firebaseremoteconfig/v1 | ||
firebaserules/v1 | ||
firestore | ||
fitness/v1 | ||
fusiontables | ||
games/v1 | ||
gamesconfiguration/v1configuration | ||
gamesmanagement/v1management | ||
genomics | ||
gensupport | ||
gmail/v1 | ||
google-api-go-generator | ||
googleapi | ||
groupsmigration/v1 | ||
groupssettings/v1 | ||
healthcare | ||
iam/v1 | ||
iamcredentials/v1 | ||
iap | ||
identitytoolkit/v3 | ||
indexing/v3 | ||
integration-tests/storage | ||
internal | ||
iterator | ||
jobs | ||
kgsearch/v1 | ||
language | ||
lib/codereview | ||
libraryagent/v1 | ||
licensing/v1 | ||
logging | ||
manufacturers/v1 | ||
mirror/v1 | ||
ml/v1 | ||
monitoring | ||
oauth2 | ||
option | ||
oslogin | ||
pagespeedonline | ||
partners/v2 | ||
people/v1 | ||
photoslibrary/v1 | ||
playcustomapp/v1 | ||
playmoviespartner/v1 | ||
plus/v1 | ||
plusdomains/v1 | ||
poly/v1 | ||
prediction | ||
proximitybeacon/v1beta1 | ||
pubsub | ||
qpxexpress/v1 | ||
redis | ||
remotebuildexecution | ||
replicapool/v1beta1 | ||
replicapoolupdater/v1beta1 | ||
reseller/v1 | ||
run | ||
runtimeconfig | ||
safebrowsing/v4 | ||
script/v1 | ||
searchconsole/v1 | ||
securitycenter | ||
servicebroker | ||
serviceconsumermanagement/v1 | ||
servicecontrol/v1 | ||
servicemanagement/v1 | ||
servicenetworking | ||
serviceusage | ||
serviceuser/v1 | ||
sheets/v4 | ||
siteverification/v1 | ||
slides/v1 | ||
sourcerepo/v1 | ||
spanner/v1 | ||
spectrum/v1explorer | ||
speech | ||
sqladmin/v1beta4 | ||
storage | ||
storagetransfer/v1 | ||
streetviewpublish/v1 | ||
support/bundler | ||
surveys/v2 | ||
tagmanager | ||
tasks/v1 | ||
testing/v1 | ||
texttospeech | ||
toolresults/v1beta3 | ||
tpu | ||
tracing/v2 | ||
translate/v2 | ||
transport | ||
urlshortener/v1 | ||
vault/v1 | ||
videointelligence | ||
vision | ||
webfonts/v1 | ||
webmasters/v3 | ||
websecurityscanner | ||
youtube/v3 | ||
youtubeanalytics | ||
youtubereporting/v1 | ||
.gitignore | ||
.hgtags | ||
api-list.json | ||
AUTHORS | ||
CONTRIBUTING.md | ||
CONTRIBUTORS | ||
doc.go | ||
GettingStarted.md | ||
go.mod | ||
go.sum | ||
key.json.enc | ||
LICENSE | ||
NOTES | ||
README.md | ||
TODO | ||
tools.go |
Google APIs Client Library for Go
Getting Started
$ go get google.golang.org/api/tasks/v1
$ go get google.golang.org/api/moderator/v1
$ go get google.golang.org/api/urlshortener/v1
... etc ...
and using:
package main
import (
"net/http"
"google.golang.org/api/urlshortener/v1"
)
func main() {
svc, err := urlshortener.New(http.DefaultClient)
// ...
}
- For a longer tutorial, see the Getting Started guide.
- For examples, see the examples directory.
- For support, use the golang-nuts mailing list.
- The code review instance may be found here.
Status
These are auto-generated Go libraries from the Google Discovery Service's JSON description files of the available "new style" Google APIs.
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.
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, consider using the Cloud Client Libraries for Go instead. These are the new and idiomatic Go libraries targeted specifically at Google Cloud Platform Services.
The generator itself and the code it produces are beta. Some APIs are alpha/beta, and indicated as such in the import path (e.g., "google.golang.org/api/someapi/v1alpha").
Application Default Credentials Example
Application Default Credentials provide a simplified way to obtain credentials for authenticating with Google APIs.
The Application Default Credentials authenticate as the application itself, which make them great for working with Google Cloud APIs like Storage or Datastore. They are the recommended form of authentication when building applications that run on Google Compute Engine or Google App Engine.
Default credentials are provided by the golang.org/x/oauth2/google
package. To use them, add the following import:
import "golang.org/x/oauth2/google"
Some credentials types require you to specify scopes, and service entry points may not inject them. If you encounter this situation you may need to specify scopes as follows:
import (
"context"
"golang.org/x/oauth2/google"
"google.golang.org/api/compute/v1"
)
func main() {
// Use oauth2.NoContext if there isn't a good context to pass in.
ctx := context.Background()
client, err := google.DefaultClient(ctx, compute.ComputeScope)
if err != nil {
//...
}
computeService, err := compute.New(client)
if err != nil {
//...
}
}
If you need a oauth2.TokenSource
, use the DefaultTokenSource
function:
ts, err := google.DefaultTokenSource(ctx, scope1, scope2, ...)
if err != nil {
//...
}
client := oauth2.NewClient(ctx, ts)
See also: golang.org/x/oauth2/google package documentation.