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 🙏

© 2024 – Pkg Stats / Ryan Hefner

hongkong-trams

v1.0.1

Published

Node module to get info for Hong Kong Tramways, including fares, schedules and realtime next tram info.

Downloads

17

Readme

Hong Kong Tramways Unofficial API

What is this for?

Trams are a special and historic means of transport in Hong Kong. They are cheap, fun and generally reliable. However there isn"t an easy way to access information about them until recently. Hong Kong Tramways have made public next tram, schedule and fare information available online. This is an easy module to get the data so you can automate things.

For example, you could have a display at home with real-time next tram info.

Install

npm install --save hongkong-trams

Usage

When creating the instance, you can pass some options, for now, only the language code is supported, possible values are "en" English, "tc" Traditional Chinese or "sc" Simplified Chinese.

var HongKongTrams = require("hongkong-trams");

var trams = HongKongTrams();

trams.getNextTramETA("92W").then(function(eta){
    console.log(eta);
});

By default a new random useragent string is generated when the object is created. If you want to override this, please pass your useragent string into the options, for example:

var trams = HongKongTrams({userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'});

Supported Methods

Example data

All methods return JSON, please see the examples linked above for more info on how to call each method. Here is an example of what get

[ { "arrive_in_minute": "9",
    "arrive_in_second": "509",
    "is_arrived": false,
    "stop_code": "92W",
    "seq": "1",
    "tram_id": "60",
    "dest_stop_code": "KTT",
    "tram_dest_tc": "堅尼地城總站",
    "tram_dest_en": "Kennedy Town Terminus",
    "is_last_tram": false,
    "eta": "Jun 23 2016 10:21AM" },
  { "arrive_in_minute": "13",
    "arrive_in_second": "758",
    "is_arrived": false,
    "stop_code": "92W",
    "seq": "2",
    "tram_id": "168",
    "dest_stop_code": "KTT",
    "tram_dest_tc": "堅尼地城總站",
    "tram_dest_en": "Kennedy Town Terminus",
    "is_last_tram": false,
    "eta": "Jun 23 2016 10:25AM" },
  { "arrive_in_minute": "16",
    "arrive_in_second": "907",
    "is_arrived": false,
    "stop_code": "92W",
    "seq": "3",
    "tram_id": "92",
    "dest_stop_code": "KTT",
    "tram_dest_tc": "堅尼地城總站",
    "tram_dest_en": "Kennedy Town Terminus",
    "is_last_tram": false,
    "eta": "Jun 23 2016 10:28AM" } ]

Other Handy Modules

Contributing

Feel free to submit any pull requests or add functionality, I"m usually pretty responsive.

If you like the module, please consider donating some bitcoin or litecoin.

Bitcoin

LNzdZksXcCF6qXbuiQpHPQ7LUeHuWa8dDW

LiteCoin

LNzdZksXcCF6qXbuiQpHPQ7LUeHuWa8dDW