Skip to main content

OpenLibraryClient

Struct OpenLibraryClient 

Source
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

Source

pub async fn get_author(&self, id: &str) -> Result<Author>

Fetch an Author by their Open Library ID (e.g. "OL23919A").

An Author OLID has the form OL<digits>A.

Source

pub async fn get_author_works( &self, id: &str, limit: u32, offset: u32, ) -> Result<AuthorWorks>

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

Source

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

Source

pub async fn get_recent_changes( &self, params: ChangesParams, ) -> Result<Vec<RecentChange>>

Fetch the global recent-changes feed.

Source

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).

Source

pub async fn get_changes_by_kind( &self, kind: &ChangeKind, params: ChangesParams, ) -> Result<Vec<RecentChange>>

Fetch recent changes of a specific kind.

Source

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

Source

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

Source

pub fn author_photo_url(&self, olid: &str, size: ImageSize) -> Result<Url>

Build an author photo URL without making an HTTP request.

olid must be a valid author OLID (e.g. "OL23919A").

Source

pub async fn cover_meta( &self, key: CoverKey, value: &str, ) -> Result<Vec<CoverMeta>>

Fetch JSON metadata for a cover image.

Note: the covers API returns an object whose single key is the bibkey.

Source§

impl OpenLibraryClient

Source

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.

Source

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

Source

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

Source

pub async fn get_user_lists( &self, username: &str, limit: u32, offset: u32, ) -> Result<UserLists>

Fetch all public lists belonging to a user.

Source

pub async fn get_list(&self, username: &str, list_id: &str) -> Result<List>

Fetch a single list.

Source

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.

Source

pub async fn get_list_subjects( &self, username: &str, list_id: &str, ) -> Result<ListSubjects>

Fetch the subjects covered by a list.

Source

pub async fn get_list_seeds( &self, username: &str, list_id: &str, ) -> Result<ListSeeds>

Fetch the seeds (raw items) in a list.

Source§

impl OpenLibraryClient

Source

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").

Source

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

Source

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

Source

pub async fn get_want_to_read(&self, username: &str) -> Result<ReadingLog>

Books on the user’s “Want to Read” shelf.

Source

pub async fn get_currently_reading(&self, username: &str) -> Result<ReadingLog>

Books the user is currently reading.

Source

pub async fn get_already_read(&self, username: &str) -> Result<ReadingLog>

Books the user has already read.

Source§

impl OpenLibraryClient

Source

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.

Source

pub async fn search_authors( &self, params: AuthorSearchParams, ) -> Result<SearchResponse<AuthorDoc>>

Search the Open Library author index.

params.q is required and must be non-empty.

Source

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).

Source

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.

Source

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

Source

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

Source

pub async fn get_work(&self, id: &str) -> Result<Work>

Fetch a Work by its Open Library ID (e.g. "OL45804W").

Source

pub async fn get_work_editions( &self, id: &str, limit: u32, offset: u32, ) -> Result<WorkEditions>

Fetch the editions belonging to a Work.

Source

pub async fn get_work_ratings(&self, id: &str) -> Result<WorkRatings>

Fetch community ratings for a Work.

Source

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

Source

pub fn builder() -> OpenLibraryClientBuilder

Start building a client with default settings.

Trait Implementations§

Source§

impl Clone for OpenLibraryClient

Source§

fn clone(&self) -> OpenLibraryClient

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more