pub struct OpenLibraryClient { /* private fields */ }Expand description
Async client for the Open Library API.
Construct via OpenLibraryClient::builder(). The client is Clone, Send, and Sync
— clone it cheaply to share across tasks.
Implementations§
Source§impl OpenLibraryClient
impl OpenLibraryClient
Fetch an Author by their Open Library ID (e.g. "OL23919A").
An Author OLID has the form OL<digits>A.
Fetch the works attributed to an Author, paginated.
limit must be 1–1000; offset is zero-based. The response includes
entries (the current page) and links for pagination.
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub async fn get_books(
&self,
bibkeys: &[String],
jscmd: BooksJsCmd,
) -> Result<HashMap<String, BooksApiEntry>>
pub async fn get_books( &self, bibkeys: &[String], jscmd: BooksJsCmd, ) -> Result<HashMap<String, BooksApiEntry>>
Query the /api/books endpoint using bibliographic keys.
bibkeys is a list of strings like "ISBN:0451450523", "OCLC:45883427",
"LCCN:2004046975", "OLID:OL7408846M", or "ID:5428012".
jscmd controls how much data is returned (Data, Details, or ViewApi).
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub async fn get_recent_changes(
&self,
params: ChangesParams,
) -> Result<Vec<RecentChange>>
pub async fn get_recent_changes( &self, params: ChangesParams, ) -> Result<Vec<RecentChange>>
Fetch the global recent-changes feed.
Sourcepub async fn get_changes_by_date(
&self,
date: &str,
params: ChangesParams,
) -> Result<Vec<RecentChange>>
pub async fn get_changes_by_date( &self, date: &str, params: ChangesParams, ) -> Result<Vec<RecentChange>>
Fetch recent changes for a specific date (YYYY-MM-DD).
Sourcepub async fn get_changes_by_kind(
&self,
kind: &ChangeKind,
params: ChangesParams,
) -> Result<Vec<RecentChange>>
pub async fn get_changes_by_kind( &self, kind: &ChangeKind, params: ChangesParams, ) -> Result<Vec<RecentChange>>
Fetch recent changes of a specific kind.
Sourcepub async fn get_changes_by_date_and_kind(
&self,
date: &str,
kind: &ChangeKind,
params: ChangesParams,
) -> Result<Vec<RecentChange>>
pub async fn get_changes_by_date_and_kind( &self, date: &str, kind: &ChangeKind, params: ChangesParams, ) -> Result<Vec<RecentChange>>
Fetch recent changes for a specific date and kind.
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub fn cover_url(&self, key: CoverKey, value: &str, size: ImageSize) -> Url
pub fn cover_url(&self, key: CoverKey, value: &str, size: ImageSize) -> Url
Build a cover image URL without making an HTTP request.
Example: cover_url(CoverKey::Id, "5428012", ImageSize::Large)
→ https://covers.openlibrary.org/b/id/5428012-L.jpg
Build an author photo URL without making an HTTP request.
olid must be a valid author OLID (e.g. "OL23919A").
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub async fn get_edition(&self, id: &str) -> Result<Edition>
pub async fn get_edition(&self, id: &str) -> Result<Edition>
Fetch an Edition by its Open Library ID (e.g. "OL7353617M").
An Edition OLID has the form OL<digits>M.
Sourcepub async fn get_edition_by_isbn(&self, isbn: &str) -> Result<Edition>
pub async fn get_edition_by_isbn(&self, isbn: &str) -> Result<Edition>
Fetch an Edition by ISBN-10 or ISBN-13.
Hyphens and spaces in the ISBN are stripped automatically. Both check digits are validated before the request is made.
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub async fn get_resource_history(&self, key: &str) -> Result<Vec<HistoryEntry>>
pub async fn get_resource_history(&self, key: &str) -> Result<Vec<HistoryEntry>>
Fetch the revision history for any Open Library resource.
key is an absolute path like /works/OL45804W or /books/OL7353617M.
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub async fn get_user_lists(
&self,
username: &str,
limit: u32,
offset: u32,
) -> Result<UserLists>
pub async fn get_user_lists( &self, username: &str, limit: u32, offset: u32, ) -> Result<UserLists>
Fetch all public lists belonging to a user.
Sourcepub async fn get_list(&self, username: &str, list_id: &str) -> Result<List>
pub async fn get_list(&self, username: &str, list_id: &str) -> Result<List>
Fetch a single list.
Sourcepub async fn get_list_editions(
&self,
username: &str,
list_id: &str,
limit: u32,
offset: u32,
) -> Result<ListEditions>
pub async fn get_list_editions( &self, username: &str, list_id: &str, limit: u32, offset: u32, ) -> Result<ListEditions>
Fetch the editions contained in a list.
Sourcepub async fn get_list_subjects(
&self,
username: &str,
list_id: &str,
) -> Result<ListSubjects>
pub async fn get_list_subjects( &self, username: &str, list_id: &str, ) -> Result<ListSubjects>
Fetch the subjects covered by a list.
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub async fn read_volume(
&self,
id_type: VolumeIdType,
id_value: &str,
) -> Result<VolumesResponse>
pub async fn read_volume( &self, id_type: VolumeIdType, id_value: &str, ) -> Result<VolumesResponse>
Look up a single volume by identifier type and value.
Example: read_volume(VolumeIdType::Isbn, "0451450523").
Sourcepub async fn read_volumes_batch(
&self,
requests: &[String],
) -> Result<VolumesResponse>
pub async fn read_volumes_batch( &self, requests: &[String], ) -> Result<VolumesResponse>
Batch-look up multiple volumes.
requests is a list of "type/value" strings, e.g. ["isbn/0451450523", "oclc/45883427"].
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub async fn query(
&self,
type_: &str,
fields: &HashMap<String, String>,
limit: u32,
offset: u32,
) -> Result<QueryResponse>
pub async fn query( &self, type_: &str, fields: &HashMap<String, String>, limit: u32, offset: u32, ) -> Result<QueryResponse>
Execute a generic query against the /query.json endpoint.
type_ must be one of /type/edition, /type/work, /type/author, etc.
fields is a map of field name → value to filter on.
limit controls the number of results (max 1000).
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub async fn get_want_to_read(&self, username: &str) -> Result<ReadingLog>
pub async fn get_want_to_read(&self, username: &str) -> Result<ReadingLog>
Books on the user’s “Want to Read” shelf.
Sourcepub async fn get_currently_reading(&self, username: &str) -> Result<ReadingLog>
pub async fn get_currently_reading(&self, username: &str) -> Result<ReadingLog>
Books the user is currently reading.
Sourcepub async fn get_already_read(&self, username: &str) -> Result<ReadingLog>
pub async fn get_already_read(&self, username: &str) -> Result<ReadingLog>
Books the user has already read.
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub async fn search(
&self,
params: SearchParams,
) -> Result<SearchResponse<BookDoc>>
pub async fn search( &self, params: SearchParams, ) -> Result<SearchResponse<BookDoc>>
Search for books and works across the Open Library catalogue.
At least one of q, title, author, isbn, or subject must be set.
All other SearchParams fields are optional filters or pagination controls.
Returns a SearchResponse<BookDoc> where num_found is the total match
count and docs is the current page.
Search the Open Library author index.
params.q is required and must be non-empty.
Sourcepub async fn search_subjects(
&self,
query: &str,
) -> Result<SearchResponse<SubjectDoc>>
pub async fn search_subjects( &self, query: &str, ) -> Result<SearchResponse<SubjectDoc>>
Search the Open Library subject index.
query is a free-text search term (non-empty, ≤ 1000 chars).
Sourcepub async fn search_lists(
&self,
query: &str,
limit: Option<u32>,
) -> Result<SearchResponse<ListDoc>>
pub async fn search_lists( &self, query: &str, limit: Option<u32>, ) -> Result<SearchResponse<ListDoc>>
Search public user-created reading lists.
query is a free-text search term. limit is clamped to 1–1000.
Sourcepub async fn search_inside(
&self,
query: &str,
limit: Option<u32>,
) -> Result<SearchResponse<InsideDoc>>
pub async fn search_inside( &self, query: &str, limit: Option<u32>, ) -> Result<SearchResponse<InsideDoc>>
Full-text search inside the text of scanned books (Internet Archive).
query is a phrase or keyword. limit is clamped to 1–1000.
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub async fn get_subject(
&self,
slug: &str,
params: SubjectParams,
) -> Result<Subject>
pub async fn get_subject( &self, slug: &str, params: SubjectParams, ) -> Result<Subject>
Fetch a Subject by its URL slug (e.g. "love", "science_fiction").
The slug must be lowercase ASCII letters, digits, and underscores only
([a-z0-9_]+, ≤ 200 chars). Pass details: Some(true) in params to
receive related subjects, top authors, and top publishers alongside the
work list.
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub async fn get_work(&self, id: &str) -> Result<Work>
pub async fn get_work(&self, id: &str) -> Result<Work>
Fetch a Work by its Open Library ID (e.g. "OL45804W").
Sourcepub async fn get_work_editions(
&self,
id: &str,
limit: u32,
offset: u32,
) -> Result<WorkEditions>
pub async fn get_work_editions( &self, id: &str, limit: u32, offset: u32, ) -> Result<WorkEditions>
Fetch the editions belonging to a Work.
Sourcepub async fn get_work_ratings(&self, id: &str) -> Result<WorkRatings>
pub async fn get_work_ratings(&self, id: &str) -> Result<WorkRatings>
Fetch community ratings for a Work.
Sourcepub async fn get_work_bookshelves(&self, id: &str) -> Result<WorkBookshelves>
pub async fn get_work_bookshelves(&self, id: &str) -> Result<WorkBookshelves>
Fetch bookshelf counts (want-to-read, currently reading, already read) for a Work.
Source§impl OpenLibraryClient
impl OpenLibraryClient
Sourcepub fn builder() -> OpenLibraryClientBuilder
pub fn builder() -> OpenLibraryClientBuilder
Start building a client with default settings.
Trait Implementations§
Source§impl Clone for OpenLibraryClient
impl Clone for OpenLibraryClient
Source§fn clone(&self) -> OpenLibraryClient
fn clone(&self) -> OpenLibraryClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more