fpti

Standardized API for public transportation client libraries.

Usage no npm install needed!

<script type="module">
  import fpti from 'https://cdn.skypack.dev/fpti';
</script>

README

fpti-js

FPTI-JS (Friendly Public Transport Interface) describes a standardized API for public transportation client libraries in JavaScript. See the spec and the list of JS modules.

Proposal, work in progress!

npm version license chat on gitter

API

The purpose of this specification is to outline a standardized API for the most common features of public transportation libraries, such as Journey planning, Departures/Arrivals or Station search. While most libraries certainly don't cover all of the following features, the basic principle for modules complying to fpti-js is that if a certain feature is available, it must be provided with the API described below. Some modules may also include additional functionalities that are not covered within this specification, as long as they don't use the reserved fpti-js method names.

Furthermore, even for additional features that are not covered within the following spec, fpti-js modules return data in the Friendly Public Transport Format v1.x.x wherever possible and use validate-fptf and fpti-tests in their tests.

Method overview

All methods expose an object method.features which contains all supported options and simple descriptions of those options as keys and values, respectively. See the method specifications for examples.

Method Feature description Returns
stations.all([opt]) / stops.all([opt]) / regions.all([opt]) All stations/stops/regions of the network. Readablestation / stop / region
stations.search(query, [opt]) / stops.search(query, [opt]) / regions.search(query, [opt]) Search stations/stops/regions by query. Promise[station] / [stop] / [region]
stations.nearby(location, [opt]) / stops.nearby(location, [opt]) / regions.nearby(location, [opt]) Search stations/stops/regions by location. Promise[station] / [stop] / [region]
journeys(origin, destination, [opt]) Journeys between stations (or optionally other locations) Promise[journey]
stopovers(station, [opt]) Departures and arrivals at a given station (or optionally other location) Promise[stopover]

Contributing

We are looking forward to discuss & extend this format further! If you have a question or want to propose changes, visit the issues page. Keep our contributing guidelines in mind. Note that, by participating in this project, you commit to the code of conduct.