Book information by ISBN number using ASP.NET from Google API

Dear Friends,
In last 2 posts we have talked about ISBNDB.com(https://indiandotnet.wordpress.com/2012/10/24/book-detail-by-isbn-number-using-asp-net/)

& Wordcat.org (https://indiandotnet.wordpress.com/2012/10/24/book-details-by-isbn-using-asp-net-from-worldcat-org/).
Now here I am talking about one more great service provider which Google. We can use Google API to fetch book detail using ISBN number.
To use Google API you have to create account and register for API.

In this example I am not using API, I am just trying to access the detail directly using URL.
Below URL is used for providing the detail of the book using ISBN

https://www.googleapis.com/books/v1/volumes?q=0123344+ISBN

So let us start to fetch detail

As the response of this URL in JSON so for change I have used JSON parser here I have used JSON.NET which you can download from codeplex site.

The design of the page is same one textbox for ISBN and one search button. On search button click I wrote following code.

‘Step 1:- google API url responsible for returning the book detail in JASON format
Private Const GOOGLEAPIURL As String = “https://www.googleapis.com/books/v1/volumes?q=”

If Me.txtISBN.Text <> String.Empty Then
Dim requestURL As String

‘Step 2:- Reformed the URL to target particular ISBN number
requestURL = GOOGLEAPIURL + Me.txtISBN.Text.Trim() + “+isbn”

‘Step 3: created Http webrequest for URL
Dim wr As HttpWebRequest = HttpWebRequest.Create(requestURL)
‘Step4 : get the response of web request in http web response object
Dim resp As HttpWebResponse = wr.GetResponse()

‘Step 5: passes the response stream in stream reader
Dim sreader As New StreamReader(resp.GetResponseStream())
‘Step 6: parsing the reader(which is in Jason format) using JASON.NET

Dim rss = JObject.Parse(sreader.ReadToEnd())

‘Step 7: if object find the fetch the detail

If rss Is Nothing = False AndAlso rss.Count > 0 Then
Me.lblBookName.Text = rss.Item(“items”)(0).Item(“volumeInfo”).Item(“title”).ToString()
Me.lblAuthor.Text = rss.Item(“items”)(0).Item(“volumeInfo”).Item(“authors”).ToString().Replace(“[“, “”).Replace(“]”, “”).ToString()
Me.lblPublisher.Text = rss.Item(“items”)(0).Item(“volumeInfo”).Item(“publisher”).ToString()
Else
Me.lblMessage.Text = “Sorry ISBN Number not found, Please try different number.”
End If
Else
Me.lblMessage.Text = “Please enter the ISBN number”
End If

So in this way we have accessed book information from Google API URL without using API key.
Thanks & best regards,
Rajat Jaiswal

Book details by ISBN using ASP.NET from worldcat.org

Dear Friends,
In last post we have talked about ISBNDB.COM’s API and how to fetch the book detail using ISBN number from ISBNDB.com (https://indiandotnet.wordpress.com/2012/10/24/book-detail-by-isbn-number-using-asp-net/)

Now in this post we will talk about Worldcat.org, which is another famous book detail service provider.
It provides the response in XML

http://xisbn.worldcat.org/webservices/xid/isbn/1090280?method=getMetadata&format=xml&fl=*

 

So let us start with step 1

The page design is just simple an ISBN textbox and a search button.

So to access this I have created a WORLDCAT URL

Private Const WORLDCATURL As String = “http://xisbn.worldcat.org/webservices/xid/isbn/&#8221;

Now for change I have used Dataset here
Now on the search button click I did following code

If Me.txtISBN.Text <> String.Empty Then

‘Step2: Recreating the URL with specific ISBN number which provided by the end user
Dim requestURL As String
requestURL = WORLDCATURL + “/” + Me.txtISBN.Text.Trim() + “?method=getMetadata&format=xml&fl=*”

‘Step3: Created a xML document object and provided the Requested URL To it
Dim Doc As XmlDocument = New XmlDocument()
Doc.Load(requestURL)

‘ step 4: created dataset object and providing the XML reader to dataset
Dim ds As DataSet = New DataSet()
Dim xmlReader As XmlNodeReader = New XmlNodeReader(Doc)
ds.ReadXml(xmlReader)

‘Step 5: It will return 2 tables if the isbn number is correct so below is the logic to get book detail
If ds Is Nothing = False AndAlso ds.Tables(1).Rows.Count() > 0 Then
Me.lblBookName.Text = ds.Tables(1).Rows(0)(“title”).ToString()
Me.lblAuthor.Text = ds.Tables(1).Rows(0)(“author”).ToString()
Me.lblPublisher.Text = ds.Tables(1).Rows(0)(“publisher”).ToString()
Else
Me.lblMessage.Text = “Sorry ISBN Number not found, Please try different number.”
End If
Else
Me.lblMessage.Text = “Please enter the ISBN number”
End If

So in this way we get the book detail from ISBN using WorldCat.org provider.

Thanks & Best Regards,
Rajat Jaiswal

Book detail by ISBN number using ASP.NET

Dear Friends,
I am explaining basic steps by which you can get book detail from ISBN using ASP.NET

I am using 3 providers which have this database catalog and provide such facility.
So below is the list
1)    isbndb.com
2)    worldcat.org
3)    Google book API
So let us start with ISBNDB.com first. So to use this service you have to create first access key.


We can get access key by registration at ISBNDB.com and it is free.
Now when you have access key then you can play with the URL which is responsible for providing the book detail response as shown below http://isbndb.com/api/books.xml?access_key=xyz&index1=ISBN&value=012343

The response of the above URL is XML.
To achieve this I did have created a constant for above URL as shown below

Private Const ISBNAPIURL As String =”http://isbndb.com/api/books.xml?access_key=”

Now on asp.net web page I have used a textbox for ISBN number and a button for search

So on click of button search event we did following code

If Me.txtISBN.Text <> String.Empty Then
Dim requestURL As String
Step1: created  request url at run time to fetch ISBN number
requestURL = ISBNAPIURL + Common.GetISBNConfig().ToString() + “&index1=isbn&value1=” + Me.txtISBN.Text.ToString()

‘step2: now as the return type is fixed XML format I have provided the response to XDocument
Dim xDoc As XDocument = XDocument.Load(requestURL)

‘Step 3:- On the avbove XDoc I have applied LINQ to XML and as we know the XML node will have following book elements so we have used it.

Dim resultSet = From book In xDoc.Descendants(“BookData”)
Select New BookDetail() With {.BookTitle = book.Element(“Title”).Value,
.BookAuthor = book.Element(“AuthorsText”).Value,
.BookPublisher = book.Element(“PublisherText”).Value}

Step4 : now we check whether the result set have something or not and  If we found  entry then we assign the output to project.

If resultSet Is Nothing = False AndAlso resultSet.Count() > 0 Then
Me.lblBookName.Text = resultSet.FirstOrDefault().BookTitle.ToString()
Me.lblAuthor.Text = resultSet.FirstOrDefault().BookAuthor.ToString()
Me.lblPublisher.Text = resultSet.FirstOrDefault().BookPublisher.ToString()
Else
Me.lblMessage.Text = “Sorry ISBN Number not found, Please try different number.”
End If
Else
Me.lblMessage.Text = “Please enter the ISBN number”
End If

In this way you can get book detail by ISBN using asp.net LINQ to XML feature.

In the next tutorial we  will use wordcat api to access book information using ASP.NET.

Thanks & Best Regards,

Rajat Jaiswal