Departure

This is the documentation for the Python Departure package.

Prerequisites

Register for the transport operators you want to get information from (registration is free for all the listed transport operators at the time of writing):

Install Python 3.6 or greater.

(Optional, recommended) create a Python virtual environment.

Installation

Install Python package.

$ pip install departure

Usage

There are three command line interface tools:

Environment variables

Before running departure or departure-web, set the following environment variables (see below for further instructions) for the public transport operators of interest:

To set an environment variable with the name SOME_VAR and the value some_value:

Alternatively, you can use the set_env_vars.bat.template and set_env_vars.sh.template files in the repository to set the environment variables automatically:

Main CLI

Make sure you have set the environment variables you need as described above.

To get started, display the main CLI's help page.

$ departure

departure CLI

The following command searches for SNCF (FR) stations containing "Paris".

$ departure sncf search paris

departure sncf search paris

The following command shows the next departures at Den Haag Centraal (NL).

$ departure ns next gvc

departure ns next gvc

The following command shows the next Westbound departures on Central Line at Oxford Circus.

$ departure lu next ce oxc w

departure lu next ce oxc w

The following command updates a departure board with SNCF (FR) departures at Paris Montparnasse.

$ departure sncf board 87391003

The departure <operator> board commands require a running a Departure board server on a physical or virtual departure board – see below for Python Departure board servers and https://github.com/spujadas/departure-board-servers-cpp for C++ Departure board servers.

Web API server

Make sure you have set the environment variables you need as described above.

To start the Departure web API server:

$ departure-web

The server will run on port 8000, e.g. if installed locally browse to http://localhost:8000.

The OpenAPI documentation can be found at /docs, e.g. http://localhost:8000/docs.

Departure OpenAPI documentation page

Here is a sample cURL command to update a board, in this case with departure information for Montparnasse SNCF station (FR):

$ curl -X POST http://localhost:8000/sncf/start-client -d "{\"stop_area_id\": \"87391003\"}"

Alternatively, you can use a REST GUI client, such as Insomnia (shown below) or Postman.

Using Insomnia as a client for Departure's web API

Web front end

To use the Departure web front end:

Departure web front end - SNCF Montparnasse

Departure board server

To run a Python Departure board server on a virtual or physical departure board, you will first need to install one or several Python back ends.

Run the following command to list the available back ends.

$ departure-server

departure-server CLI

About

Written by Sébastien Pujadas, released under the MIT license, with additional provisions as per below.

All product names, logos, and brands are property of their respective owners. All company, product and service names used in this project are for identification purposes only. Use of these names, logos, and brands does not imply endorsement.

The London Underground (TfL Tube) engine is powered by TfL Open Data. Contains OS data © Crown copyright and database rights 2016' and Geomni UK Map data © and database rights [2019].

The National Rail engine is powered by National Rail Enquiries. The built-in list of National Rail station codes was derived from https://www.nationalrail.co.uk/stations_destinations/48541.aspx.

The built-in list of Nederlandse Spoorwegen station codes was retrieved from Rijden de Treinen.

The built-in WSDL file used to access RATP's real-time web service was extracted from RATP's API development kit.

The built-in list of SNCF stations (used by the SNCF and Transilien engines) was obtained from the Gares de voyageurs dataset, which is released under the ODbL (Open Database License).

The built-in list of Transilien stations and stops was obtained from the Gares et points d'arrêt du réseau Transilien dataset, which is released under the ODbL (Open Database License).