openlibrary

package
v0.0.0-...-ab39b29 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package openlibrary provides a client for the openlibrary.org HTTP API.

Index

Constants

View Source
const BaseURL = "https://openlibrary.org"

BaseURL is the base URL for the production openlibrary.org HTTP API.

Variables

This section is empty.

Functions

func CoverURL

func CoverURL(internalCoverID int) string

Types

type Client

type Client struct {
	// BaseURL specifies the base URL to use in requests to the API.
	// If empty, the package constant BaseURL is used.
	BaseURL string
	// HTTP specifies the HTTP client to use in requests.
	// If nil, http.DefaultClient is used.
	HTTP *http.Client
}

Client is a client for the openlibrary.org HTTP API.

The zero value is ready to use. Methods on a client are goroutine safe.

func (*Client) Search

func (c *Client) Search(ctx context.Context, q SearchQuery) (*SearchResponse, error)

Search performs a search for the given query.

The function does not support pagination.

type SearchQuery

type SearchQuery struct {
	Title  string
	Author string
}

type SearchResponse

type SearchResponse struct {
	Docs []struct {
		CoverI           int `json:"cover_i"`
		FirstPublishYear int `json:"first_publish_year"`
	} `json:"docs"`
}

Jump to

Keyboard shortcuts

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