Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
/ metro-info Public archive

🚌 Simplified interaction with Christchurch's Metro Info bus service

License

Notifications You must be signed in to change notification settings

Codex-/metro-info

Repository files navigation

metro-info

build codecov npm

🚌 Simplified interaction with Christchurch's Metro Info bus service

Install

npm install metro-info

Usage

Getting times for a specific Platform can be achieved as per the example below.

import { getPlatformTimes, PlatformTimes } from "metro-info";

async function getTimes(): void {
  const platformTimes: PlatformTimes = await getPlatformTimes(1205);
}

If you're unsure of a Platform number, they can be found on the physical stops themselves or alternatively a complete collection of all Platforms with their locations, tags, and various other information can be obtained as per the example below.

import { getPlatformLocations, PlatformLocations } from "metro-info";

async function getLocations(): void {
  const platformLocations: PlatformLocations = await getPlatformLocations();
}

Compatibility

metro-info will opt to use a globally provided fetch method if one exists, before falling back to using node-fetch. This allows compatibility with with any frameworks that implement fetch, such as: NativeScript, React Native, and most browsers.

Models

The models closely resemble those as exposed by the Connexionz API. The schema documentation was incredibly verbose, I have omitted commenting many items as a lot of the schema documentation simply reiterated the property name.

Issues

If you encounter a case where an exception is thrown while parsing the XML response, please raise an issue including the XML that caused the failure and I will investigate the cause.