feat(client): add get_many() and get_many_by_isbn() bulk fetch#440
Open
mekarpeles wants to merge 1 commit into
Open
feat(client): add get_many() and get_many_by_isbn() bulk fetch#440mekarpeles wants to merge 1 commit into
mekarpeles wants to merge 1 commit into
Conversation
Add two new methods to OpenLibrary for batch fetching entities: - ol.get_many(olids): fetches any mix of Works, Editions, Authors in a single /api/get_many.json call. Returns typed objects; null/missing entries are silently skipped. - ol.get_many_by_isbn(isbns): resolves ISBNs to OLIDs via one /api/books.json call, then fetches full Edition data via get_many(). Two total HTTP calls regardless of batch size. Both methods are tested (9 new unit tests, 55 total passing).
This was referenced Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two new methods to
OpenLibraryfor bulk entity fetching:ol.get_many(olids)Fetches any mix of Works, Editions, and Authors in a single
/api/get_many.jsoncall. Returns a list of typed objects in response order. Documents not found in OL are silently skipped.ol.get_many_by_isbn(isbns)Resolves ISBNs → OLIDs via one
/api/books.jsoncall, then fetches full Edition data viaget_many(). Two total HTTP calls regardless of batch size.Why
Single-entity fetches (
Work.get(),Edition.get()) make one HTTP request per entity. For import pipelines and bulk enrichment, this is prohibitive. The/api/get_many.jsonendpoint already exists on OL and supports hundreds of keys per request.Testing
TestGetManycovering: empty input, Work/Edition/Author dispatch, null-doc skipping, URL construction, andget_many_by_isbnISBN→OLID resolutionpre-commit run --filescleanRelated
Part of a series making
openlibrary-clientproduction-ready for local Docker dev and bulk operations:from_local(), env vars,health_check()(open)Closes #440