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.

This entry was posted in Uncategorized. Bookmark the permalink.

11 Responses to Datasets – Places.sg

  1. Metabaron says:

    Is it me or it’s impossible to search places around your current location?

  2. Feroz says:

    Can i search by a product instead of place ?

  3. Santanu says:

    if i want to filter the result according to category for nearby then what will be the the url for that:
    http://api.projectnimbus.org/placesodataservice.svc/Places?keyword=Food and Beverages&latitude=1.324&longitude=103.82&distance=2000

  4. Feroz says:

    Hi
    I am trying to access this data service and i have a valid key. When i access, i get the following error
    401-Unauthorized: Access is denied due to invalid credentials”.

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