Skip to content

Go client library for accessing Google Books API

Notifications You must be signed in to change notification settings

eguevara/go-books

Repository files navigation

go-books

go-books is a Go client library for accessing Google Books Annotations API.

https://developers.google.com/apis-explorer/?hl=en_US#s/books/v1/

Usage

 import 	"github.com/eguevara/go-books"

Authentication

OAuth2 http client is required to to access Google Books API on behalf of a user.

data, err := ioutil.ReadFile("pemFile")
if err != nil {
    log.Fatal(err)
}

conf := &jwt.Config{
		Email:      "[email protected]",
		PrivateKey: []byte(data),
		Scopes: []string{
			"https://www.googleapis.com/auth/books",
		},
		TokenURL: google.JWTTokenURL,
		Subject:  "[email protected]",
	}
client := conf.Client(oauth2.NoContext)

Examples

client, err := books.New(oauthClient)
if err != nil {
    log.Fatalf("http: error %v", err)
}

opts := &books.AnnotationsListOptions{
    VolumeID:       "volumeId",
    ContentVersion: "version",
    LayerID:        "notes",
    Source:         "app",
	Fields:         "items(layerId,selectedText,volumeId),totalItems",
}

list, _, err := client.Annotations.List(opts)
if err != nil {
    log.Fatalf("error in list(): %v ", err)
}

About

Go client library for accessing Google Books API

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published