Code::Xtreme::Apps 2011 Project Nimbus Training

It was a fabulous Saturday morning, while many folks will be sleeping in, a good 100+ developers showed up at the Microsoft office @ One Marina Boulevard. Looking forward to the upcoming code::xtreme::apps competition happening in July’11. Thank you for being such enthusiastic participants and the Project Nimbus team are especially appreciative of your time and interest.

Just a recap we have presented and demonstrated on how you can access and use data from Project Nimbus, especially those datasets made available by LTA.
The below are the various slides and code used by the presenters.

Shank – Windows Phone 7
http://projectnimbus.blob.core.windows.net/share/CodeXtremeX%20Bryan%20Lim.zip
Bryan Lim – Android
http://projectnimbus.blob.core.windows.net/share/WP7%20Accessing%20Nimbus%20LTA%20datasets.zip
Sebastian Ng – iPhone (check out http://www.jollideal.com to see his start-up)
Code snippets to pull data
Header file: https://s3-ap-southeast-1.amazonaws.com/sebng/nimbus/NimbusDemo_lta_iphoneViewController.hImplementation file: https://s3-ap-southeast-1.amazonaws.com/sebng/nimbus/NimbusDemo_lta_iphoneViewController.m
As mentioned, look out for the instructions coming from the organizers as to how you can get access to the full collection of the LTA datasets soon.

We look forward to see you at the competition day and await you to ‘wow’ us with your works!

Cheers!

Posted in Uncategorized | Leave a comment

Notice: LTA Datasets will be down for maintenance

Dear Innovators,
Project Nimbus and LTA will be reviewing some terms of usage.

This is to inform you that the LTA Data service will be under maintenance in the meanwhile.

We apologise for the inconvenience caused and will further update you when the service is back online.

Thank you.

Warmest Wishes,
Project Nimbus Team

Posted in Uncategorized | Leave a comment

Notice: LTA Datasets will down for maintenance from 1st Feb’11

Dear Innovator,

Wishing you a Happy Lunar New Year! All the best in this year of the Rabbit!

This is to inform you that the Project Nimbus team will be doing maintenance work for data services over this long weekend.
The datasets that will be affected primarily will be those from LTA, effectively from 1st Feb till the end of the month.

While we look forward to rollout the new features to you soon. We apologise for the inconvenience caused during this duration.

Thank you.

Warmest Wishes,
Project Nimbus Team

Posted in Uncategorized | 4 Comments

Notice: LTA Datasets will down for maintenance from 4th Nov – 11th Nov

Dear Developers,

We seek your understanding and patience while the Project Nimbus do some maintenance with the datasets from LTA.
The disruption will be in effect from 4th Nov – 11th Nov.

Sorry for the inconvenience caused.

Posted in Uncategorized | Leave a comment

New Content Available on Project Nimbus – Places.sg!

Places of Interests in Singapore

One of our Project Nimbus content providers have published a new dataset — Places.sg, featuring a unified database of the Places Of Interests [POIs], such as businesses and retail shops, in Singapore!

Innovators and developers will be able to pull these data, such as business listing infomation, promotions, food menu and events, and incorporate them into their applications. Places.sg is a collaborative effort with the Infocomm Development Authority (IDA) of Singapore under the Digital Concierge Programme and Microsoft Corporation.

Places.sg works by providing free and easy access to directory listings of POIs. These directory listing include information such as operating hours, geolocation (latitude and longitude) and others. Anybody can query for the information about a POI, or a list of POIs around a certain location.

Developers get to build cool and creative applications and websites on top of these data and can even monetize on these applications or websites that are built. Businesses get to increase their exposure to consumers by simply being in the directory listing. Businesses can even drive traffic to their shops by listing promotions and uploading photographs. Consumers will thus have a richer and easier access to information, promotions and events happening in Singapore.

You can visit the Azure Data Market for other available datasets as well.

Posted in Uncategorized | Leave a comment

Consuming Windows Azure Marketplace Data Market Datasets

Getting the Data Market Account Key

To access and consume any of the Data Market Datasets, you need to find your Account Key which will be used as a form of credentials.

  1. Go to http://datamarket.azure.com/account/info.
  2. Log in with your Windows Live ID and click on My Account.
  3. At the Account Details page, click on Account Keys.
  4. If you have not consumed datasets from Windows Azure Data Market before, your first account key will be found under the Default label as shown:

Subscribing to the a Dataset, eg Places.sg

Developers need to be subscribed to the dataset in order to use the data available. This example shows you how to subscribe to one of the datasets, Places.sg.

  1. Go to https://datamarket.azure.com/ and select Points of Interests.
  2. Select Places of Interests in Singapore.
  3. Click on Sign Up.
  4. Log into Windows Azure Marketplace Data Market using your Windows Live ID.
  5. Access the Places.sg API Terms of Use, check I have read and agree to the terms of use and Sign Up.
  6. Once you have successfully signed up, you will see the following Purchase Receipt.
  7. You have successfully subscribed to the Places.sg dataset and can access it from the My Data menu option.

Consuming the Places.sg Dataset

  1. Under the Places of Interests in Singapore dataset page you will find the Service Root URL to access the dataset from your application.
  2. Click on Explore this Dataset on the same page to test requests and see the content of the dataset.

Code Snippet — How do I access the Places.sg dataset

C#.NET

private List GetPlacesFromDataMarket(string UniqueUserId, string AccountKey)
{
    WebRequest request = HttpWebRequest.Create(
    "https://api.datamarket.azure.com/Data.ashx/PlacesSg/PlacesofInterestinSingapore/Places?$top =100");
    request.Credentials = new NetworkCredential(UniqueUserId, AccountKey);

    WebResponse response = request.GetResponse();
    string strResponse = new StreamReader(response.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 Places()
            {
                CompanyName = place.Element(dNS + "company_name").Value,
                CompanyType = place.Element(dNS + "company_type").Value,
                Category = place.Element(dNS + "category").Value
            }).ToList();

    return results;
}
class Places
{
    public string CompanyName { get; set; }
    public string CompanyType { get; set; }
    public string Category { get; set; }
}

Java

private static ArrayList
 getPlaces(String UniqueUserId, String AccountKey) {

    // Declare an ArrayList for storing the data to be retrieved from Data Market
    ArrayList placeList = new ArrayList();
try {

        // Declare a URL object with the url of the Data Market Dataset
        URL _url = new URL("https://api.datamarket.azure.com/Data.ashx/PlacesSg/PlacesofInterestinSingapore/Places?$top=100");

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

        // Encode credential to base64 for HTTP Basic Access Authentication used by Data Market
        BASE64Encoder encoder = new BASE64Encoder();
        String credential = UniqueUserId + ":" + AccountKey;
        String credentialBase64 = (encoder.encode(credential.getBytes())).replaceAll("\\s", "");

        // Append the necessary Data Market authentication infomation to the URLConnection object
        _urlConn.setRequestProperty("accept", "*/*");
        _urlConn.addRequestProperty("Authorization", "Basic " + credentialBase64);

        // 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 Data Market and extracted later
        String[] IProperties = strBuilder.toString().split("<m:properties>");
        for (int i = 1; i < IProperties.length; i++) {
            Place place = new Place();

            // For each line of data, the function GetStringBetween extracts the content between the opening and closing xml tags
            place.setCompanyName(GetStringBetween(
                    IProperties[i], "<d:company_name>", "</d:company_name>"));
            place.setCompanyType(GetStringBetween(
                    IProperties[i], "<d:company_type>", "</d:company_type>"));
            place.setCategory(GetStringBetween(
                    IProperties[i], "<d:category>", "</d:category>"));
            placeList.add(place);
        }
    } catch (MalformedURLException ex) {
        ex.printStackTrace();
    } catch (IOException ex) {
        ex.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    return placeList;
}
private static String GetStringBetween(String src, String start, String end) {
    StringBuilder sb = new StringBuilder();
    int startIdx = src.indexOf(start) + start.length();
    int endIdx = src.indexOf(end);
    while (startIdx < endIdx) {
        sb.append(String.valueOf(src.charAt(startIdx)));
        startIdx++;
    }
    return sb.toString();
}
static class Place {
    private String companyName;
    private String companyType;
    private String category;
    public String getCategory() {
        return category;
    }
    public void setCategory(String category) {
        this.category = category;
    }
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    public String getCompanyType() {
        return companyType;
    }
    public void setCompanyType(String companyType) {
        this.companyType = companyType;
}

php

<http>
<head>
<title>Get Places of Interests in Singapore</title>
</head>
<body>
<?php
    $UniqueUserId = '';
    $AccountKey = '';
    $url ='https://api.datamarket.azure.com/Data.ashx/PlacesSg/PlacesofInterestinSingapore/Places?$top=100';
    $params = array(
            'http' => array(
                'method' => 'GET',
                'header' => 'Authorization: Basic '.base64_encode($UniqueUserId.':'.$AccountKey)
            )
    );
    $context = stream_context_create($params);
    $page = file_get_contents($url, false, $context);
    $doc = new DOMDocument();
    $doc->loadXML($page);
?>
<table border="1">
<tr>
<th>Company Name</th>
<th>Company Type&</th>
<th>Category</th>
</tr>
<?php
    foreach ($doc->getElementsByTagName('properties') as $node) {
        echo '<tr>'."\n";
        echo '<td>'.$node->getElementsByTagName('company_name')->item(0)->nodeValue.'</td>'."\n";
        echo '<td>'.$node->getElementsByTagName('company_type')->item(0)->nodeValue.'</td>'."\n";
        echo '<td>'.$node->getElementsByTagName('category')->item(0)->nodeValue.'</td>'."\n";
        echo '</tr>'."\n";
    }
?>
</table>

Posted in Uncategorized | 2 Comments

Datasets – Places.sg

Places.sg
Places.sg aggregates the flow of your information to multiple web and mobile sites, so that when you upload your information and/or promotions in one place, it gets quickly syndicated to many digital properties.

Datasets Available

Dataset Description URL Metadata
Places Information of Places in Singapore http://
api.projectnimbus.org/
placesodataservice.svc/
Places
Click Here

Tips

Function Example Link Description
To search for a place via Place ID http://
api.projectnimbus.org/
placesodataservice.svc/
Detail?ID=1
To search for a particular place, send a request to the link with the ID query string appended to it
To search for a place via Keyword found in the name http://
api.projectnimbus.org/
placesodataservice.svc/
Search?Keyword=Restaurant
To search for a particular place, send a request to the link with the Keyword query string appended to it

Code Snippet

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

class Places
    {
            public string Id { get; set; }
            public string CompanyName { get; set; }
            public string Category { get; set; }
    }

public List GetPlacesFromNimbus(string AccountKey, string UniqueUserID)
    {
        System.Net.WebRequest wr=
          HttpWebRequest.Create(
            "http://api.projectnimbus.org/placesodataservice.svc/Places");
        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(resStr).Descendants(atomNS + "entry")
            let place = item.Element(atomNS + "content").Element(mNS + "properties")
                select new Places() {
                Id = place.Element(dNS + "id").Value,
                CompanyName = place.Element(dNS + "company_name").Value,
                Category = place.Element(dNS + "category").Value
            }).ToList();

        return results;
    }

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

class Place {
    private String id;
    private String companyName;
    private String category;
    public String getID() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    public String getCategory() {
        return category;
    }
    public void setCategory(String category) {
        this.category = category;
    }
}

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

       // 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++) {
           Place place = new Place();
           // For each line of data, the function Utils.getStringBetween extracts the content between the opening and closing xml tags
           place.setId(Utils.getStringBetween(
                IProperties[i], "<d:id m:type=\"Edm.Int32\">", "</d:id>"));
           place.setCompanyName(Utils.getStringBetween(
                IProperties[i], "<d:company_name>", "</d:company_name>"));
           place.setCategory(Utils.getStringBetween(
                IProperties[i], "<d:category>", "</d:category>"));
           placeList.add(place);
       }
   } catch (MalformedURLException ex) {
       ex.printStackTrace();
   } catch (IOException ex) {
       ex.printStackTrace();
   } catch (Exception ex) {
       ex.printStackTrace();
   }
   return placeList ;
}

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.

Posted in Uncategorized | 11 Comments