OpenLibrary
in package
Open Library Utilities
Class for accessing helpful Open Library APIs.
Tags
Table of Contents
- $client : Client
- HTTP client
- __construct() : mixed
- Constructor
- getSubjects() : array<string|int, mixed>
- Returns an array of elements for each work matching the parameters. An API call will be made for each subjectType until data is returned
- normaliseSubjectString() : string
- Support function to return a normalised version of the search string for use in the API url
- processSubjectsApi() : array<string|int, mixed>
- Return the following array of values for each work: title, cover_id, cover_id_type, key, ia, mainAuthor
Properties
$client
HTTP client
protected
Client
$client
Methods
__construct()
Constructor
public
__construct(Client $client) : mixed
Parameters
- $client : Client
-
HTTP client
Return values
mixed —getSubjects()
Returns an array of elements for each work matching the parameters. An API call will be made for each subjectType until data is returned
public
getSubjects(string $subject, string $publishedIn, array<string|int, mixed> $subjectTypes[, bool $ebooks = true ][, bool $details = false ][, int $limit = 5 ][, int $offset = null ][, bool $publicFullText = true ]) : array<string|int, mixed>
Parameters
- $subject : string
-
The subject term to be looked for
- $publishedIn : string
-
Date range in the form YYYY-YYYY
- $subjectTypes : array<string|int, mixed>
-
An array of subject types to check
- $ebooks : bool = true
-
Whether to use ebook filter
- $details : bool = false
-
Whether to return full details
- $limit : int = 5
-
The number of works to return
- $offset : int = null
-
Paging offset
- $publicFullText : bool = true
-
Only return publicly available, full-text works
Return values
array<string|int, mixed> —normaliseSubjectString()
Support function to return a normalised version of the search string for use in the API url
protected
normaliseSubjectString(string $subject) : string
Parameters
- $subject : string
-
Search string to normalise
Return values
string —processSubjectsApi()
Return the following array of values for each work: title, cover_id, cover_id_type, key, ia, mainAuthor
protected
processSubjectsApi(string $url, int $limit, bool $publicFullText) : array<string|int, mixed>
Parameters
- $url : string
-
URL to request
- $limit : int
-
The number of works to return
- $publicFullText : bool
-
Only return publicly available, full-text works