This project is a small JavaScript script that fetches real-time information about vehicles in Prague. PID (Pražská Integrovaná Doprava) has made a beautiful live map of all the transportation vehicles using their API. Using this API, this script is able to pull the data.
I am not affiliated with PID in any way, and I am not responsible for any misuse of their API!
Warning! The INTERVAL_MINUTES
variable in the .env file is the time in minutes between each fetch.
Please use PID’s API responsibly and do not overload their servers.
I was unable to find any information whether one can use the API for personal use and grab the data externally. The API does not have any kind of authentication or rate limiting by my knowledge. If the PID wishes me to take down this repository, please contact me at my email. I am absolute willing to cooperate, and I will respect the decision. Thank you.
- Metro
- Tram
- Buses
- Trains
- Ferries
- Trolleybuses
- Support for more vehicles might be added in the future.
- Clone the repository
- Run
npm install
- Fill the
.env
file - Run
node index.js
It is required to have a MySQL table created with the following structure in order to store the data.
create table metro
(
id int auto_increment primary key,
fetch_datetime datetime default CURRENT_TIMESTAMP null,
c_trains int not null,
b_trains int not null,
a_trains int not null
);
Well, you can use external tools such as Grafana to visualize the data. Based off the visualisation, you will be able to see the peak times and times of no operation. If any incidents will happen, you will be able to see the impact on the transportation system.