-
Notifications
You must be signed in to change notification settings - Fork 3
Setup
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.
How are you using the package?
I've downloaded this repository onto my device
I've installed the package using pip
If you're running the package locally, the first step is to create a new file in the authentication folder called .env. This will allow the package to reference your username and password without you having it on display in your code. I don't have a username or password.
Important
Keep your username and password private.
Set up your file like this:
api_username = "your_username"
api_password = "your_password"
Ensure you change the respective fields above to contain your username and password, or the package won't work and you'll receive and error.
Running the realtime-trains-py package locally on your machine will require you to implement a few things before you can start. You can skip step one (1) if you have installed the package using pip install realtime-trains-py.
The first step is to create a file called .env. You should add this file into the authentication folder. This will allow the package to reference your username and password without you having it on display in your code. I don't have a username or password.
Important
Keep your username and password private.
Set up your file like this:
api_username = "your_username"
api_password = "your_password"
Ensure you change the respective fields above to contain your username and password, or the package won't work and you'll receive and error.
The second step, is to initialise the package. To do this, you'll need to make a new python file: 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 [tbc] import [tbc]
your_var = RealtimeTrainsPy()
When you initialise RealtimeTrainsPy(), you can provide between zero (0) and three (3) arguments, like below.
your_var = RealtimeTrainsPy(complexity = "", username = "your_username", password = "your_password")
Important
Make sure you provide both your username and password together, or you won't be able to access the API.
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.
Simple (s)
Simple mode provides you with access to some data the API has to offer. This mode only allows you to view data fom seven (7) days before the current date and 80 days after the current date. Any data you request from the API will be formatted so you can understand and read it.
This is recommended for users who don't want to see all the nerdy train stuff.
Advanced (a)
Advanced mode provides you with access to most data the API has to offer. This mode only allows you to view data fom seven (7) days before the current date and 80 days after the current date. Any data you request from the API will be formatted so you can understand and read it.
This is recommended for users who want to see all the nerdy train stuff, but with similar restrictions as simple mode.
Complex (c)
Complex mode provides you with access to all data the API has to offer. This mode offers no restrictions to what you can access, however it does not format any data for you. Other modes will provide data in a set format, but complex mode will only provide you data as a new .json file.
This mode is recommended for anyone with understanding of json files and who wants to see all the nerdy train stuff.
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.
Important
Keep your username and password private.
All of our data is kindly provided by Realtime Trains.