Version: v0.0.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2021 License: MIT Imports: 5 Imported by: 0



A simple Go wrapper around the Books API



This section is empty.


View Source
var (
	// FormatError marks errors with provided book identifers
	FormatError = fmt.Errorf("identifier in wrong format")
	// NetworkError marks errors with the connection to the OpenLibrary API
	NetworkError = fmt.Errorf("network error")
	// NotFoundError marks an empty response from the OpenLibrary API
	NotFoundError = fmt.Errorf("book not found")


This section is empty.


type Authors

type Authors struct {
	Name string `json:"name"`
	URL  string `json:"url"`

type BookDetails

type BookDetails struct {
	Authors         []Authors       `json:"authors"`
	Classifications Classifications `json:"classifications"`
	Cover           Cover           `json:"cover"`
	Excerpts        []Excerpts      `json:"excerpts"`
	Identifiers     Identifiers     `json:"identifiers"`
	Links           []Links         `json:"links"`
	NumberOfPages   int             `json:"number_of_pages"`
	PublishDate     string          `json:"publish_date"`
	Publishers      []Publishers    `json:"publishers"`
	PublishPlaces   []PublishPlaces `json:"publish_places"`
	Subjects        []Subjects      `json:"subjects"`
	Title           string          `json:"title"`
	URL             string          `json:"url"`
	Weight          string          `json:"weight"`

type Classifications

type Classifications struct {
	DeweyDecimalClass []string `json:"dewey_decimal_class"`
	LcClassifications []string `json:"lc_classifications"`

type Client

type Client struct {
	// contains filtered or unexported fields

Client provides OpenLibrary Books API query methods

func (*Client) GetByISBN

func (c *Client) GetByISBN(k string) (*BookDetails, error)

GetByISBN fetches details for a book based on its ISBN10 or ISBN13.

func (*Client) GetByLCCN

func (c *Client) GetByLCCN(k string) (*BookDetails, error)

GetByLCCN fetches details for a book based on its Library of Congress Control Number.

func (*Client) GetByOCLC

func (c *Client) GetByOCLC(k string) (*BookDetails, error)

GetByOCLC fetches details for a book based on its WorldCat OCLC number.

func (*Client) GetByOLID

func (c *Client) GetByOLID(k string) (*BookDetails, error)

GetByOLID fetches details for a book based on its OpenLibrary ID number.

func (*Client) GetByRawKey

func (c *Client) GetByRawKey(k string) (*BookDetails, error)

GetByRawKey fetches details for a book based on an arbitrary key; this method is provided as a future-proof fallback in case the OpenLibrary API adds more "bibkey" request types in the future. Most users should use one of the other lookup functions.

func (*Client) SetAPIPath

func (c *Client) SetAPIPath(p string)

SetAPIPath updates the hostname and path to the API; the default is "". If APIPath is set to an empty string, the client will fall back to the default option.

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(h http.Client)

SetHTTPClient updates the httpClient on the client with a manually-configured one. If unset, the client will fall back to using http.DefaultClient.

type Cover

type Cover struct {
	Small  string `json:"small"`
	Medium string `json:"medium"`
	Large  string `json:"large"`

type Excerpts

type Excerpts struct {
	Text    string `json:"text"`
	Comment string `json:"comment"`

type Identifiers

type Identifiers struct {
	Amazon           []string `json:"amazon"`
	Goodreads        []string `json:"goodreads"`
	Google           []string `json:"google"`
	ISBN10           []string `json:"isbn_10"`
	ISBN13           []string `json:"isbn_13"`
	LCCN             []string `json:"lccn"`
	LibraryThing     []string `json:"librarything"`
	OCLC             []string `json:"oclc"`
	ProjectGutenberg []string `json:"project_gutenberg"`
type Links struct {
	Title string `json:"title"`
	URL   string `json:"url"`

type PublishPlaces

type PublishPlaces struct {
	Name string `json:"name"`

type Publishers

type Publishers struct {
	Name string `json:"name"`

type Subjects

type Subjects struct {
	Name string `json:"name"`
	URL  string `json:"url"`

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL