Use when the user asks to look up online book metadata by ISBN, title, author, publication details, editions, subjects, covers, or Open Library source URLs.
100
100%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Use this file when you need exact CLI syntax, output shape, or script-specific failure handling.
scripts/lookup_book.pysource, lookup_type, query, num_found, and results.error and error_code and return a non-zero exit code.5; maximum limit is 20.15 seconds.python3 scripts/lookup_book.py --isbn 9780140328721Uses:
https://openlibrary.org/isbn/{isbn}.jsonhttps://openlibrary.org/search.json with the user-supplied ISBN for bounded enrichmentTypical success shape:
{
"source": "Open Library",
"lookup_type": "isbn",
"query": {
"isbn": "9780140328721"
},
"num_found": 1,
"results": [
{
"title": "Fantastic Mr. Fox",
"authors": ["Roald Dahl"],
"first_publish_year": 1970,
"publish_date": "October 1, 1988",
"publishers": ["Puffin"],
"isbn_10": [],
"isbn_13": ["9780140328721"],
"subjects": ["Foxes"],
"openlibrary_work_key": "/works/OL45804W",
"openlibrary_edition_key": "/books/OL7353617M",
"cover_urls": {
"small": "https://covers.openlibrary.org/b/id/15152634-S.jpg",
"medium": "https://covers.openlibrary.org/b/id/15152634-M.jpg",
"large": "https://covers.openlibrary.org/b/id/15152634-L.jpg"
},
"source_urls": {
"work": "https://openlibrary.org/works/OL45804W",
"work_api": "https://openlibrary.org/works/OL45804W.json",
"edition": "https://openlibrary.org/books/OL7353617M",
"edition_api": "https://openlibrary.org/books/OL7353617M.json",
"isbn_api": "https://openlibrary.org/isbn/9780140328721.json"
}
}
]
}If Open Library returns 404 for the ISBN, the script returns a successful no-match payload:
{
"source": "Open Library",
"lookup_type": "isbn",
"query": {
"isbn": "9780000000000"
},
"num_found": 0,
"results": []
}python3 scripts/lookup_book.py \
--title "The Left Hand of Darkness" \
--author "Ursula K. Le Guin" \
--limit 5Uses https://openlibrary.org/search.json with title, author, fields, and limit query parameters.
python3 scripts/lookup_book.py --query "octavia butler parable sower"Use broad query lookup when the user does not provide clean title/author or ISBN fields.
Each result normalizes:
titleauthorsfirst_publish_yearpublish_datepublishersisbn_10isbn_13subjectsopenlibrary_work_keyopenlibrary_edition_keycover_urlssource_urlsSearch results may omit fields that Open Library does not return for that record.
Common errors:
{"error": "--limit must be 20 or less", "error_code": "INVALID_LIMIT"}{"error": "--isbn must be a valid-looking ISBN-10 or ISBN-13", "error_code": "INVALID_ISBN"}{"error": "GET https://openlibrary.org/search.json?... failed: ...", "error_code": "NETWORK_ERROR"}{"error": "GET https://openlibrary.org/search.json?... returned invalid JSON", "error_code": "INVALID_JSON_RESPONSE"}Report these errors directly and do not fabricate book metadata.