Documentation ¶
Overview ¶
A simple Go wrapper around the OpenLibrary.org Books API
Index ¶
- Variables
- type Authors
- type BookDetails
- type Classifications
- type Client
- func (c *Client) GetByISBN(k string) (*BookDetails, error)
- func (c *Client) GetByLCCN(k string) (*BookDetails, error)
- func (c *Client) GetByOCLC(k string) (*BookDetails, error)
- func (c *Client) GetByOLID(k string) (*BookDetails, error)
- func (c *Client) GetByRawKey(k string) (*BookDetails, error)
- func (c *Client) SetAPIPath(p string)
- func (c *Client) SetHTTPClient(h http.Client)
- type Cover
- type Excerpts
- type Identifiers
- type Links
- type PublishPlaces
- type Publishers
- type Subjects
Constants ¶
This section is empty.
Variables ¶
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") )
Functions ¶
This section is empty.
Types ¶
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 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 ¶
SetAPIPath updates the hostname and path to the API; the default is "https://openlibrary.org/api/books". If APIPath is set to an empty string, the client will fall back to the default option.
func (*Client) SetHTTPClient ¶
SetHTTPClient updates the httpClient on the client with a manually-configured one. If unset, the client will fall back to using http.DefaultClient.
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 PublishPlaces ¶
type PublishPlaces struct {
Name string `json:"name"`
}
type Publishers ¶
type Publishers struct {
Name string `json:"name"`
}