Search Japanese public libraries for book availability, powered by Calil. Type a title or author, pick a book, and see which of your local libraries have it — no sign-up, no server, no build step.
- Search by title or author — via the Google Books API (optional API key for reliability, see below)
- Live availability — checks your chosen library system(s) via Calil and polls until results are ready
- Default library — set your prefecture/city once; every search checks that library system automatically
- Multiple systems per city — some cities have more than one library system (ward library, university libraries, etc.) — pick which ones to include
- Direct links — each library and reservation link goes straight to the library's own catalog/reserve page
- Clear button — reset the search field and results in one tap to start a new search
- Light & dark — follows your system colour scheme
- No dependencies — pure HTML / CSS / JavaScript, runs entirely client-side
- Open
index.html(or the deployed site) - Tap ⚙️ and:
- Paste your Calil API key (get one free here) and save it
- Optionally paste a Google Books API key (get one free here) for reliable search (see below)
- Pick your prefecture and city, choose which library system(s) to include, and save as default
- Search for a book by title or author
- Tap a result to see availability across your default library system(s)
- Book search: Google Books API (
volumesendpoint) — CORS-enabled. Coverage of obscure/library-only Japanese titles is imperfect since it's a general book catalog, not a JP library-specific one. - Google Books quota: keyless requests share a global anonymous quota across every app calling the API without a key — it can return
429due to unrelated traffic elsewhere, independent of your own usage (confirmed: identical429reproduced from two unrelated networks on the same day). Adding a free Google Cloud API key in settings gives the app its own private quota and avoids this. - Availability & library data: Calil API
/checkand/libraryendpoints. Despite the published docs only mentioning JSONP, both endpoints return realAccess-Control-Allow-Origin: *CORS headers when called withcallback=no, so the whole app runs via plainfetch()— no proxy or JSONP needed. - Async polling:
/checkcan returncontinue: 1while Calil queries the library system live. The app polls the same endpoint with the returnedsessionid every 2 seconds (Calil's documented minimum interval) untilcontinue: 0or ~30 seconds elapse. - API key storage: your Calil
appkeyis entered in the settings panel (as a password-masked field, with a one-tap "削除" to clear it) and stored only in the browser'slocalStorage— it is never committed to this repo. Because there's no backend, the key is still visible in outgoing network requests from your browser (unavoidable without a server-side proxy, which was ruled out for this app); Calil's rate limit (1,000 requests/hour) is tracked per key+IP. - Attribution: per Calil's terms, every library name and reservation link is linked back to the corresponding
calil.jpbook/library page. - City → library system resolution: selecting a city calls Calil's
/libraryendpoint, groups the returned libraries bysystemid, and lets you opt in/out per system (university libraries are unchecked by default). - Security hardening: all externally-sourced text (book titles, library/system names, reservation URLs) is rendered via
textContent/DOM construction rather thaninnerHTML, so it can never be interpreted as markup. Reservation URLs are further validated to behttp(s)://before being used as a link target, rejectingjavascript:/data:and similar schemes. AContent-Security-Policymeta tag restricts network/script/style/image origins to only what the app needs (self,api.calil.jp,www.googleapis.com, Google Books thumbnail hosts). - Accessibility: search results are real
<button>elements (keyboard/screen-reader operable, not just clickable<li>s). The settings panel is a properrole="dialog"with focus moved in on open, restored on close, Tab trapped inside, and Escape to close.
# No install needed — just open the file
open index.htmlFiles:
index.html # App shell + settings modal
style.css # All styles (CSS variables, responsive, light/dark)
script.js # App logic (search, Calil calls, polling, rendering)
- Header: replace the emoji next to the app name with the app icon (
icons/app-icon.svg, rounded corners, decorativealt="")
- Replace the emoji favicon with the app icon: SVG favicon, 32×32 PNG fallback, and a 180×180
apple-touch-iconfor iOS home screens
- Fix: on mobile (reported on iPhone Chrome), opening the on-screen keyboard to type an API key could scroll the field itself out of view above the fold. The fixed-position settings modal now locks background scroll while open, uses
dvh(dynamic viewport height, accounts for the keyboard) instead of plainvhfor its max height, and explicitly scrolls a focused field back into view once the keyboard finishes animating in
Security:
- Replaced
innerHTMLrendering of book titles, library/system names, and reservation links with safe DOM construction (textContent+createElement) — external API data could otherwise inject markup - Reservation URLs are validated to be
http:/https:before use, rejectingjavascript:/data:schemes - Added a
Content-Security-Policyrestricting script/style/connect/img origins to only what the app needs - API key fields are now password-masked (
type="password"), with a "削除" button to clear a saved key br_defaultinlocalStorageis now defensively parsed — a corrupted/malformed value is discarded instead of crashing the app on load
Accessibility / usability:
- Search results are now real
<button>elements — keyboard/screen-reader operable, not just clickable list items - Settings modal is a proper
role="dialog": focus moves in on open and is restored on close, Tab is trapped inside, Escape closes it - Saving an API key or default library now shows a brief inline confirmation instead of saving silently
- The search button disables while a search is in flight, preventing duplicate overlapping requests
- Selecting a different book while a previous availability check is still polling now cancels the stale request (via
AbortController) instead of racing it - Fixed the search row on narrow screens (input + 検索 + クリア) to wrap into two rows instead of squeezing all three into one
Not implemented: moving API keys behind a server-side proxy — this app is deliberately client-side-only (no hosting account available for a proxy), a tradeoff already made earlier; the mitigations above (masked fields, clear-key button, CSP) address the practical risk within that constraint.
- Add a "クリア" (Clear) button next to search that resets the search field, results, and availability panel for a fresh search
- Selecting a book now hides the search results list, showing only the 蔵書状況 (availability) panel instead of both at once
- Show the current version number in the footer, so you can confirm the deployed site has actually updated (GitHub Pages caches assets for a while after each release)
- Add optional Google Books API key setting to avoid the shared anonymous-quota
429errors that keyless search can hit - Clearer error messages distinguishing quota issues from other search failures
- Initial release
- Title/author search via Google Books
- Default library system setup (prefecture → city → systemid selection)
- Availability check with async polling via Calil
- Attribution links per Calil's terms of use
- Responsive layout with light/dark support