Getting Started: Holdings lookup – direct REST api access
In this example I will take you through how to usefully directly access the Holdings Lookup service from within a web page. The api reference for the service can be found here.
To use the api you will need to obtain an API Key. The API Key identifies your usage of the Talis Platform and helps us keep count of how popular the services are. You get your API Key by joining the TDN (which is free), and clicking on the "api keys" tab in your account view. Use the "request new api key" button to create new key that can be used immediately.
So that you can ‘see’ what the service can deliver, enter the following URL in to your favourite browser’s address prompt (replacing {key} with your API Key):
http://api.talis.com/1/bib/holdings?api_key={KEY}&output=xml&isbn=074758110XIt should result in a display something like this:
Useful, but not very elegant. So let’s utilise the xsl transform capability of the API to provide html output more suitable for end user consumption.
Step one create a simple xslt script to transform the raw XML into a html page:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" />
<xsl:template match="Holdings">
<html>
<head>
<title>
<xsl:text>Holding libraries for ISBN: </xsl:text>
<xsl:value-of select="./holding[1]/@isbn"/>
</title>
</head>
<body>
<p style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size:15px">
<xsl:text>Holding libraries for ISBN: </xsl:text>
<xsl:value-of select="./holding[1]/@isbn"/>
</p>
<table border="0" cellpadding="0" cellspacing="0" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 11px;" >
<tbody>
<tr>
<th>Library</th>
<th>Code</th>
</tr>
<xsl:apply-templates select="holding"/>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="holding">
<tr>
<td>
<xsl:value-of select="./@name"/>
</td>
<td>
<xsl:value-of select="./@identity"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Save this file on to a web server and then pass its address as the xsl argument to the api call thus:
http://api.talis.com/1/bib/holdings?api_key={KEY}&output=xml&isbn=074758110X&content_type=text/html&xsl=http://research.talis.com/2006/api_examples/HoldingsExample.xslTo be even more useful the api call could be used as the src argument for an iframe element embedded in another web page like this:
A final enhancement would be to utilise the Bibliographic Deep Linking API to turn the Library names into links which take the user directly to the relevant screen within the search interface for a particular library collection.
The source for this enhanced xslt script:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8" />
<xsl:template match="Holdings">
<html>
<head>
<title>
<xsl:text>Holding libraries for ISBN: </xsl:text>
<xsl:value-of select="./holding[1]/@isbn"/>
</title>
<script type="text/javascript"><![CDATA[
function
doWin(s){
win = window.open(s,'_linkWindow','width=800,height=600,toolbar,scrollbars,location');
win.focus();
}
]]></script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 11px;" >
<tbody>
<xsl:apply-templates select="holding"/>
</tbody>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="holding">
<tr>
<td>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:text>javascript:doWin('</xsl:text>
<xsl:text>http://api.talis.com/1/node/items/</xsl:text>
<xsl:value-of select="./@identity"/>
<xsl:text>/bib?api_key=1234&isbn=</xsl:text>
<xsl:value-of select="./@isbn"/>
<xsl:text>');</xsl:text>
</xsl:attribute>
<xsl:value-of select="./@name"/>
</xsl:element>
</td>
<td>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Note the JavaScript function doWin() used to open a separate browser window to display the deep link. For more information on the Bibliographic Deep Linking api check out the reference page and the simple user guide article.



.
Sorry not here.