Documentation
¶
Overview ¶
Package openlibrary provides an interface to the Open Library API. It is VERY barebones and was created to serve the needs of a handful of developers during a Hackathon. They are interested in improving it once they aren't under a tight time crunch.
Index ¶
Constants ¶
const ( // BaseURL is the hostname of the Open Library API BaseURL = "http://openlibrary.org" // SearchURL is the search url of the Open Library API SearchURL = BaseURL + "/search" // WorksURL is the url for works in the Open Library API WorksURL = BaseURL + "/works" // CoverURL is the hostname for the Open Library covers API CoverURL = "http://covers.openlibrary.org" // AuthorURL is the url for authors in the Open Library API AuthorURL = BaseURL + "/authors" // EditionsURL is the url for editions of a work in the Open Library API // must provide work ID EditionsURL = BaseURL + "/works/%s/editions.json" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Author ¶ added in v0.3.5
type Author struct {
Bio AuthorBio `json:"bio"`
Name string `json:"name"`
Links []struct {
URL string `json:"url"`
Type struct {
Key string `json:"key"`
} `json:"type"`
Title string `json:"title"`
} `json:"links"`
PersonalName string `json:"personal_name"`
Created struct {
Type string `json:"type"`
Value string `json:"value"`
} `json:"created"`
Photos []int `json:"photos"`
LastModified struct {
Type string `json:"type"`
Value string `json:"value"`
} `json:"last_modified"`
LatestRevision int `json:"latest_revision"`
Key string `json:"key"`
BirthDate string `json:"birth_date"`
Revision int `json:"revision"`
Type struct {
Key string `json:"key"`
} `json:"type"`
RemoteIds struct {
Viaf string `json:"viaf"`
Wikidata string `json:"wikidata"`
} `json:"remote_ids"`
}
An Author represents a work's author response body from a request
func GetAuthorByID ¶ added in v0.3.5
GetAuthorByID returns an author given an Author ID
type AuthorBio ¶ added in v0.6.0
type AuthorBio string
AuthorBio extracts an author's bio
func (*AuthorBio) UnmarshalJSON ¶ added in v0.6.0
UnmarshalJSON will try to unmarshal a complex object, falling back to string before failing
type Doc ¶
type Doc struct {
AuthorAlternativeName []string `json:"author_alternative_name"`
AuthorKey []string `json:"author_key"`
AuthorName []string `json:"author_name"`
CoverEditionKey string `json:"cover_edition_key"`
CoverID int `json:"cover_i"`
EbookCount int `json:"ebook_count_i"`
EditionCount int `json:"edition_count"`
EditionKey []string `json:"edition_key"`
FirstPublishYear int `json:"first_publish_year"`
FullText bool `json:"has_fulltext"`
IA []string `json:"ia"`
IABoxID []string `json:"ia_box_id"`
IACollectionS string `json:"ia_collection_s"`
IALoadedID []string `json:"ia_loaded_id"`
GoodreadsID []string `json:"id_goodreads"`
GoogleID []string `json:"id_google"`
LibraryThingID []string `json:"id_librarything"`
OverdriveID []string `json:"id_overdrive"`
ISBN []string `json:"isbn"`
Key string `json:"key"`
Language []string `json:"language"`
LastModifiedID int `json:"last_modified_i"`
LCCN []string `json:"lccn"`
LendingEditionS string `json:"lending_edition_s"`
LendingIDS string `json:"lending_identifier_s"`
OCLC []string `json:"oclc"`
PrintDisabledS string `json:"printdisabled_s"`
PublicScanB bool `json:"public_scan_b"`
PublishDate []string `json:"publish_date"`
PublishPlace []string `json:"publish_place"`
PublishYear []int `json:"publish_year"`
Publisher []string `json:"publisher"`
Seed []string `json:"seed"`
Subject []string `json:"subject"`
Text []string `json:"text"`
Title string `json:"title"`
TitleSuggest string `json:"title_suggest"`
Type string `json:"type"`
}
A Doc represents an item in the Open Library
func TitleSearch ¶
TitleSearch performs a title search and returns the results.
type Edition ¶ added in v0.5.0
type Edition struct {
Publishers []string `json:"publishers"`
NumberOfPages int `json:"number_of_pages"`
Subtitle string `json:"subtitle"`
Covers []int `json:"covers"`
LocalID []string `json:"local_id"`
PhysicalFormat string `json:"physical_format"`
LastModified struct {
Type string `json:"type"`
Value string `json:"value"`
} `json:"last_modified"`
LatestRevision int `json:"latest_revision"`
Key string `json:"key"`
Classifications struct {
} `json:"classifications"`
SourceRecords []string `json:"source_records"`
Title string `json:"title"`
Identifiers struct {
Goodreads []string `json:"goodreads"`
} `json:"identifiers"`
Created struct {
Type string `json:"type"`
Value string `json:"value"`
} `json:"created"`
Isbn13 []string `json:"isbn_13"`
Isbn10 []string `json:"isbn_10"`
PublishDate string `json:"publish_date"`
Works []struct {
Key string `json:"key"`
} `json:"works"`
Type struct {
Key string `json:"key"`
} `json:"type"`
Revision int `json:"revision"`
}
Edition represents the edition of a work
func GetEditionsByID ¶ added in v0.5.0
GetEditionsByID returns the editions for a work
type EditionsResponse ¶ added in v0.5.0
type EditionsResponse struct {
Entries []Edition `json:"entries"`
Links struct {
Self string `json:"self"`
Work string `json:"work"`
} `json:"links"`
Size int `json:"size"`
}
EditionsResponse represents the response for editions of a work
type Search ¶
type Search struct {
Start int `json:"start"`
Found int `json:"numFound"`
Docs []Doc `json:"docs"`
}
A Search represents the response body from a request.
type Work ¶
type Work struct {
Description WorkDescription `json:"description"`
Title string `json:"title"`
Created struct {
Type string `json:"type"`
Value string `json:"value"`
} `json:"created"`
Photos []int `json:"photos"`
LastModified struct {
Type string `json:"type"`
Value string `json:"value"`
} `json:"last_modified"`
LatestRevision int `json:"latest_revision"`
Key string `json:"key"`
BirthDate string `json:"birth_date"`
Revision int `json:"revision"`
Type WorkType `json:"type"`
RemoteIds WorkRemoteID `json:"remote_ids"`
Authors []WorkAuthor `json:"authors"`
Covers []int `json:"covers"`
}
A Work respresents a work response body from a request
func GetWorkByID ¶
GetWorkByID returns a work given an a Work ID
type WorkAuthor ¶ added in v0.5.0
type WorkAuthor struct {
Type struct {
Key string `json:"key"`
} `json:"type"`
Author struct {
Key string `json:"key"`
} `json:"author"`
}
WorkAuthor describes the author of a work
type WorkDescription ¶ added in v0.5.4
type WorkDescription string
WorkDescription extracts a work's description field
func (*WorkDescription) UnmarshalJSON ¶ added in v0.5.4
func (d *WorkDescription) UnmarshalJSON(data []byte) error
UnmarshalJSON will try to unmarshal a complex object, falling back to string before failing
type WorkRemoteID ¶ added in v0.5.0
WorkRemoteID is some remote ID