Skip to main content

Python API Wrapper Package for the RealTime Trains API.

Project description

Realtime Trains API Python Module

Maintained and managed by members of realtime-trains-lang

PyPI License Issues

View our release notes

Documentation

About this package

realtime-trains-py is an open-source python API Wrapper designed to allow you to access data directly from the Realtime Trains API, in a simple and user-friendly way. This package includes five different complexity modes that allow you to customise how you want to see the data provided by the API.

This package can be used for anything railway related, whether you're a rail enthusiast or commuter, this package can be used for all your purposes. The package can be used in personal applications or for personal rail data access. For commercial use, you should contact Realtime Trains. More information can be found on their API home page

This package is not affiliated with Realtime Trains.

What can I do with this package?

This package allows you to access data directly from the Realtime Trains API using one of five complexities. Each complexity mode gives you access to different access to the data the API offers.

For the most flexibility, you can use simple mode, the recommended mode. Simple mode allows you to access a fair amount of the data available from the Realtime Trains API. This mode is recommended for those that want a manageable amount of information while keeping it easy to read. Use complexity="s".

For the most freedom with the API, you can use complex mode. Complex mode lets you access all the data available from the Realtime Trains API. This mode does not format any data for you - it creates new .json files with the data you requested. This mode is recommended for those who have a good understanding of python and managing json files. Use complexity="c".

For a balance of freedom and flexibility, you can use advanced mode. Advanced mode allows you to access most of the data available from the Realtime Trains API. This mode is recommended for those that want to see a bit more information, but like to keep things easy to read. Use complexity="a".

Using advanced and simple mode, you can optionally select between prettier or normal mode. The default, prettier mode, gives you your data in a nicely formatted table, while normal mode gives you your data as a list of objects, so you'll need to get the data out of the objects yourself. To use a normal mode use complexity="s.n" or complexity="a.n". Don't worry though! If you're confused, we have plenty of documentation to help you out.

Installation Instructions

To install the package, simply run the following command in your terminal:

$ pip install realtime-trains-py

Alternatively, you can clone, fork or download the repository onto your device.

Once installed, you can import the package. Place the lines below in your file, or you can run them directly in your terminal.

from realtime_trains_py import RealtimeTrainsPy

rtt = RealtimeTrainsPy(
    username="<your_username>", 
    password="<your_password>", 
    complexity="<your_choice>"
)

Check out our full setup guide for more help setting up.

You'll need an account for the Realtime Trains API to use this package. You can sign up for free at the API home page.

Examples

The example below will return up to 15 rows on the departure board for London King's Cross at the time you run the program.

rtt.get_departures(tiploc="KNGX", rows=15)

The example below will return up to 15 rows on the arrivals board for London King's Cross at the time you run the program.

rtt.get_arrivals(tiploc="KNGX", rows=15)

The example below will return the service information of G28171 (2H18 0958 London Liverpool Street to Cambridge North) at the time you run the program.

rtt.get_service(service_uid="G28171")

The example below will return up to 15 rows of departures and arrivals for London King's Cross at the time you run the program.

rtt.get_station(tiploc="KNGX", rows=15)

More in-depth examples can be found on our examples page.

License

The realtime-trains-py API Wrapper uses an MIT License.

All of our data is kindly provided by Realtime Trains.

Project details


Download files

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

Source Distribution

realtime_trains_py-2025.2.1.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

realtime_trains_py-2025.2.1-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

Details for the file realtime_trains_py-2025.2.1.tar.gz.

File metadata

  • Download URL: realtime_trains_py-2025.2.1.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for realtime_trains_py-2025.2.1.tar.gz
Algorithm Hash digest
SHA256 78806503191f1b5554defbd5f803b17143ac7c4e96a5dacc94f456455c569758
MD5 8604e7c483724af27be7a025b0f171dd
BLAKE2b-256 4956700fd4860a1446745cb9545898ce9531818107260d37751a6fd2a079be9f

See more details on using hashes here.

File details

Details for the file realtime_trains_py-2025.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for realtime_trains_py-2025.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21fe60ffc5fa7807aa28185dd9f2f878482084de91b008020fa43073cab3a2dc
MD5 ec956f627ecc5c2aee99561314d25690
BLAKE2b-256 df0be451fef8ba80e663c197d22f11505edf99bd600520d0a2ca691d0b1588d3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page