Skip to content

sok.apis.books.open_library_api

Open Library API implementation.

API Documentation: https://openlibrary.org/developers/api Note: Open Library API is free and requires no API key.

OpenLibraryApi

class OpenLibraryApi()

Bases: BaseAPI

Open Library API implementation for book search and metadata.

Free API providing access to millions of books without requiring an API key.

Initialize Open Library API (no API key required).

Source

supported_content_typesproperty

List[ContentType]

Get supported content types.

supported_media_typesproperty

List[MediaType]

Get supported media types.

get_detailsasync

async def get_details(
item_id: str,
content_type: ContentType,
**kwargs,
) -> Dict[str, Any]:

Get detailed book information from Open Library.

Parameters

NameTypeDescription
item_idstrOpen Library work key (e.g., '/works/OL123W').
content_typeContentTypeType of content.
**kwargsAdditional parameters.

Returns

  • Dict[str, Any]Dictionary containing book details.
Source
async def get_related_items(
item_id: str,
content_type: ContentType,
**kwargs,
) -> List[Dict[str, Any]]:

Get related items (not supported by Open Library).

Parameters

NameTypeDescription
item_idstrItem identifier.
content_typeContentTypeType of content.
**kwargsAdditional parameters.

Raises

  • NotImplementedErrorAlways raised as this API doesn't support related items.
Source
async def search(
query: str,
content_type: ContentType,
**kwargs,
) -> Dict[str, Any]:

Search for books on Open Library.

Parameters

NameTypeDescription
querystrSearch query string.
content_typeContentTypeType of content to search for.
**kwargsAdditional parameters (max_results).

Returns

  • Dict[str, Any]Dictionary containing search results.
Source
Built with Kiln