A node package for accessing Network Rail TRUST data

Usage no npm install needed!

<script type="module">
  import openraildataTrust from '';



Travis Version GitHub license sheilds

A Node.JS package which connects to Network Rail's TRUST system to provide information on the UK rail network.



npm install openraildata-trust

Example usage

An example of a subscription to all UK train movement and printing the results to the console.

'use strict';

const Trust = require('openraildata-trust');
const trust = new Trust('username', 'password');

trust.connect((err) => {
    trust.subscribe('TRAIN_MVT_ALL_TOC', (er, msg) => {
      if (!er) {


Trust = require('openraildata-trust')

Require returns a constructor for STOMP client instances.

Trust(username, password)

  • username: Your Network Rail Datafeeds email
  • password: Your Network Rail Datafeeds password


Will attempt to connect to Network Rails TRUST STOMP server. Any errors which occur during connection will be returned through the callback in the first parameter. If no error occurs then the first parameter will be null

trust.disconnect([timeout], [callback])

  • timeout: Wait value (in ms) before disconnecting. (default is 0ms).
  • callback: A callback function that is called after disconnecting.

Disconnectes from the TRUST server. Before disconnecting all subscriptions will be unsubscribed.

trust.subscribe(topic, callback)

  • topic: The topic name to subscribe to (Should not contain '/topic/' as this is prepended within the function). These can be found at: under the available feeds sections. This does also require an active account on and
  • callback: A callback function that is called as a new message arrives or on an error. The first parameter will hold an error or null and the second parameter will contain a JSON object with the message.