Skip to main content

Realtime Trains API Python Module


Maintained and managed by anonymous4401/anonymous44401

PyPI License Issues Downloads

Latest release

Pre-releases

Documentation

Repository

Discord

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 three 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. 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

realtime-trains-py 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 three complexities. Each complexity mode gives you access to different 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="simple".

Using simple mode, you can 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 objects, so you'll need to get the data out of the objects yourself. To use normal mode, use complexity="simple_normal". If you're confused, check out the documentation.

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="complex".

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(
    request_token="<your_request_token>",
    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 by visiting the API home page.

Examples

Watch Service

The example below will display a live service board for G28171.
rtt.watch_service(service_uid="G28171")

Watch Service (Async)

The example below will display a live service board for G28171.
import asyncio
await rtt.watch_service(service_uid="G28171")

Lookup

The example below will display all CRS codes and TIPLOCs for London Liverpool Street.
rtt.lookup(location="London Liverpool Street")
The example below will display the location for LST (London Liverpool Street).
rtt.lookup(code="LST")

Get Live (Async)

The example below will display a live service board for G28171.
import asyncio
await rtt.watch_service(service_uid="G28171")

Get Live

The example below will display a live departure board for Ely.
rtt.get_live(tiploc="ELYY")

Get Departures

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)

Get Service

The example below will return the service information of G28171 at the time you run the program.
rtt.get_service(service_uid="G28171")

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

Licensing

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

All data is kindly provided by Realtime Trains through the Realtime Trains API. This package is not affiliated with Realtime Trains.

Artificial Intelligence

The realtime-trains-py package has been written entirely by hand without any assistance from Artificial Intelligence.

The following items have been written with the assistance of Artificial Intelligence:

  • bug_report.md
  • CONTRIBUTING.md
  • feature_request.md
  • README.md
  • realtime-trains-py Wiki
  • SECURITY.md

Metadata

Release files for realtime-trains-py 2027.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for realtime-trains-py 2027.2.1
File Size Uploaded Provenance Actions
realtime_trains_py-2027.2.1.tar.gz 30.4 kB Without provenance Details for realtime_trains_py-2027.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for realtime-trains-py 2027.2.1
File Interpreter ABI Platform Actions
realtime_trains_py-2027.2.1-py3-none-any.whl Python 3 none any Details for realtime_trains_py-2027.2.1-py3-none-any.whl

Total release size: 58.3 kB

Release files / realtime_trains_py-2027.2.1.tar.gz

Download URL realtime_trains_py-2027.2.1.tar.gz
Size 30.4 kB
Tags Source
SHA-256 checksum
How to use checksums
91891bb03446084e7c426f3e872c6f22ec7cbbfc8af11bd6a846b748ce283e57
BLAKE2b-256 checksum
How to use checksums
0f25f763199783978b63ae7ac3c65c3719376861331ca788936287113d9fca35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / realtime_trains_py-2027.2.1-py3-none-any.whl

Download URL realtime_trains_py-2027.2.1-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
520dcdaebc8e27efacf76d65ae66ae66d7b1edbd1e8fc85e8b55a882ba840d16
BLAKE2b-256 checksum
How to use checksums
512a8abb3762f53d2b36e5f38e50db8093ed6fd29c22f8aff2365c636f32d458
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for realtime-trains-py 2027.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2027.2.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page