npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sgdata-sdk

v0.1.1

Published

Modern TypeScript SDK for Singapore Government Open Data APIs

Readme

SGData SDK

Modern TypeScript SDK for Singapore Government Open Data APIs. Access real-time transport, weather, and environmental data with full type safety.

🇸🇬 Replaces the abandoned 8-year-old data-dot-gov package with a modern, TypeScript-first approach.

Features

TypeScript-first - Full type definitions and IntelliSense support
Zero dependencies - Lightweight and secure
Modern APIs - Works with current data.gov.sg endpoints (2025)
No API key required - Singapore's open data is truly open
Well documented - JSDoc comments and examples

Installation

npm install sgdata-sdk

Quick Start

import { SGDataClient } from 'sgdata-sdk';

const client = new SGDataClient();

// Get real-time carpark availability
const carparks = await client.getCarparkAvailability();
console.log(carparks.items[0].carpark_data);

// Get 2-hour weather forecast
const weather = await client.getWeatherForecast2H();
console.log(weather.items[0].forecasts);

// Get air quality (PSI)
const psi = await client.getPSI();
console.log(psi.items[0].readings.psi_twenty_four_hourly);

Using with API Key (Optional)

For higher rate limits, sign up at data.gov.sg to get an API key:

import { SGDataClient } from 'sgdata-sdk';

// With API key for higher rate limits
const client = new SGDataClient({ 
  apiKey: 'your-api-key-here' 
});

// Without API key (default rate limits apply)
const client = new SGDataClient();

Rate Limits:

  • Without API key: Standard rate limits apply
  • With API key: 60 requests per minute per endpoint

To get an API key:

  1. Go to https://data.gov.sg
  2. Click "Sign up" in the top right
  3. Follow the registration process
  4. Your API key will be available in your account dashboard

API Reference

Transport

getCarparkAvailability()

Get real-time carpark availability across Singapore. Updated every minute.

const data = await client.getCarparkAvailability();
// Returns: { items: [{ timestamp, carpark_data: [...] }] }

Weather Forecasts

getWeatherForecast2H()

Get 2-hour weather forecast. Updated every 30 minutes.

const forecast = await client.getWeatherForecast2H();
// Returns: { area_metadata, items: [{ forecasts: [...] }] }

getWeatherForecast24H()

Get 24-hour weather forecast. Updated multiple times daily.

const forecast = await client.getWeatherForecast24H();

getWeatherForecast4D()

Get 4-day weather forecast. Updated twice daily.

const forecast = await client.getWeatherForecast4D();

Environment

getPSI()

Get current PSI (Pollutant Standards Index) readings. Updated every 15 minutes.

const psi = await client.getPSI();
// Returns air quality readings for all regions

getTemperature()

Get real-time air temperature across Singapore. Updated every 5 minutes.

const temp = await client.getTemperature();

getRainfall()

Get rainfall readings across Singapore. Updated every 5 minutes.

const rainfall = await client.getRainfall();

getHumidity()

Get relative humidity readings. Updated every minute.

const humidity = await client.getHumidity();

getUVIndex()

Get UV index readings. Updated hourly between 7AM and 7PM.

const uv = await client.getUVIndex();

Example Use Cases

Find Available Parking Near You

const carparks = await client.getCarparkAvailability();
const availableNow = carparks.items[0].carpark_data
  .filter(cp => parseInt(cp.lots_available) > 10)
  .slice(0, 5);
console.log('Carparks with 10+ spots:', availableNow);

Check if You Need an Umbrella

const weather = await client.getWeatherForecast2H();
const forecasts = weather.items[0].forecasts;
const rainy = forecasts.some(f => 
  f.forecast.toLowerCase().includes('rain')
);
console.log(rainy ? '🌧️ Bring umbrella!' : '☀️ No rain expected');

Air Quality Alert

const psi = await client.getPSI();
const national = psi.items[0].readings.psi_twenty_four_hourly.national;

if (national > 100) {
  console.log('⚠️ Unhealthy air quality');
} else {
  console.log('✅ Air quality is good');
}

TypeScript Support

This SDK is written in TypeScript and includes full type definitions. You get autocomplete and type checking out of the box:

import { SGDataClient, CarparkInfo, PSIReading } from 'sgdata-sdk';

const client = new SGDataClient();

// TypeScript knows the exact structure!
const carparks = await client.getCarparkAvailability();
const firstCarpark: CarparkInfo = carparks.items[0].carpark_data[0];

Error Handling

try {
  const data = await client.getCarparkAvailability();
  console.log(data);
} catch (error) {
  console.error('Failed to fetch data:', error);
}

Data Sources

All data is sourced from Singapore's official data.gov.sg platform.

  • Carpark Availability: HDB, LTA, URA carparks
  • Weather: National Environment Agency (NEA)
  • PSI: National Environment Agency (NEA)

Contributing

Issues and pull requests are welcome on GitHub.

License

MIT

Author

Ong Kong Tat - GitHub


Built for Singapore's developer community