Datasets – National Library Board (NLB)

National Library Board Singapore (NLB)
NLB oversees both the National Library as well as the Public Libraries. By international convention, the functions of these two kinds of libraries are distinct and well-differentiated. The NLB’s mission is to provide a trusted, accessible and globally-connected library and information service through the National Library and a comprehensive network of Public Libraries. Also under its management are 1 community children’s library, and 17 libraries belonging to government agencies, schools and institutions. Through its innovative use of technology and collaboration with strategic partners, NLB ensures that library users have access to a rich array of information services and resources that are convenient, accessible and relevant.

Datasets Available

Dataset Description URL Metadata
Catalogue Information of articles and media materials within the NLB collection https://
api.projectnimbus.org/
nlbodataservice.svc/
CatalogSet
Click Here
Lastest Infopedia Article Lastest collection of Infopedia article by NLB https://
api.projectnimbus.org/
nlbodataservice.svc
/LatestArticleSet
Click Here
Libraries List and location of  Public Libraries in Singapore https://
api.projectnimbus.org/
nlbodataservice.svc/
LibrarySet
Click Here
Events Upcoming events happening at the libraries https://
api.projectnimbus.org/
nlbodataservice.svc/
EventSet
Click Here

Code Snippet

.NET (optimised for .NET 3.5/Above) – How do I access a complete list of Libraries(Updated 01 Nov 2010)

class Library
    {
            public string LibraryID { get; set; }
            public string Name { get; set; }
            public string Address { get; set; }
    }

public List GetLibraryFromNimbusNLB(string AccountKey, string UniqueUserID)
    {
        System.Net.WebRequest wr=
          HttpWebRequest.Create(
            "http://api.projectnimbus.org/nlbodataservice.svc/LibrarySet");
        wr.Headers.Add("AccountKey",AccountKey);
        wr.Headers.Add("UniqueUserID",UniqueUserID);
        wr.Method = "GET";
        WebResponse res = wr.GetResponse();
        string resStr
         = new System.IO.StreamReader(res.GetResponseStream()).ReadToEnd();

        XNamespace atomNS
          = "http://www.w3.org/2005/Atom";
        XNamespace dNS
          = "http://schemas.microsoft.com/ado/2007/08/dataservices";
        XNamespace mNS
          = "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata";

        List results
          = (from item in XElement.Parse(strResponse).Descendants(atomNS + "entry")
            let place = item.Element(atomNS + "content").Element(mNS + "properties")
                select new Library() {
                LibraryID = place.Element(dNS + "LibraryID").Value,
                Name = place.Element(dNS + "Name").Value,
                Address = place.Element(dNS + "Address").Value
            }).ToList();

        return results;
    }

Java – How do I access a complete list of Libraries (Updated 01 Nov 2010)

class Library {
    private String libraryID;
    private String name;
    private String address;
    public String getLibraryID() {
        return libraryID;
    }
    public void setLibraryID(String libraryID) {
        this.libraryID= libraryID;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
}

public ArrayList getLibraries(String AccountKey, String UniqueUserId) {
   // Declare an ArrayList for storing the data to be retrieved from Nimbus
   ArrayList libraryList = new ArrayList();
   try {
       // Declare a URL object with the url of the Nimbus Dataset
       URL _url = new URL("http://api.projectnimbus.org/nlbodataservice.svc/LibrarySet");

       // Declare a URLConnection object and open a connection using the URL object declared previously
       URLConnection _urlConn = _url.openConnection();

       // Append the necessary Nimbus authentication info (AcountKey, UniqueUserId) to the URLConnection object
       _urlConn.setRequestProperty("accept", "*/*");
       _urlConn.addRequestProperty("AccountKey",
            AccountKey);
       _urlConn.addRequestProperty("UniqueUserID",
            UniqueUserId);

       // BufferedReader object stores the response (InputStream) of the URLConnection object
       BufferedReader br = new BufferedReader(new InputStreamReader(_urlConn.getInputStream()));

       String line = null;
       StringBuilder strBuilder = new StringBuilder();
       while ((line = br.readLine()) != null) {
           strBuilder.append(line);
       }

       // An array of String is used to store the data retrieved from Nimbus and extracted later
       String[] IProperties = strBuilder.toString().split("<m:properties>");
       for (int i = 1; i < IProperties.length; i++) {
           Library lib = new Library();
           // For each line of data, the function Utils.getStringBetween extracts the content between the opening and closing xml tags
           lib.setLibraryID(Utils.getStringBetween(
                IProperties[i], "<d:LibraryID m:type=\"Edm.Int32\">", "</d:LibraryID>"));
           lib.setName(Utils.getStringBetween(
                IProperties[i], "<d:Name>", "</d:Name>"));
           lib.setAddress(Utils.getStringBetween(
                IProperties[i], "<d:Address>", "</d:Address>"));
           libraryList.add(lib);
       }
   } catch (MalformedURLException ex) {
       ex.printStackTrace();
   } catch (IOException ex) {
       ex.printStackTrace();
   } catch (Exception ex) {
       ex.printStackTrace();
   }
   return libraryList ;
}

Helpers Available

.NET – C# Proxy Classes: Coming soon | Read this blog post for more information to use these proxy classes.

JAVA – Read this blog post for more information to use JAVA to connect to the data service.

PHP & AJAX – Read this blog post for more information to use PHP/AJAX to connect to the data service.

obj C / xcode – coming soon

Terms of Use

The datasets:

  • Are here as a community technology preview for a period of time (TBD).
  • Cannot be used in any public offering.
  • Are offered as-is with no official support.

Support

None at this time.

This entry was posted in Uncategorized. Bookmark the permalink.

2 Responses to Datasets – National Library Board (NLB)

  1. Pingback: What is Project Nimbus? How do I get started? « Project Nimbus

  2. Lim Han says:

    Does anyone have trouble accessing the CatalogSet with the extension “?keyword=”

    I’m not able to retrieve any data with any keyword parameters.

    Best regards,
    Han

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s