Downloads archived MBTA real-time data feeds from various sources.
- Python 3
- Mac/Linux: can install using asdf (
asdf installin this directory) - Mac: can install from Homebrew (
brew install python3 pipenv) - Windows:
- download from official site
- install Pipenv:
pip3 install --user pipenv
- Mac/Linux: can install using asdf (
- AWS CLI
- Mac: can install from Homebrew (
brew install awscli) - Any: can install as a global Python package (
pip3 install --user awscli) - Use
aws configureto set up your credentials:- "Access Key ID" and "Secret Access Key" are provided by an AWS admin
- Enter "Region" as
us-east-1 - Press Enter when prompted for a default output format
- Mac: can install from Homebrew (
pipenv installin this directoryexport S3_BUCKET_NAME=x, replacingxwith bucket name stored in 1Password
git clone https://github.com/mbta/prediction_loc.gitcd prediction_loc
poetry run prediction-loc --datetime (date -Iminutes -d 'last Fri')
poetry run prediction-loc --datetime (date -Iminutes -d 'last Fri')
| Argument | Description |
|---|---|
--stop [stop id] |
Use to only include trip_updates affecting the given (comma-separated) stop_id(s) |
--route [route id] |
Use to only include trip_updates affecting the given route |
--trip [trip id] |
Use to only include a specific trip_id |
--feed [name] |
Feed to retrieve. Accepted values: bus (default), subway, cr, cr_vehicle, cr_boarding, winthrop, concentrate, concentrate_vehicle, alerts, busloc, busloc_vehicle, swiftly_bus_vehicle |
--raw |
Download the file directly, without filtering or processing |
--output [filepath] |
Where to create the output file (default is prediction-loc/output/[feed]-[datetime].json) |
Note: route_id is matched exactly for the bus and concentrate feeds, but does substring matching for all others. For example, --route Green will include all Green Line branches, and --route Worcester will still match route_id CR-Worcester.
If the aws command cannot be found, you will need to add it to your PATH:
- Find the location of the install by running the command
python3 -c 'import awscli; print(awscli)'
- It should print something similar to
<module 'awscli' from '/Users/localuser/Library/Python/3.6/lib/python/site-packages/awscli/__init__.py'\>
- Cut off the end of the filepath, starting with
lib, and add/binto get a path that looks like/Users/localuser/Library/Python/3.6/bin - Add that to your
PATHby opening (or creating)~/.bash_profileand addingexport PATH=$PATH:/Users/localuser/Library/Python/3.6/bin(using the path you created in step 2) - Open a new terminal window or run
source ~/.bash_profileto apply your changes