Subscribe to this feed July 10, 2007

PHP ISBN Lookup Tool

Basically, I needed a simple tool to help me catalogue my home book catalogue of over 1,000 books without having to type them all in by hand (or copy and paste from Amazon or wherever). Fortunately, I found this freely available online database, ISBNdb.com, which has a remote access application programming interface (API) designed to allow other websites and standalone applications use the vast collection of data collected by ISBNdb.com since 2003. Currently, they have just under 3 million books in their database - which is very substantial and sufficient for my purposes. While I needed this information for cataloging my home library, you could obviously use it for other uses such as building and verifying bookstore inventories, creating your own bookstore, automated cross-merchant price lookups over messaging devices or phones, or whatever.

Requirements

  • PHP 5.0.x (needed because I'm using the simplexml_loadfile() function to parse the XML generated by the ISBNdb API. Since I don't have PHP5 up and running on this site, I don't have a working demo. Sorry.)
  • ISBNdb Access Key (500 server requests/day free with any account. Sign up for a free account at: https://isbndb.com/account/create.html)
  • Barcode Scanner (Optional, but nice to have. I found one off of eBay for $.01 (+$10 shipping), MODEL NUMBER: LS1006-1000, SERIAL NUMBER SZ497, and it works like a charm!

Application Description

With this script, you simily enter a 10 or 13 digit ISBN number into the single form field and click submit. (with the barcode scanner I got, you just scan and a CR is automatically entered, so you don't have to type anything). The tool will retrieve and parse an XML file from the ISBNdb.com site, and print the results in a nicely formatted table, showing title, long title, authors, Dewey decimal number, LCC number, average new price, average used price, and estimated value (based on the condition of the book, which you can optionally enter as an A, B, C, D, or F "flag" prior to the ISBN number. In addition, the script will write the data to a text file, called "books.txt" in a very simple pipe "|" deliniated format.

That's pretty much it. You can easily configure it to your own uses, or use it to develop your own intereface to ISBNdb.com's API - which is really the meat of this tool.

Screenshots

Here's a screenshot. Sorry I don't have a working demo up and running:

PHP ISBN Lookup Tool

Source Code

The source code is available here. I've commented most of the sections, although if you have a question, feel free to contact me.

Good luck and have fun!

22 Comments
#22 shikha wrote at 5:23 am, June 19, 2009 GMT answer

how to get cover page image of book using PHP ISBN Lookup Tool

#20 Dan Gardner wrote at 7:17 pm, May 19, 2009 GMT answer

I am trying to develop a xcel data base of over 5000 different titles. Is there a program for sale that will automatically fill the cells when I do the scan?

#21 John Dawson wrote at 9:37 pm, May 19, 2009 GMT answer homepage

the ISBN tool that I wrote will automatically generate a comma-separated row of metadata for each book. You can save this data as a CSV file (e.g., "books.csv") and open in MS Excel. I also had over 5,000 titles in my library which I was easily able to capture using this tool.

#19 edward sharp wrote at 3:20 pm, February 25, 2009 GMT answer homepage

very cool stuff, indeed!

#18 edward sharp wrote at 3:19 pm, February 25, 2009 GMT answer homepage

very cool stuff, indeed!

#13 James D wrote at 2:56 am, December 24, 2008 GMT answer homepage

Going to use this on my textbook website to look up prices and such. Good work, now I just have to find out how to implement it.

#12 Chris Flores wrote at 7:03 am, November 13, 2008 GMT answer

Had problems with the code. Here is how i fixed it:

$url_details_ch = curl_init("http://isbndb.com/api/books.xml?access_key=$accessKey&results=details&index1=isbn&value1=$query");
curl_setopt($url_details_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($url_details_ch, CURLOPT_HEADER, 0);
$url_details_data = curl_exec($url_details_ch);
curl_close($url_details_ch);
$xml_details = new SimpleXmlElement($url_details_data, LIBXML_NOCDATA);

#14 David M wrote at 5:44 pm, January 3, 2009 GMT answer homepage

I am running php5 but having problems with the original script loading the file, that is,I am getting the "no file loaded" response.

I have not tried your curl script. Any suggestions? Were you having trouble getting the file loaded.

#15 John Dawson wrote at 6:17 pm, January 3, 2009 GMT answer homepage

it sounds like a problem with the simplexml_load_file() function. check to see if simplexml is enabled in phpinfo(). if yes, then it's probably a problem with your api url. check to make sure you can access it directly (i.e., isbndb.com/api/books.xml)

#16 David M wrote at 10:44 pm, January 3, 2009 GMT answer homepage

Thanks for the quick reply.
I checked the php.ini and don't see a reference to simplexml_load_file()
The tech support folks sez it is enabled.

Can you paste the php.ini entry from your server? That may help.

The link seems to work ok. I've got an access key and it works well with the url in my browser.

Thanks for the assistance.

#17 John Dawson wrote at 12:14 am, January 4, 2009 GMT answer homepage

Hi David,

There's not a reference to simplexml in php.ini because it's enabled by default in php5. I was earlier referring to phpinfo(). To check server settings, create this file, and save as phpinfo.php:

<?php
phpinfo();
?>

And save it at the root of your server.

Then look for simplexml.

John

#11 Chris Flores wrote at 7:02 am, November 13, 2008 GMT answer

Had problems with it on our website. I changed it to use cURL.

Here is the example:

$url_details_ch = curl_init("http://isbndb.com/api/books.xml?access_key=$accessKey&results=details&index1=isbn&value1=$query");
curl_setopt($url_details_ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($url_details_ch, CURLOPT_HEADER, 0);
$url_details_data = curl_exec($url_details_ch);
curl_close($url_details_ch);
$xml_details = new SimpleXmlElement($url_details_data, LIBXML_NOCDATA);


Works perfectly now!!

#8 Ryan Gannon wrote at 12:13 am, January 9, 2008 GMT answer homepage

Hey, hope you don't mind me posting this but I've used this as the core of a software I wrote.

It's intended for libraries. You can find it here:
blog.ryangannon.com/category/php-personal-book-library-database/

Lots of thanks,
Ryan.

#9 John Dawson wrote at 12:57 am, January 9, 2008 GMT answer homepage

No problem, Ryan. Glad you found it useful!

John

#10 paeal wrote at 12:43 pm, June 15, 2008 GMT answer homepage
#2 Ashton Thomas wrote at 5:45 am, December 26, 2007 GMT answer homepage

Hey, your tool is very helpful, but I can't get it to work quite right.

I have the script up and supposedly working, but when i enter the [condition]&[isbn] all i get is a blank response page.

can you please help me with this??

I am a novice to PHP but have a large project in it so I'm trying to catch up.

everything looks to be in place.

It is the exact file that is on this website.

Thank you very much and Happy Holidays

-Ashton

#3 Ashton Thomas wrote at 5:46 am, December 26, 2007 GMT answer homepage

Hey, your tool is very helpful, but I can't get it to work quite right.

I have the script up and supposedly working, but when i enter the [condition]&[isbn] all i get is a blank response page.

can you please help me with this??

I am a novice to PHP but have a large project in it so I'm trying to catch up.

everything looks to be in place.

It is the exact file that is on this website.

Thank you very much and Happy Holidays

-Ashton

#4 John Dawson wrote at 6:17 am, December 26, 2007 GMT answer homepage

Hi Ashton, can you confirm that you are using PHP5 and have an API key?

#5 Ashton Thomas wrote at 4:24 pm, December 26, 2007 GMT answer homepage

Hey, Thank you for the reply

I do have an API Key ad have used it in basic URL queries.
However, I am running PHP 4.4.7
I will go about upgrading. Is this where the problem is??

thanks

#6 John Dawson wrote at 4:35 pm, December 26, 2007 GMT answer homepage

Yes, Ashton, because the simplexml_loadfile() function is not available in PHP 4.x

#7 Ashton Thomas wrote at 4:46 pm, December 26, 2007 GMT answer homepage

I have changed the extension from .php to .php5 and now it works correctly.

But when i enter the ino as [x][123456789] it does not work properly. i just have to enter the isbn alone and it works correctly

#1 Mathew M wrote at 5:44 pm, October 14, 2007 GMT answer homepage

This is a great tool for Booksellers on the web with excellent visibility. Highly reccommend it..

write a comment