Reference
ISBN Lookup
Look up any book by ISBN-10 or ISBN-13. Covers, authors, publishers, and more.
Try: 9780134190440 (Clean Code) ·
9780735619678 (The Lean Startup)
Developer Reference
Core Algorithm & Standalone Script
Standalone, zero-dependency JavaScript implementation powering this tool. Free to inspect, copy, and build upon.
const input = document.getElementById('isbnInput');
const btn = document.getElementById('lookupBtn');
const spinner = document.getElementById('spinnerWrap');
const errorMsg = document.getElementById('errorMsg');
const resultWrap = document.getElementById('resultWrap');
function formatISBN(raw) {
const digits = raw.replace(/\D/g, '');
if (digits.length === 13) {
return digits.replace(/(\d{3})(\d{1})(\d{2})(\d{6})(\d{1})/, '$1-$2-$3-$4-$5');
}
if (digits.length === 10) {
return digits.replace(/(\d{1})(\d{3})(\d{5})(\d{1})/, '$1-$2-$3-$4');
}
return raw;
}
input.addEventListener('input', () => {
const pos = input.selectionStart;
const raw = input.value.replace(/[^0-9X]/gi, '');
const formatted = formatISBN(raw);
input.value = formatted;
});
input.addEventListener('keydown', e => { if (e.key === 'Enter') doLookup(); });
btn.addEventListener('click', doLookup);
function tryExample(isbn) {
input.value = formatISBN(isbn);
doLookup();
}
function showError(msg) {
spinner.classList.add('hidden');
resultWrap.classList.add('hidden');
errorMsg.textContent = msg;
errorMsg.classList.remove('hidden');
}
function hideAll() {
spinner.classList.add('hidden');
errorMsg.classList.add('hidden');
resultWrap.classList.add('hidden');
}
async function doLookup() {
const raw = input.value.replace(/\D/g, '');
if (raw.length !== 10 && raw.length !== 13) {
showError('Please enter a valid ISBN-10 or ISBN-13.');
return;
}
hideAll();
spinner.classList.remove('hidden');
try {
const olData = await fetchOpenLibrary(raw);
if (olData) {
renderResult(olData);
return;
}
} catch(e) {}
try {
const gbData = await fetchGoogleBooks(raw);
if (gbData) {
renderResult(gbData);
return;
}
} catch(e) {}
showError('Book not found. Check the ISBN and try again.');
}
async function fetchOpenLibrary(isbn) {
const url = `https://openlibrary.org/api/books?bibkeys=ISBN:${isbn}&format=json&jscmd=data`;
const res = await fetch(url);
if (!res.ok) throw new Error('Network error');
const json = await res.json();
const key = `ISBN:${isbn}`;
if (!json[key]) return null;
const b = json[key];
const authors = (b.authors || []).map(a => a.name).join(', ') || 'Unknown';
const publisher = (b.publishers || []).map(p => p.name).join(', ') || null;
const year = b.publish_date || null;
const pages = b.number_of_pages || null;
const subjects = (b.subjects || []).slice(0, 10).map(s => typeof s === 'string' ? s : s.name);
const isbn13 = (b.identifiers?.isbn_13 || [])[0] || (isbn.length === 13 ? isbn : null);
const isbn10 = (b.identifiers?.isbn_10 || [])[0] || (isbn.length === 10 ? isbn : null);
const cover = b.cover ? (b.cover.large || b.cover.medium || b.cover.small) : null;
const olUrl = b.url || `https://openlibrary.org/isbn/${isbn}`;
const wcUrl = `https://www.worldcat.org/isbn/${isbn}`;
return { title: b.title, authors, publisher, year, pages, subjects, isbn13, isbn10, cover, olUrl, wcUrl };
}
async function fetchGoogleBooks(isbn) {
const url = `https://www.googleapis.com/books/v1/volumes?q=isbn:${isbn}`;
const res = await fetch(url);
if (!res.ok) throw new Error('Network error');
const json = await res.json();
if (!json.items || !json.items.length) return null;
const vol = json.items[0].volumeInfo;
const authors = (vol.authors || []).join(', ') || 'Unknown';
const publisher = vol.publisher || null;
const year = vol.publishedDate || null;
const pages = vol.pageCount || null;
const subjects = (vol.categories || []).slice(0, 10);
const identifiers = vol.industryIdentifiers || [];
const isbn13 = (identifiers.find(i => i.type === 'ISBN_13') || {}).identifier || null;
const isbn10 = (identifiers.find(i => i.type === 'ISBN_10') || {}).identifier || null;
const cover = vol.imageLinks ? (vol.imageLinks.thumbnail || vol.imageLinks.smallThumbnail) : null;
const olUrl = `https://openlibrary.org/isbn/${isbn}`;
const wcUrl = `https://www.worldcat.org/isbn/${isbn}`;
return { title: vol.title, authors, publisher, year, pages, subjects, isbn13, isbn10, cover, olUrl, wcUrl };
}
function renderResult(data) {
spinner.classList.add('hidden');
document.getElementById('bookTitle').textContent = data.title || 'Unknown Title';
document.getElementById('bookAuthors').textContent = data.authors || '';
document.getElementById('bookPublisher').textContent = data.publisher || '—';
document.getElementById('bookYear').textContent = data.year || '—';
document.getElementById('bookPages').textContent = data.pages ? `${data.pages} pages` : '—';
document.getElementById('bookIsbn13').textContent = data.isbn13 || '—';
document.getElementById('bookIsbn10').textContent = data.isbn10 || '—';
const coverImg = document.getElementById('coverImg');
const coverPlaceholder = document.getElementById('coverPlaceholder');
if (data.cover) {
coverImg.src = data.cover;
coverImg.style.display = 'block';
coverPlaceholder.style.display = 'none';
} else {
coverImg.style.display = 'none';
coverPlaceholder.style.display = 'flex';
}
const subjectWrap = document.getElementById('subjectWrap');
subjectWrap.innerHTML = data.subjects.length
? data.subjects.map(s => `<span class="subject-tag">${s}</span>`).join('')
: '';
const bookLinks = document.getElementById('bookLinks');
bookLinks.innerHTML = `
<a class="book-link" href="${data.olUrl}" target="_blank" rel="noopener">OpenLibrary ↗</a>
<a class="book-link" href="${data.wcUrl}" target="_blank" rel="noopener">WorldCat ↗</a>
`;
resultWrap.classList.remove('hidden');
}