Reputation: 3
I'm making a search bar that brings up a book list from Google books based on a search term. It brings up title, author, isbn, etc. That part of the app currently all works.
Each list entry has a button, and on clicking it, I want information to come up showing whether the book is available for digital borrowing from Open Library. So I need a second API from open library, to take the isbn that google books returns, and use that to identify if the book is available on OL for digital borrowing.
I'm using isbn because that seems the most specific.
The first GoogleBooks call returns multiple data which is split into properties, e.g.
var bookTitle = book.volumeInfo.title;
var bookAuthor = book.volumeInfo.authors;
var bookDescription = book.volumeInfo.description
var bookThumbnail = book.volumeInfo.imageLinks.smallThumbnail;
var isbn = book.volumeInfo.industryIdentifiers[0].identifier;
openlibrary api can filter by book availability, e.g.
https://openlibrary.org/search.json?q=harry%20potter&fields=*,availability&limit=1
I need to know what the data property of the book availability is. For instance the google books ISBN is 'volumeInfo.industryIdentifiers[0].identifier'. I need the name of that property but for open library book availability.
From what I've found I think it's something like 'editions.ebook_access' but I'm not sure. I want to be able to refer to it so I can get it to display on the page.
Edit:
var fetchRequest = function() {
var isbn = '0451526538'
var searchURL = `https://openlibrary.org/api/books?bibkeys=${isbn}&format=json&jscmd=data`;
fetch(searchURL)
.then(function(response) {
return response.json();
})
.then(function(response2) {
return response2.items.map(function(book) {
createBookList(book)
}) })
.catch( function() {
console.log(`There was an error with the fetch request`);
}); }
Part that links the data properties:
bookEPUB.textContent = 'This book is available to borrow in ePUB format';
bookEPUB.href = 'book.ebooks.availability.epub_url';
bookPDF.textContent = 'This book is available to borrow in PDF format';
bookPDF.href = 'book.ebooks.availability.pdf_url';
bookTEXT.textContent = 'This book is available to borrow in TEXT format';
bookTEXT.href = 'book.ebooks.availability.text_url';
Upvotes: 0
Views: 272
Reputation: 114
I think you can use the OpenLibrary API in this format.
https://openlibrary.org/api/books?bibkeys={ISBN_number}&format=json&jscmd=data
Write ISBN number of the book which you want to check availability for and it will give you book availability of that book in ebooks
property of the response as shown below.
Upvotes: 0