A type-safe TypeScript SDK for the Open Library API.
Status: Work in progress π§
Open Library is an incredible open-source project β a free, editable catalog aiming to have one web page for every book ever published. But working with its API in TypeScript is painful:
- No type safety. Response shapes are undocumented, inconsistent, and polymorphic. A
descriptionfield might be astringor{ type: string; value: string }. Good luck. - No official TypeScript SDK. There's a Python client, but nothing for the JS/TS ecosystem.
- Verbose and scattered docs. You end up reading source code to understand what you'll actually get back.
@asmelabs/olib fixes all of that β Zod-validated responses, normalized types, and a clean API surface.
# bun bun add @asmelabs/olib # npm npm install @asmelabs/olib # yarn yarn add @asmelabs/olib # pnpm pnpm add @asmelabs/olib
import { createOpenLibraryClient } from "@asmelabs/olib"; const ol = createOpenLibraryClient(); // Search for books const results = await ol.search("Fantastic Mr Fox"); // #not implemented yet // Get a work by its Open Library ID const work = await ol.works.get("OL45804W"); // #not implemented yet // Get an edition by ISBN const edition = await ol.editions.getByISBN("9780140328721"); // #not implemented yet // Get an author const author = await ol.authors.get("OL34184A"); // Build a cover image URL const coverUrl = ol.covers.book("9780140328721").type("isbn").size("M").build(); // => "https://covers.openlibrary.org/b/isbn/9780140328721-M.jpg"
- π Type-safe β Full TypeScript types for all endpoints, powered by Zod schemas
- β Runtime validation β Responses are parsed and validated at runtime, not just at compile time
- π Universal β Works in Node.js, Bun, Deno, and browsers (uses
fetch) - π¦ Tree-shakeable β ESM-first, import only what you need
- π§© Normalized responses β Polymorphic fields like
descriptionare normalized to consistent types - π Covers helper β URL builder for book covers and author photos without extra API calls
| Module | Endpoints | Status |
|---|---|---|
| Search | Books, Authors, Subjects | #not implemented yet |
| Works | Get, Editions, Ratings, Bookshelves | #not implemented yet |
| Editions | Get, by ISBN | #not implemented yet |
| Authors | Get, Works | β |
| Covers | Book covers, Author photos (URL builder) | β |
| Subjects | Get | #not implemented yet |
β Full documentation coming soon.
- TypeScript β₯ 5.0
- A
fetch-compatible runtime (Node 18+, Bun, Deno, modern browsers)
Contributions are welcome! Please read the Contributing Guide before submitting a PR.
Built and maintained by Asme Labs.
Open Library is a project of the Internet Archive, a 501(c)(3) non-profit.