Skip to content

This script uses trafiklab data to track services operation times

License

Notifications You must be signed in to change notification settings

BrunoSalerno/trafiklab_service_tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trafiklab_service_tracker

This tool fetches information about current journeys of a given transit route using the TrafikLab APIs. The data is only available for Stockholm, Sweden. The script checks the expected and actual time of departure/arrival by stop, for all the current journeys of the route. When each journey finishes, its final values are appended to a CSV file. The script tries to make the least number of requests, with five retries at most in case of error.

Setup

  • Install pipenv
  • Clone/download this repository
  • Inside the folder, run pipenv install
  • Fetch the API keys from Trafiklab (see below).

Usage

API_KEY=<Your API key> SERVICE="Bus 550" ORIGIN=9703 DESTINATION=5889 pipenv run python main.py

Optional parameter FREQ can be used to set the iteration frequency (in minutes). Default: 1 minute.

The api key is the one for the Trafiklab's TravelPlanner V3.1 API. The ids of origins and destinations can be fetched with the Trafiklab's Platsuppslag API, which can be done directly with the find_site script included in this repo (see next).

find_site script

This script allows you to find the site_id of any place in Stockholm. To use it, you need the Platsuppslag API key.

API_KEY=<Your API key> pipenv run python find_site.py Stora Torget

API keys

To get your API keys, you have to create a project in Trafiklab, enable the desired APIs, and generate the keys.

About

This script uses trafiklab data to track services operation times

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages