Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A simple python wrapper around National Rail Enquires LDBS SOAP Webservice

Project Description


nre-darwin-py provides an abstraction layer for accessing National Rail Enquiries Darwin service via their LDB SOAP web service. This service provides live departure board information for all United Kingdom train stations.

This module has the following goals:

  • Allow developers to avoid the complexity of SOAP and the decisions involved in choosing a Python SOAP client
  • Provide a more pythonic interface to station board and service details information
  • Make useful documentation available through pydoc or through the help command in the python shell
  • Facilitate the easy creation of departure board websites and webservices

Getting started

You will need to register for Darwin access, you can do this via National Rail Enquiries developer site.

Then install nre-darwin-py:

pip install nre-darwin-py

Basic usage

Initiate a session:

>>> from nredarwin.webservice import DarwinLdbSession
>>> darwin_sesh = DarwinLdbSession(wsdl="", api_key="YOUR_KEY")

Retrieve the departure board for Manchester Piccadilly station:

>>> board = darwin_sesh.get_station_board('MAN')
>>> board.location_name
'Manchester Piccadilly'
>> board.train_services[0].destination_text
'Rose Hill Marple'

Retrieve more detailed information regarding a particular service:

>>> service_id = board.train_services[0].service_id
>>> service = darwin_sesh.get_service_details(service_id)
>>> [cp.location_name for cp in service.subsequent_calling_points]
[Gorton, Fairfield, Guide Bridge, Hyde Central, Woodley, Romiley, Rose Hill Marple]

The provided script shows a simple departure board implementation for your reference


  • The environment variables DARWIN_WEBSERVICE_WSDL and DARWIN_WEBSERVICE_API_KEY can be used to set the WSDL url and api key, so you don’t have to specify them when initiating a DarwinLdbSession.
  • The WSDL url for the LDB Webservice may change from time to time, and has in the past. Your application should take this into account.
  • Any call to get_station_board or get_service_details will result in a query to the LDB Webservice, and therefore an HTTP request to an external service. Your application will need to handle caching and failure modes itself.
  • There is an overhead involved when creating a DarwinLdbSession, as the WSDL must be retrieved and parsed.


Additional contributions by George Goldberg. Advice on SUDS proxy issues from Pete Barking.


  • Make departure and arrival times available as timezone-aware datetime objects
  • More detailed exception handling
  • More examples

Release History

This version
History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(7.6 kB) Copy SHA256 Hash SHA256
Source Feb 6, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting