Skip to content

[FEATURE] Metrolinx API service module #219

Description

@BreakableHoodie

Summary

Build a centralised NestJS module for calling the Metrolinx Open Data API. This is a prerequisite for all real-time features: coach check-in (#67), schedule change detection (#163), and service alerts (#187).

Why a shared module

Without it, every contributor implementing a real-time feature has to independently handle:

  • API key injection from environment variables
  • Server-side response caching (required by Metrolinx ToS §6 — never call per-user-request)
  • HTTP client setup and error handling
  • Rate limit awareness

Requirements

  • API key — read from METROLINX_API_KEY env var; fail loudly on startup if missing when real-time features are enabled
  • Caching — all responses cached server-side with appropriate TTLs:
    • Fleet Consist: 1 service day (consists are stable within a day)
    • TripUpdates / Alerts: 30 seconds (feeds refresh on a fixed interval)
    • VehiclePosition: 15 seconds
  • Base URL — configurable via env (default: https://api.openmetrolinx.com/OpenDataAPI)
  • Format — JSON for structured endpoints, protobuf for GTFS-RT feeds (see [FEATURE] Metrolinx API service module #219 for protobuf setup)
  • Error handling — surface API errors clearly; do not silently swallow failures

API key registration

Registration is at https://api.openmetrolinx.com/OpenDataAPI/Help/Registration/en (free, takes up to 10 business days). A key has been requested — coordinate with project maintainers for access.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions