An unofficial C# Portable Class Library for Singapore's National Environment Agency API. Compatible with .NET 4.5, Silverlight 5, Windows 8, Windows Phone 8.1, and Windows Phone Silverlight 8 (and up - Universal Windows Apps should work too.)
Currently supports retrieving the PSI Update and PM2.5 Update datasets.
NuGet: Install-Package SGEnviro
-
Update NEA API URL.
- The old one will be deprecated on 26 August 2016.
If you haven't already, grab an API key from the NEA site.
Initialize the API by:
using SGEnviro;
...
var api = new SGEnviroApi("YOUR API KEY HERE");
// Check further examples below.
...
// At the top,
using SGEnviro.Forecasts;
...
// Then, after initializing the API object:
PsiUpdate result = await api.GetPsiUpdateAsync();
...
The results are broken down per region, and presented with more human-friendly names (compared to those given in the API):
// At the top,
using SGEnviro.Forecasts;
...
// Then, after initializing the API object:
Pm25Update result = await api.GetPm25UpdateAsync();
...
Just as with 3-hour PSI, results are broken down per region (minus "National", which isn't provided for PM2.5).
Microsoft.Bcl (1.1.10)
Microsoft.Bcl.Async (1.0.168)
Microsoft.Bcl.Build (1.0.21)
Microsoft.Net.Http (2.2.29)
Tests are written using the Visual Studio Unit Testing Framework. To run them, a valid API key must be added to the App.config
file in the SGEnviroTest
folder.