This package is an API wrapper for data from https://data.gov.sg using JavaScript.
Install it via npm
or yarn
:
# npm install data-dot-gov --save-dev
#
# OR
#
# yarn add data-dot-gov
Only ES6 compliant Node versions (ie 6.* and above) are supported. Check your Node version with: node -v
In your main index.js
/server.js
file, import the package and set the consumer key. You can obtain
a consumer key by creating an account at https://developers.data.gov.sg.
After setting up, go to your APIs and create a new app. A Consumer Key should have been made available to you.
Use the following code to import the package and set the Consumer Key:
// include package
const dataDotGov = require('data-got-gov');
// ... other code ...
// set consumer key
dataDotGov.setConsumerKey('abcdefghijklmnopqrstuv');
// use it
dataDotGov.RealTime.Transport.getTaxiAvailability()
.then((response) => {
// handle success
})
.catch((err) => {
// handle error
});
All functions return a Q promise so you can use .then()
for success cases and .catch()
for errors.
✅ indicates it's ready. ❌ indicates it's not ready.
Source: https://developers.data.gov.sg/
Available at: dataDotGov.RealTime.Transport.getTaxiAvailability()
Not available yet.
Not available yet.
Not available yet.
Not available yet.
Not available yet.
Not available yet.
Not available yet.
Not available yet.
Not available yet.
Not available yet.
Not available yet.
Not available yet.
Source: https://data.gov.sg/developer
Available at: dataDotGov.DataStore.getPackageInfo(:package_name)
:package_name
- name of package according to package on https://data.gpv.sg.
Available at: dataDotGov.DataStore.getResourceInfo(:resource_id)
:resource_id
- UUID of resource from .getPackageInfo()
.
Available at: dataDotGov.DataStore.query(:resource_id, :query)
:resource_id
- UUID of CKAN API resource, note that this is not the same as the :resource_id
from resource_metadata
.
:query
- additional search parameters for querying the resource identified by :resource_id
.
Add on to this if you've created a function endpoint for this!
Fork this project and clone it locally.
Install dependencies with:
# npm install
#
# OR
#
# yarn install
See the above section in Usage on obtaining an API Consumer Key
Create an .env
file in the project root with the following content:
PORT=<port for hosting>
DATAGOVSG_CONSUMER_KEY=<consumer key from above>
The ./index.js
file contains the main file which is included upon require('data-dot-gov')
.
The ./lib
folder contains the code in a single-layer organisation manner. Files within ./lib
should be named in lowercase according to the variables they expose.
Tests are stored in ./test
and are run using the Mocha runner. Test coverage is
provided by Istanbul and is made available in ./coverage
.
To run the tests, use npm test
.
To run the tests with watching, use npm run test-watch
Run the development server using npm run dev
and you should be able to access the coverage
reports at http://localhost:PORT where PORT
is a defined key in your ./.env
file.