GithubHelp home page GithubHelp logo

nea_api's Introduction

NEA API Wrapper

Wrapper for the National Environment Agency of Singapore's Data API.

Disclaimer: This wrapper is NOT an official wrapper and do not attempt to represent NEA in anyway.

About

This wrapper has the following functions:

  • get_pm25()
  • get_2hr_nowcast()
  • get_24hrs_forecast()
  • get_4days_outlook()
  • get_heavy_rain_warning()
  • get_uvi()
  • get_earthquake()
  • get_psi_update()

All functions return an OrderedDict object which you can manipulate. The structure of the OrderedDict is the same as the original XML output.

Register for an API Key

To get an API key, you'll have to register at NEA's dataset API page

Installation

$ pip install nea_api

Usage

from nea_api import NEA

nea = NEA(api_key="<api key>")
results = nea.get_pm25()

# ipdb> results
OrderedDict([('channel', OrderedDict([('title', 'PM2.5 Update'), ('source', 'Airviro'), ('item', OrderedDict([('region', [OrderedDict([('id', 'rNO'), ('latitude', '1.41803'), ('longitude', '103.82000'), ('record', OrderedDict([('@timestamp', '20160406140000'), ('reading', OrderedDict([('@type', 'PM25_RGN_1HR'), ('@value', '17')]))]))]), OrderedDict([('id', 'rCE'), ('latitude', '1.35735'), ('longitude', '103.82000'), ('record', OrderedDict([('@timestamp', '20160406140000'), ('reading', OrderedDict([('@type', 'PM25_RGN_1HR'), ('@value', '27')]))]))]), OrderedDict([('id', 'rEA'), ('latitude', '1.35735'), ('longitude', '103.94000'), ('record', OrderedDict([('@timestamp', '20160406140000'), ('reading', OrderedDict([('@type', 'PM25_RGN_1HR'), ('@value', '19')]))]))]), OrderedDict([('id', 'rWE'), ('latitude', '1.35735'), ('longitude', '103.70000'), ('record', OrderedDict([('@timestamp', '20160406140000'), ('reading', OrderedDict([('@type', 'PM25_RGN_1HR'), ('@value', '26')]))]))]), OrderedDict([('id', 'rSO'), ('latitude', '1.29587'), ('longitude', '103.82000'), ('record', OrderedDict([('@timestamp', '20160406140000'), ('reading', OrderedDict([('@type', 'PM25_RGN_1HR'), ('@value', '30')]))]))])])]))]))])

Todo

  • Tests!

Reference

nea_api's People

Contributors

davidchua avatar

Watchers

 avatar  avatar

Forkers

codelah lyeght

nea_api's Issues

How to get api key

the url in the readme doesnt work :( how doi get an api key to get it to work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.