Gathering detailed insights and metrics for hk-bus-eta-skpracta
Gathering detailed insights and metrics for hk-bus-eta-skpracta
Query the ETA (Estimated Time of Arrival) of HK Bus
npm install hk-bus-eta-skpracta
Typescript
Module System
70.1
Supply Chain
98.5
Quality
74.9
Maintenance
100
Vulnerability
80.2
License
TypeScript (99.31%)
JavaScript (0.69%)
Total Downloads
891
Last Day
2
Last Week
16
Last Month
87
Last Year
591
66 Commits
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
3.2.3
Package Id
hk-bus-eta-skpracta@3.2.3
Unpacked Size
122.96 kB
Size
31.12 kB
File Count
77
Publised On
25 Dec 2023
Cumulative downloads
Total Downloads
Last day
-66.7%
2
Compared to previous day
Last week
-11.1%
16
Compared to previous week
Last month
93.3%
87
Compared to previous month
Last year
97%
591
Compared to previous year
1
6
Bus ETAs in Hong Kong is now available as open data in Hong Kong, while there is no format normalization across different transport provider. This package is a js package (typescript supported) for querying normalized public traffic ETA (Estimated Time of Arrival) in Hong Kong. The ETA data structure is based on hkbus/hk-bus-crawling and a well-established open-source project is known as hkbus.app.
A Python version package is available here and the source code is available here.
Live demo is available here.
npm install hk-bus-eta
or
yarn add hk-bus-eta
Crawling traffic database:
1import { fetchEtaObj } from "hk-bus-eta"; 2import type { BusDb } from "hk-bus-eta"; 3 4fetchEtaDb().then((db: BusDb) => { 5 console.log(db) 6})
Crawling ETA
1import { fetchEtas } from "hk-bus-eta"; 2import tyep { Eta } from "hk-bus-eta"; 3 4// busDb is the BusDb object fetched by fetchEtaObj 5 6fetchEtas({ 7 ...busDb.routeList["1+1+CHUK YUEN ESTATE+STAR FERRY"], 8 seq: 0, 9 language: "en", 10}).then(etas => { 11 console.log(etas) 12})
The data structure of EtaDb is as follows:
1{ 2 holidays: string[]; 3 routeList: { 4 [routeId: string]: { 5 route: string, 6 co: Company[], 7 orig: { 8 en: string, 9 zh: string 10 }, 11 dest: { 12 en: string, 13 zh: string 14 }, 15 fares: string[] | null, 16 faresHoliday: string[] | null, 17 freq: { 18 [type: string]: { 19 [startTime: string]: [string, string] | null 20 } 21 } | null, 22 jt: string | null, 23 seq: number, 24 serviceType: string, 25 stops: { 26 [company: string]: string[] 27 }, 28 bound: { 29 [company: string]: "O" | "I" | "OI" | "IO" 30 }, 31 gtfsId: string, 32 nlbId: string 33 } 34 } 35 stopList: { 36 [stopId: string]: { 37 location: { 38 lat: number, 39 lng: number, 40 }, 41 name: { 42 en: string, 43 zh: string 44 } 45 } 46 } 47 stopMap: { 48 [stopId: string]: Array<{ 49 [company: string]: string 50 }> 51 } 52}
The data structure of Eta is as follows:
1{ 2 eta: string, 3 remark: { 4 zh: string, 5 en: string 6 }, 7 co: string 8}
Project owner chunlaw is the initiator of the whole project. Everyone is welcome to contribute.
Modified by skpracta to include https://hkbus-data.skpracta.info as a data source and intended for use by https://hkbus.skpracta.info as a fork of HKBUS.
GPL-3.0 license
No vulnerabilities found.
No security vulnerabilities found.