Replacing Google Books with Internet Archive Open Library as Custom Source

40 views
Skip to first unread message

Gabriel

unread,
Jun 16, 2026, 7:04:23 PM (12 days ago) Jun 16
to mementodatabase
You've probably experienced that Google Books often rejects lookup requests, making it unusable. Internet Archive's Open Library can easily be used as Custom Source when searching via ISBN barcode scan. Here's the custom source script if anyone finds it helpful:

function getBookInfo(isbn) {
  // The Open Library Books API endpoint
  var url = "https://www.openlibrary.org/api/books?bibkeys=ISBN:" + isbn + "&format=json&jscmd=data";
  var response = http().get(url);
 
  if (response.code == 200) {
    var data = JSON.parse(response.body);
    var bookKey = "ISBN:" + isbn;
    var book = data[bookKey];
   
    if (book) {
      // Extract author names into a single comma-separated string
      var authors = "";
      if (book.authors) {
        var authorList = [];
        for (var i = 0; i < book.authors.length; i++) {
          authorList.push(book.authors[i].name);
        }
        authors = authorList.join(", ");
      }
     
      // Return the array object Memento expects
      return [{
        // Memento UI fields (Required for the popup list)
        title: book.title,            
        desc: authors,                
        thumb: book.cover ? book.cover.medium : "",
       
        // Custom data fields we will map in the next step
        book_title: book.title,
        book_author: authors,
        isbn: isbn,
        book_date: book.publish_date || "",
        book_pages: book.number_of_pages ? book.number_of_pages.toString() : "",
        book_publisher: book.publishers ? book.publishers[0].name : "",
        book_cover: book.cover ? book.cover.large : ""
      }];
    } else {
      return [{ title: "No match found in Open Library" }];
    }
  }
  return [{ title: "API Error: " + response.code }];
}

// Execute the function using Memento's global 'query' variable
result(getBookInfo(query));
Reply all
Reply to author
Forward
0 new messages