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).
Sourcesupported_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
| Name | Type | Description |
|---|---|---|
item_id | str | Open Library work key (e.g., '/works/OL123W'). |
content_type | ContentType | Type of content. |
**kwargs | Additional parameters. |
Returns
Dict[str, Any]Dictionary containing book details.
get_related_itemsasync
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
| Name | Type | Description |
|---|---|---|
item_id | str | Item identifier. |
content_type | ContentType | Type of content. |
**kwargs | Additional parameters. |
Raises
NotImplementedErrorAlways raised as this API doesn't support related items.
searchasync
async def search( query: str, content_type: ContentType, **kwargs,) -> Dict[str, Any]:Search for books on Open Library.
Parameters
| Name | Type | Description |
|---|---|---|
query | str | Search query string. |
content_type | ContentType | Type of content to search for. |
**kwargs | Additional parameters (max_results). |
Returns
Dict[str, Any]Dictionary containing search results.