npm i mtr-kit
// Or
yarn add mtr-kit
// Or
pnpm i mtr-kit
API client for Official Real-time MTR train information
import { rtApi } from "mtr-kit" // API Client
import { stopScheduleApi, LineCode } from "mtr-kit" // use the schedule API directly
const schedule = await stopScheduleApi.get({ line: LineCode.TML, stop: StopCode.TMU })
console.log(schedule)
/*
Output:
{
status: 1,
message: 'successful',
sys_time: '2023-07-13 11:10:07',
curr_time: '2023-07-13 11:09:58',
data: {
'TML-TUM': {
curr_time: '2023-07-13 11:09:58',
sys_time: '2023-07-13 11:10:07',
DOWN: [Array]
}
},
isdelay: 'N'
}
*/
API client for MTR routes, fares and barrier-fee facilities
import { openDataApi } from "mtr-kit" // API Client
import { fareApi, LineCode } from "mtr-kit" // use the fare API directly
const mtrFares = await fareApi.listMtrFares()
console.log(mtrFares)
/*
Output:
[
{
SRC_STATION_NAME: 'Central',
SRC_STATION_ID: 1,
DEST_STATION_NAME: 'Central',
DEST_STATION_ID: 1,
OCT_ADT_FARE: 0,
OCT_STD_FARE: 0,
OCT_JOYYOU_SIXTY_FARE: 0,
SINGLE_ADT_FARE: 0,
OCT_CON_CHILD_FARE: 0,
OCT_CON_ELDERLY_FARE: 0,
OCT_CON_PWD_FARE: 0,
SINGLE_CON_CHILD_FARE: 0,
SINGLE_CON_ELDERLY_FARE: 0
},
...more
]
*/
const airportExpressFares = await fareApi.listAirportExpressFares()
/*
Output:
[
{
ST_FROM: 'HongKong',
ST_FROM_ID: 44,
ST_TO: 'Airport',
ST_TO_ID: 47,
OCT_ADT_FARE: 110,
OCT_CHD_FARE: 55,
SINGLE_ADT_FARE: 115,
SINGLE_CHD_FARE: 57.5
},
...more
]
*/
Line code according to the Real-time MTR train information
import { LineCode } from "mtr-kit"
Line basic information
type Line = {
line: LineCode
nameEn: string
nameZh: string
color: string
stops: {
stop: StopCode
up: LineStopDirection
down: LineStopDirection
}[]
}
import { lines } from "mtr-kit" // Line[]
import { lineMap } from "mtr-kit" // { [key in LineCode]: Line }
// Import line specifically
import { TML } from "mtr-kit" // Line
Stop code according to the Real-time MTR train information
import { StopCode } from "mtr-kit"
Stop basic information
type Stop = {
stop: StopCode
nameEn: string
nameZh: string
color: string
textColor: string
}
import { stops } from "mtr-kit" // Stop[]
import { stopMap } from "mtr-kit" // { [key in StopCode]: Stop }
// Import stop specifically
import { TUM } from "mtr-kit" // Stop
pnpm i
pnpm run test
pnpm run build
This repo uses Release Please to release.
- Merge
develop
intomain
- A GH Action will run(triggered automatically) and a Release PR will be created.
- Merge the release PR
- Wait for the second GH Action to run(triggered automatically)
- Create merge back PR(from
main
back todevelop
) - You're done!