Setup - realtime-trains-lang/realtime-trains-py GitHub Wiki

Setting up the realtime-trains-py package

Depending on how you want to run the package, there are a few things that you need to do before you can start using the package. To get help that's specific to your needs, read through the section below, then click one of the links to get directed to the right place.

Let's get started!

Before you start, you need to make sure the package is installed on your machine. Make sure you're running the latest version for the most optimised experience. You'll also need a compatible version of python. realtime-trains-py is compatible with Python 3.8 and newer. We recommend Python 3.13 for the best experience.

To install, simply run:

py -m pip install --upgrade realtime-trains-py

You can run this in your terminal.

Some external required packages will be automatically installed when you install realtime-trains-py. These include:

  • tabulate
  • requests

Initialising

I've forked, cloned or downloaded this repository onto my device

Forking, cloning or downloading this repository onto your device allows you to edit the code to suit your own needs. This also allows you to contribute to the repository by submitting a pull request. This setup option is recommended for users who have a very good understanding of Python.

I'm using the package in my terminal

Installing this package using pip in your terminal is a great option, as the pip will have the most up-to-date code and be 100% what you see on this repository. This setup option is recommended for users who have a good understanding of Python.

I'm using the package in a file

Installing this package using pip is the recommended option, as pip will have the most up-to-date code and be 100% what you see on this repository. This setup option is recommended for users who do not have a good understanding of Python.


Setting up the package locally

[!WARNING] If you would like to contribute to this project by submitting a pull request, please ensure that your local copy of the repository is thoroughly reviewed and free of any sensitive or personal information. This includes, but is not limited to, usernames, passwords, API keys, or any other credentials that might compromise your security or the integrity of the repository.

Keep in mind that all pull requests are public and can be viewed by anyone on the internet once submitted. To protect your privacy and maintain the security of your systems, double-check your code and configuration files before making any changes public.
Not all submitted pull requests will be merged into the main branch

By following these guidelines, you help keep the project secure and maintain a professional standard for collaboration within the community. If you are unsure about the process or need assistance, feel free to check the GitHub documentation on pull requests or reach out to the repository maintainers for guidance.


To start, you need to initialise the package in your file. To do this, you'll need to create a new Python file called [your_file].py. In this file, you'll need to import __init__ and assign RealtimeTrainsPy() to a variable of your choosing, like below. You should do this for any new python files you create.

You'll also need to import sys and append the path to realtime-trains-py to ensure you're running code from the cloned repository as opposed to the code on pip.

import sys
sys.path.append("path/to/folder/realtime-trains-py/src/realtime_trains-py")

from __init__ import RealtimeTrainsPy

rtt = RealtimeTrainsPy(
    username="<your_username>",
    password="<your_password>",
    complexity="<your_complexity>" # Remember, complexity is optional
)

We recommended that you create a separate folder called tests/ for your code.

Make sure you change the username and password fields for your own authentication details!

When you initialise RealtimeTrainsPy, you can provide 2 or 3 arguments. These are:

  • Your complexity (optional)

  • Your username (required)

  • Your password (required)

Don't have a username or password?

This will allow you to begin using the package. Check out our documentation for step-by-step guides on how to do this. You can also have a look at the examples.

Your final step is the try running the program. If you have followed this setup guide correctly, you shouldn't receive any errors. If you receive an error, re-read the setup guide and report an issue with realtime-trains-py on GitHub so that we can check our systems.

That's all you need to know to set up the package locally on your device. Any other queries you have will likely have answers already on this wiki. If you're still unsure, head to either the discussions or issues page to check for community-created answers.


Setting up the package in your terminal

When you open your terminal, make sure you're running python, or you won't be able to do anything. On Windows, can do this by simply typing py and pressing enter.

Start by typing the following line into your terminal. Make sure you click enter afterwards.

from realtime_trains_py import RealtimeTrainsPy

For the next part, you'll need a username and password. I don't have a username or password.

Run the command below - make sure you change the credentials to your ones or you'll get an error when you press enter.

rtt = RealtimeTrainsPy(username="[your_username]", password="[your_password]", complexity="[select_type]")

When you initialise the package, you can provide 2 or 3 arguments. These are:

  • Your complexity (optional)

  • Your username (required)

  • Your password (required)

Don't have a username or password?

This will allow you to begin using the package. Check out our documentation for step-by-step guides on how to do this. You can also have a look at the examples.

Your final step is the try running the program. If you have followed this setup guide correctly, you shouldn't receive any errors. If you receive an error, re-read the setup guide and report an issue with realtime-trains-py on GitHub so that we can check our systems.

That's all you need to know to set up the package in a file. Any other queries you have will likely have answers already on this wiki. If you're still unsure, head to either the discussions or issues page to check for community-created answers.


Setting up the package in a file

Running the realtime-trains-py package using pip will require you to implement a few things before you can start.

To start, you need to initialise the package in your file. To do this, you'll need to create a new Python file called [your_file].py. In this file, you'll need to import realtime_trains_py and assign RealtimeTrainsPy() to a variable of your choosing, like below.

from realtime_trains_py import RealtimeTrainsPy

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

When you initialise the package, you can provide 2 or 3 arguments. These are:

  • Your complexity (optional)

  • Your username (required)

  • Your password (required)

Don't have a username or password?

This will allow you to begin using the package. Check out our documentation for step-by-step guides on how to do this. You can also have a look at the examples.

Your final step is the try running the program. If you have followed this setup guide correctly, you shouldn't receive any errors. If you receive an error, re-read the setup guide and report an issue with realtime-trains-py on GitHub so that we can check our systems.

That's all you need to know to set up the package in a file. Any other queries you have will likely have answers already on this wiki. If you're still unsure, head to either the discussions or issues page to check for community-created answers.


I don't have a username or password

To get a username and password, head over to the api portal and select register. Follow the appropriate steps on the site. Once logged in, you'll be directed to the API home page. This page shows you your API auth credentials - these are the details you'll use to access the API. Your username is prefixed with rttapi_ and your password will be a 40-character hex string. Copy these details and paste them into your code.

[!CAUTION] Keep your username and password private.