Google books API searching by ISBN

Develop software to help the small bookshop owner to catalog & sell online.

New Project started 2021
Post Reply
User avatar
Stevyn
SysOp
Posts:1776
Joined:Mon Nov 09, 2009 10:03 am
Location:Japan
Contact:
Google books API searching by ISBN

Post by Stevyn » Thu Apr 22, 2021 8:41 am

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
Contact me directly: Ironfeatherbooks (@) gmail.com

Image

User avatar
Stevyn
SysOp
Posts:1776
Joined:Mon Nov 09, 2009 10:03 am
Location:Japan
Contact:

Re: Google books API searching by ISBN

Post by Stevyn » Thu Apr 22, 2021 9:14 am

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);

  }

}
Contact me directly: Ironfeatherbooks (@) gmail.com

Image

User avatar
Stevyn
SysOp
Posts:1776
Joined:Mon Nov 09, 2009 10:03 am
Location:Japan
Contact:

Re: Google books API searching by ISBN

Post by Stevyn » Wed May 05, 2021 7:50 pm

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);
Contact me directly: Ironfeatherbooks (@) gmail.com

Image

Post Reply