openlibrary

package module
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 6 Imported by: 1

README

Open Library Go Interface

GoDoc GitHub tag (latest SemVer) Contributor Covenant

A package for interacting with the Open Library API.

Very very much a work in progress.

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

View Source
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"
)

Variables

This section is empty.

Functions

This section is empty.

Types

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

func TitleSearch(title string) (docs []Doc, err error)

TitleSearch performs a title search and returns the results.

func (*Doc) CoverURL

func (d *Doc) CoverURL(size Size) string

CoverURL returns the URL of an image of the specified size for the document.

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 Size

type Size string

A Size represents the size of an image.

const (
	// SizeSmall is an image suitable for use as a thumbnail on a results page
	SizeSmall Size = "S"

	// SizeMedium is suitable for display on a details page
	SizeMedium Size = "M"

	// SizeLarge is the largest image size
	SizeLarge Size = "L"
)

type Work

type Work struct {
	Description struct {
		Type  string `json:"type"`
		Value string `json:"value"`
	} `json:"description"`
	Title   string `json:"title"`
	Created struct {
		Type  string `json:"type"`
		Value string `json:"value"`
	} `json:"created"`
	Covers       []int `json:"covers"`
	LastModified struct {
		Type  string `json:"type"`
		Value string `json:"value"`
	} `json:"last_modified"`
	LatestRevision int    `json:"latest_revision"`
	Key            string `json:"key"`
	Authors        []struct {
		Type struct {
			Key string `json:"key"`
		} `json:"type"`
		Author struct {
			Key string `json:"key"`
		} `json:"author"`
	} `json:"authors"`
	Type struct {
		Key string `json:"key"`
	} `json:"type"`
	Subjects []string `json:"subjects"`
	Revision int      `json:"revision"`
}

A Work respresents a work response body from a request

func GetWorkByID

func GetWorkByID(id string) (work Work, err error)

GetWorkByID returns a work given an a Work ID

Jump to

Keyboard shortcuts

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