/go-gitbook-api

GitBook API client in GO (golang)

Primary LanguageGoApache License 2.0Apache-2.0

go-gitbook-api

GitBook API client in GO (golang)

Documentation

See GoDoc for automatically generated API documentation.

Check out the examples below for quick and simple ways to start.

Simple Example

package main

import (
    "fmt"
    "github.com/GitbookIO/go-gitbook-api"
)

func main() {
    // Make API client
    api := gitbook.NewAPI(gitbook.APIOptions{})

    // Get book
    book, err := api.Book.Get("gitbookio/javascript")

    // Print results
    fmt.Printf("book = %q\n", book)
    fmt.Printf("error = %q\n", err)
}

Advanced Example

package main

import (
    "fmt"
    "github.com/GitbookIO/go-gitbook-api"
)

func main() {
    // Make API client
    api := gitbook.NewAPI(gitbook.APIOptions{
        // Custom host instead of "https://api.gitbook.com"
        Host: "http://localhost:5000/api/",

        // Hit API with a specific user
        Username: "username",
        Password: "token or password",
    })

    // Get book
    book, err := api.Book.Get("gitbookio/javascript")

    // Print results
    fmt.Printf("book = %q\n", book)
    fmt.Printf("error = %q\n", err)
}