-
Notifications
You must be signed in to change notification settings - Fork 3
Examples
We've got you covered. This page provides you with examples of how to run and use the API Wrapper.
Firstly, 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. To install, simply run:
pip install --upgrade realtime-trains-py
You may need to install some of the external required packages for the package to work. These include:
- tabulate
- requests
To install these, run:
pip install --upgrade [package]
Make sure you change [package] to either tabulate or requests.
Initialising the package is super easy. If you're running the package in a terminal, follow the example below. If you're using a file to do this, skip to the next section.
When you open your terminal, make sure you're running python, or you won't be able to do anything.
Start by typing the following line into your terminal. Make sure you click enter afterwards.
from realtime_trains_py import RealtimeTrainsPyFor 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 try running the code later.
rtt = RealtimeTrainsPy(username = "[your_username]", password = "[your_password]", complexity = "[select_type]")And that's how to set up the realtime-trains-py package using the terminal. It's super easy.
When you open your file, make sure it's a .py file, or you won't be able to do anything.
Start by typing the following line into your file.
from realtime_trains_py import RealtimeTrainsPyFor the next part, you'll need a username and password. I don't have a username or password.
Below the line you just wrote, type the following - make sure you change the credentials to your ones or you'll get an error when you try running the code later.
rtt = RealtimeTrainsPy(username = "[your_username]", password = "[your_password]", complexity = "[select_type]")The whole file should look like this:
from realtime_trains_py import RealtimeTrainsPy
rtt = RealtimeTrainsPy(username = "[your_username]", password = "[your_password]", complexity = "[select_type]")And that's how to set up the realtime-trains-py package in a file. Now you're ready to start crunching the data!
All of our data is kindly provided by Realtime Trains.