An open API service indexing awesome lists of open source software.

https://github.com/public-transport/fpti-js

Standardized API for public transportation client libraries in JavaScript.
https://github.com/public-transport/fpti-js

api-client fptf fpti fpti-js friendly-public-transport-format friendly-public-transport-interface public-transport public-transportation

Last synced: 6 months ago
JSON representation

Standardized API for public transportation client libraries in JavaScript.

Awesome Lists containing this project

README

          

# fpti-js

**FPTI-JS (_Friendly Public Transport Interface_)** describes a standardized API for public transportation client libraries in JavaScript. See **[the spec](#api)** and the [list of JS modules](modules.md).

**_Proposal, work in progress!_**

[![npm version](https://img.shields.io/npm/v/fpti.svg)](https://www.npmjs.com/package/fpti)
[![license](https://img.shields.io/github/license/public-transport/fpti-js.svg?style=flat)](license)
[![chat on gitter](https://badges.gitter.im/juliuste.svg)](https://gitter.im/juliuste)

## 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](https://github.com/public-transport/friendly-public-transport-format/) `v1.x.x` wherever possible** and **use [`validate-fptf`](https://github.com/public-transport/validate-fptf) and [`fpti-tests`](https://github.com/juliuste/fpti-tests) in their tests**.

### Method overview

All `method`s 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])`](docs/stations-stops-regions.all.md) | **All** stations/stops/regions of the network. | [`Readable`](https://nodejs.org/api/stream.html#stream_readable_streams) → [`station`](https://github.com/public-transport/friendly-public-transport-format/blob/master/spec/readme.md#station) / [`stop`](https://github.com/public-transport/friendly-public-transport-format/blob/master/spec/readme.md#stop) / [`region`](https://github.com/public-transport/friendly-public-transport-format/blob/master/spec/readme.md#region)
[`stations.search(query, [opt])` / `stops.search(query, [opt])` / `regions.search(query, [opt])`](docs/stations-stops-regions.search.md) | Search stations/stops/regions by *query*. | [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) → [`[station]`](https://github.com/public-transport/friendly-public-transport-format/blob/master/spec/readme.md#station) / [`[stop]`](https://github.com/public-transport/friendly-public-transport-format/blob/master/spec/readme.md#stop) / [`[region]`](https://github.com/public-transport/friendly-public-transport-format/blob/master/spec/readme.md#region)
[`stations.nearby(location, [opt])` / `stops.nearby(location, [opt])` / `regions.nearby(location, [opt])`](docs/stations-stops-regions.nearby.md) | Search stations/stops/regions by *location*. | [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) → [`[station]`](https://github.com/public-transport/friendly-public-transport-format/blob/master/spec/readme.md#station) / [`[stop]`](https://github.com/public-transport/friendly-public-transport-format/blob/master/spec/readme.md#stop) / [`[region]`](https://github.com/public-transport/friendly-public-transport-format/blob/master/spec/readme.md#region)
[`journeys(origin, destination, [opt])`](docs/journeys.md) | Journeys between stations (or optionally other locations) | [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) → [`[journey]`](https://github.com/public-transport/friendly-public-transport-format/blob/master/spec/readme.md#journey)
[`stopovers(station, [opt])`](docs/stopovers.md) | Departures and arrivals at a given station (or optionally other location) | [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) → [`[stopover]`](https://github.com/public-transport/friendly-public-transport-format/blob/master/spec/readme.md#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](https://github.com/public-transport/fpti-js/issues). Keep our [contributing guidelines in mind](contributing.md). Note that, by participating in this project, you commit to the [code of conduct](code-of-conduct.md).