HTTP server for Metlink PID

pip install metlinkpid-http==1.0.0


metlinkpid-http: HTTP server for Metlink PID

latest release on PyPI

The metlinkpid-http script provides an HTTP endpoint for a Metlink LED passenger information display:

$ metlinkpid-http --serial=/dev/ttyUSB0
Serving on

$ curl '|Limited+Express|_Stops+all+stations+except+East+Richard'
{"error":null,"message":"12:34 FUNKYTOWN~5|Limited Express|_Stops all stations except East Richard"}


Install from PyPI using pip:

pip install metlinkpid-http

Basic usage

Find the device

Determine the device to which the display is connected. On Linux, this can be achieved by disconnecting the display from the computer & reconnecting, then inspecting the contents of dmesg output for USB attachment messages:

[    3.010816] usb 1-1.4: FTDI USB Serial Device converter now attached to ttyUSB0

The above output indicates that the display is reachable through /dev/ttyUSB0.

Start the HTTP server

Run the script passing that device location as the --serial option:

$ metlinkpid-http --serial=/dev/tty/USB0

The script accepts the following options:

The PID serial device name, such as /dev/ttyUSB0 on Linux or COM1 on Windows. If not specified, defaults to the value of environment variable METLINKPID_SERIAL; if no such variable, defaults to /dev/ttyUSB0.
The hostname/IP address and port to listen on, separated by a colon (:). If not specified, defaults to the value of environment variable METLINKPID_HTTP; if no such variable, defaults to
-h or --help
Displays usage information similar to above, and provides a link to this documentation.

If the PID successfully connects, the URL is confirmed:

Serving on

Display a message

Next, browse to the specified URL in a browser, adding an appropriately encoded query string to the end:

You should see a plain-text JSON result similar to this:

{"error":null,"message":"MY MESSAGE"}

The same result can be obtained on the terminal using curl:

$ curl ''
{"error":null,"message":"MY MESSAGE"}

You could do the same thing in Python like this, using the "requests" library:

>>> import requests
>>> requests.get('').json()
{'error': None, 'message': 'MY MESSAGE'}

By exposing the display via HTTP in this way, you can operate it using almost any programming language or toolkit.

See the "metlinkpid" module documentation for full details about message formatting.

The HTTP server also periodically pings the display in the background, preventing message display timeout.


Bug reports, feature requests, and questions are welcome via the issue tracker.

Issue tracker:


Pull requests for both code and documentation improvements are gratefully received and considered.

GitHub repository:


This project is licensed under the MIT License.