Page 1 of 1

Google books API searching by ISBN

Posted: Thu Apr 22, 2021 8:41 am
by Stevyn
Google books API searching by ISBN

https://developers.google.com/books/docs/v1/using
https://jonathanmh.com/searching-google ... uickstart/

Code: Select all

https://www.googleapis.com/books/v1/volumes?q=isbn:<your_isbn_here>
for example

https://www.googleapis.com/books/v1/vol ... 0735619670

Re: Google books API searching by ISBN

Posted: Thu Apr 22, 2021 9:14 am
by Stevyn

Code: Select all

function getBookDetails(isbn) {

  // Query the book database by ISBN code.
  isbn = isbn || "9781451648546"; // Steve Jobs book

  var url = "https://www.googleapis.com/books/v1/volumes?q=isbn:" + isbn;

  var response = UrlFetchApp.fetch(url);
  var results = JSON.parse(response);

  if (results.totalItems) {

    // There'll be only 1 book per ISBN
    var book = results.items[0];

    var title = (book["volumeInfo"]["title"]);
    var subtitle = (book["volumeInfo"]["subtitle"]);
    var authors = (book["volumeInfo"]["authors"]);
    var printType = (book["volumeInfo"]["printType"]);
    var pageCount = (book["volumeInfo"]["pageCount"]);
    var publisher = (book["volumeInfo"]["publisher"]);
    var publishedDate = (book["volumeInfo"]["publishedDate"]);
    var webReaderLink = (book["accessInfo"]["webReaderLink"]);

    // For debugging
    Logger.log(book);

  }

}

Re: Google books API searching by ISBN

Posted: Wed May 05, 2021 7:50 pm
by Stevyn
Save image from google books

https://stackoverflow.com/questions/724 ... om-php-url

Code: Select all

$url = 'http://example.com/image.php';
$img = '/my/folder/flower.gif';
file_put_contents($img, file_get_contents($url));
or via curl

Code: Select all

$ch = curl_init('http://example.com/image.php');
$fp = fopen('/my/folder/flower.gif', 'wb');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);