MBTA

From LibrePlanet
Jump to: navigation, search

Introduction

This page includes ways to liberate usage of the Massachusetts Bay Transportation Authority (MBTA) or "The T." By default, using the MBTA schedules and apps contain nonfree software. Let us explore ways to plan travel around Boston in a better way together.

MBTA Maps

Low-tech

Go to a bus stop or train station and wait until a bus or train arrives. Find paper time schedules for the routes you frequent at popular stations such as Park Street.

The drawback to this method is that buses and trains do not always stick to the schedule. Planning is difficult and you may be late to your destination.

MBTA API

Usage of the MBTA API seems to be the most freedom respecting digital route at this time. This method is efficient as only the requested data is pulled instead of an entire webpage which helps when using metered connections.

Website

Documentation

Source code with MIT (expat) license

Requesting a key does require nonfree JavaScript to be enabled, but does not require a captcha.

Configuring dependencies for Replicant

The MBTA API can be accessed through Replicant using Termux. These tools come with most GNU/Linux operating systems be default.

  1. Install Termux from F-Droid.
  2. Open Termux.
  3. Install curl and python. pkg install -y curl python
  4. All set!

Installing the Hacker's Keyboard from F-Droid is also recommended, but not required.

Note: If Termux is closed improperly without exit, the .bash_history might be lost. It is recommended to use these upcoming commands in simple bash scripts so that they can be easily be copied or modified without needing to retype the addresses or API keys.

Using Curl without an API key

Replace 70020 with the stop id. Bus stop ids can usually be read from the sign at the stop. Additional methods of finding stop ids can be found below.

curl "https://api-v3.mbta.com/predictions?filter%5Bstop%5D=70020" | python -m json.tool

The API will let you pull once every so often without an API key. This is useful if you do not have an API key yet.

Using Curl with an API key

Replace INSERTAPIKEYHERE with a valid API key.

curl -sN -H "x-api-key: INSERTAPIKEYHERE" "https://api-v3.mbta.com/predictions?filter%5Bstop%5D=70020" | python -m json.tool

Pulling a stream using an API key

curl -sN -H "accept: text/event-stream" -H "x-api-key: INSERTAPIKEYHERE" "https://api-v3.mbta.com/predictions?filter%5Bstop%5D=70020"

The stream will be kept open and only updates will come through. Between updates the connection will give a keep alive notification. The stream will have to be stopped with CTRL + c.

Note that busy stations will include noise that does not pertain to the next vehicle.

Stop IDs

Downloading the list of stops

curl "https://api-v3.mbta.com/stops" > stops.txt

The stops list is about 5.4MB of json.

Parsing the stops list

Example: Find the Orange line stop ids leading to Forest Hills.

python -m json.tool stops.txt | grep -A12 ' - Orange Line - Forest Hills'

Downtown Crossing - Orange Line - Forest Hills is stop 70020.

Complications:

  • The red and green lines have converging tracks so the above method will not always work.
  • Stations have several stop ids that include platforms, busways, elevators, escalators, and more.
  • End stations have two platforms going the same direction with two separate ids. They usually run frequently enough that this is not an issue.

Example: List all subway platforms.

python -m json.tool stops.txt | grep -A12 -e ' - Red Line - ' -e ' - Green Line - ' -e ' - Orange Line - ' -e ' - Blue Line - ' | grep -e description -e \"id | cut --delimiter=\" --fields=4 | sed '2~2s/^/: /' | paste - - | sed 's/[ \t]*:/:/' | sort -t'-' -k2

Explanation: cut --delimiter=\" --fields=4 only prints the 4th field delimited by ". sed '2~2s/^/: /' add ': ' to the beginning of every other line starting at the second line. paste - - combines every other line. sed 's/[ \t]*:/:/' removes white space before a colon. sort -t'-' -k2 sorts based on the second column delimited by -.

Orange Line Stops

  • Green Street - Orange Line - Forest Hills: 70002
  • Stony Brook - Orange Line - Forest Hills: 70004
  • Jackson Square - Orange Line - Forest Hills: 70006
  • Roxbury Crossing - Orange Line - Forest Hills: 70008
  • Ruggles - Orange Line - Forest Hills: 70010
  • Massachusetts Avenue - Orange Line - Forest Hills: 70012
  • Back Bay - Orange Line - Forest Hills: 70014
  • Tufts Medical Center - Orange Line - Forest Hills: 70016
  • Chinatown - Orange Line - Forest Hills: 70018
  • Downtown Crossing - Orange Line - Forest Hills: 70020
  • State - Orange Line - Forest Hills: 70022
  • Haymarket - Orange Line - Forest Hills: 70024
  • North Station - Orange Line - Forest Hills: 70026
  • Community College - Orange Line - Forest Hills: 70028
  • Sullivan Square - Orange Line - Forest Hills: 70030
  • Wellington - Orange Line - Forest Hills: 70032
  • Malden Center - Orange Line - Forest Hills: 70034
  • Assembly - Orange Line - Forest Hills: 70278
  • Green Street - Orange Line - Oak Grove: 70003
  • Stony Brook - Orange Line - Oak Grove: 70005
  • Jackson Square - Orange Line - Oak Grove: 70007
  • Roxbury Crossing - Orange Line - Oak Grove: 70009
  • Ruggles - Orange Line - Oak Grove: 70011
  • Massachusetts Avenue - Orange Line - Oak Grove: 70013
  • Back Bay - Orange Line - Oak Grove: 70015
  • Tufts Medical Center - Orange Line - Oak Grove: 70017
  • Chinatown - Orange Line - Oak Grove: 70019
  • Downtown Crossing - Orange Line - Oak Grove: 70021
  • State - Orange Line - Oak Grove: 70023
  • Haymarket - Orange Line - Oak Grove: 70025
  • North Station - Orange Line - Oak Grove: 70027
  • Community College - Orange Line - Oak Grove: 70029
  • Sullivan Square - Orange Line - Oak Grove: 70031
  • Wellington - Orange Line - Oak Grove: 70033
  • Malden Center - Orange Line - Oak Grove: 70035
  • Assembly - Orange Line - Oak Grove: 70279
  • Forest Hills - Orange Line - Track 1: Forest Hills-01
  • Oak Grove - Orange Line - Track 1: Oak Grove-01
  • Forest Hills - Orange Line - Track 2: Forest Hills-02
  • Oak Grove - Orange Line - Track 2: Oak Grove-02

Red Line Stops

  • Davis - Red Line - Alewife: 70064
  • Porter - Red Line - Alewife: 70066
  • Harvard - Red Line - Alewife: 70068
  • Central - Red Line - Alewife: 70070
  • Kendall/MIT - Red Line - Alewife: 70072
  • Charles/MGH - Red Line - Alewife: 70074
  • Park Street - Red Line - Alewife: 70076
  • Downtown Crossing - Red Line - Alewife: 70078
  • South Station - Red Line - Alewife: 70080
  • Broadway - Red Line - Alewife: 70082
  • Andrew - Red Line - Alewife: 70084
  • Savin Hill - Red Line - Alewife: 70088
  • Fields Corner - Red Line - Alewife: 70090
  • Shawmut - Red Line - Alewife: 70092
  • Ashmont - Red Line - Alewife: 70094
  • North Quincy - Red Line - Alewife: 70098
  • Wollaston - Red Line - Alewife: 70100
  • Quincy Center - Red Line - Alewife: 70102
  • Quincy Adams - Red Line - Alewife: 70104
  • JFK/UMass - Red Line - Alewife (from Ashmont): 70086
  • JFK/UMass - Red Line - Alewife (from Braintree): 70096
  • JFK/UMass - Red Line - Ashmont: 70085
  • Savin Hill - Red Line - Ashmont: 70087
  • Fields Corner - Red Line - Ashmont: 70089
  • Shawmut - Red Line - Ashmont: 70091
  • Davis - Red Line - Ashmont/Braintree: 70063
  • Porter - Red Line - Ashmont/Braintree: 70065
  • Harvard - Red Line - Ashmont/Braintree: 70067
  • Central - Red Line - Ashmont/Braintree: 70069
  • Kendall/MIT - Red Line - Ashmont/Braintree: 70071
  • Charles/MGH - Red Line - Ashmont/Braintree: 70073
  • Park Street - Red Line - Ashmont/Braintree: 70075
  • Downtown Crossing - Red Line - Ashmont/Braintree: 70077
  • South Station - Red Line - Ashmont/Braintree: 70079
  • Broadway - Red Line - Ashmont/Braintree: 70081
  • Andrew - Red Line - Ashmont/Braintree: 70083
  • JFK/UMass - Red Line - Braintree: 70095
  • North Quincy - Red Line - Braintree: 70097
  • Wollaston - Red Line - Braintree: 70099
  • Quincy Center - Red Line - Braintree: 70101
  • Quincy Adams - Red Line - Braintree: 70103
  • Ashmont - Red Line - Exit Only: 70093
  • Alewife - Red Line - Track 1: Alewife-01
  • Braintree - Red Line - Track 1: Braintree-01
  • Alewife - Red Line - Track 2: Alewife-02
  • Braintree - Red Line - Track 2: Braintree-02

Green Line Stops

  • South Street - Green Line - (B) Boston College: 70111
  • Chestnut Hill Avenue - Green Line - (B) Boston College: 70113
  • Chiswick Road - Green Line - (B) Boston College: 70115
  • Sutherland Road - Green Line - (B) Boston College: 70117
  • Washington Street - Green Line - (B) Boston College: 70121
  • Warren Street - Green Line - (B) Boston College: 70125
  • Allston Street - Green Line - (B) Boston College: 70127
  • Griggs Street - Green Line - (B) Boston College: 70129
  • Harvard Avenue - Green Line - (B) Boston College: 70131
  • Packards Corner - Green Line - (B) Boston College: 70135
  • Babcock Street - Green Line - (B) Boston College: 70137
  • Pleasant Street - Green Line - (B) Boston College: 70139
  • Saint Paul Street - Green Line - (B) Boston College: 70141
  • Boston University West - Green Line - (B) Boston College: 70143
  • Boston University Central - Green Line - (B) Boston College: 70145
  • Boston University East - Green Line - (B) Boston College: 70147
  • Blandford Street - Green Line - (B) Boston College: 70149
  • Park Street - Green Line - (B) Boston College: 70196
  • Kenmore - Green Line - (B) Boston College: 71151
  • Park Street - Green Line - (C) Cleveland Circle: 70197
  • Saint Marys Street - Green Line - (C) Cleveland Circle: 70211
  • Hawes Street - Green Line - (C) Cleveland Circle: 70213
  • Kent Street - Green Line - (C) Cleveland Circle: 70215
  • Saint Paul Street - Green Line - (C) Cleveland Circle: 70217
  • Coolidge Corner - Green Line - (C) Cleveland Circle: 70219
  • Summit Avenue - Green Line - (C) Cleveland Circle: 70223
  • Brandon Hall - Green Line - (C) Cleveland Circle: 70225
  • Fairbanks Street - Green Line - (C) Cleveland Circle: 70227
  • Washington Square - Green Line - (C) Cleveland Circle: 70229
  • Tappan Street - Green Line - (C) Cleveland Circle: 70231
  • Dean Road - Green Line - (C) Cleveland Circle: 70233
  • Englewood Avenue - Green Line - (C) Cleveland Circle: 70235
  • Kenmore - Green Line - (C) Cleveland Circle/(D) Riverside: 70151
  • Arlington - Green Line - Copley & West: 70157
  • Boylston - Green Line - Copley & West: 70159
  • Government Center - Green Line - Copley & West: 70202
  • Haymarket - Green Line - Copley & West: 70204
  • North Station - Green Line - Copley & West: 70206
  • Science Park/West End - Green Line - Copley & West: 70208
  • Lechmere - Green Line - Copley & West: 70210
  • Woodland - Green Line - (D) Riverside: 70163
  • Waban - Green Line - (D) Riverside: 70165
  • Eliot - Green Line - (D) Riverside: 70167
  • Newton Highlands - Green Line - (D) Riverside: 70169
  • Newton Centre - Green Line - (D) Riverside: 70171
  • Chestnut Hill - Green Line - (D) Riverside: 70173
  • Reservoir - Green Line - (D) Riverside: 70175
  • Beaconsfield - Green Line - (D) Riverside: 70177
  • Brookline Hills - Green Line - (D) Riverside: 70179
  • Brookline Village - Green Line - (D) Riverside: 70181
  • Longwood - Green Line - (D) Riverside: 70183
  • Fenway - Green Line - (D) Riverside: 70187
  • Park Street - Green Line - (D) Riverside: 70198
  • Park Street - Green Line - Drop-off Only: 71199
  • Park Street - Green Line - (E) Heath Street: 70199
  • Prudential - Green Line - (E) Heath Street: 70239
  • Symphony - Green Line - (E) Heath Street: 70241
  • Northeastern University - Green Line - (E) Heath Street: 70243
  • Museum of Fine Arts - Green Line - (E) Heath Street: 70245
  • Longwood Medical Area - Green Line - (E) Heath Street: 70247
  • Brigham Circle - Green Line - (E) Heath Street: 70249
  • Fenwood Road - Green Line - (E) Heath Street: 70251
  • Mission Park - Green Line - (E) Heath Street: 70253
  • Riverway - Green Line - (E) Heath Street: 70255
  • Back of the Hill - Green Line - (E) Heath Street: 70257
  • Boston College - Green Line - Exit Only: 70107
  • Riverside - Green Line - Exit Only: 70161
  • Lechmere - Green Line - Exit Only: 70209
  • Cleveland Circle - Green Line - Exit Only: 70237
  • Park Street - Green Line - Government Center & North: 70200
  • Hynes Convention Center - Green Line - Kenmore & West: 70153
  • Copley - Green Line - Kenmore & West/(E) Heath Street: 70155
  • North Station - Green Line - Lechmere: 70205
  • Science Park/West End - Green Line - Lechmere: 70207
  • Government Center - Green Line - Loop Platform: Government Center-Brattle
  • Government Center - Green Line - North Station & North: 70201
  • Haymarket - Green Line - North Station & North: 70203
  • Boston College - Green Line - Park Street & North: 70106
  • South Street - Green Line - Park Street & North: 70110
  • Chestnut Hill Avenue - Green Line - Park Street & North: 70112
  • Chiswick Road - Green Line - Park Street & North: 70114
  • Sutherland Road - Green Line - Park Street & North: 70116
  • Washington Street - Green Line - Park Street & North: 70120
  • Warren Street - Green Line - Park Street & North: 70124
  • Allston Street - Green Line - Park Street & North: 70126
  • Griggs Street - Green Line - Park Street & North: 70128
  • Harvard Avenue - Green Line - Park Street & North: 70130
  • Packards Corner - Green Line - Park Street & North: 70134
  • Babcock Street - Green Line - Park Street & North: 70136
  • Pleasant Street - Green Line - Park Street & North: 70138
  • Saint Paul Street - Green Line - Park Street & North: 70140
  • Boston University West - Green Line - Park Street & North: 70142
  • Boston University Central - Green Line - Park Street & North: 70144
  • Boston University East - Green Line - Park Street & North: 70146
  • Blandford Street - Green Line - Park Street & North: 70148
  • Kenmore - Green Line - Park Street & North: 70150
  • Hynes Convention Center - Green Line - Park Street & North: 70152
  • Copley - Green Line - Park Street & North: 70154
  • Arlington - Green Line - Park Street & North: 70156
  • Boylston - Green Line - Park Street & North: 70158
  • Riverside - Green Line - Park Street & North: 70160
  • Woodland - Green Line - Park Street & North: 70162
  • Waban - Green Line - Park Street & North: 70164
  • Eliot - Green Line - Park Street & North: 70166
  • Newton Highlands - Green Line - Park Street & North: 70168
  • Newton Centre - Green Line - Park Street & North: 70170
  • Chestnut Hill - Green Line - Park Street & North: 70172
  • Reservoir - Green Line - Park Street & North: 70174
  • Beaconsfield - Green Line - Park Street & North: 70176
  • Brookline Hills - Green Line - Park Street & North: 70178
  • Brookline Village - Green Line - Park Street & North: 70180
  • Longwood - Green Line - Park Street & North: 70182
  • Fenway - Green Line - Park Street & North: 70186
  • Saint Marys Street - Green Line - Park Street & North: 70212
  • Hawes Street - Green Line - Park Street & North: 70214
  • Kent Street - Green Line - Park Street & North: 70216
  • Saint Paul Street - Green Line - Park Street & North: 70218
  • Coolidge Corner - Green Line - Park Street & North: 70220
  • Summit Avenue - Green Line - Park Street & North: 70224
  • Brandon Hall - Green Line - Park Street & North: 70226
  • Fairbanks Street - Green Line - Park Street & North: 70228
  • Washington Square - Green Line - Park Street & North: 70230
  • Tappan Street - Green Line - Park Street & North: 70232
  • Dean Road - Green Line - Park Street & North: 70234
  • Englewood Avenue - Green Line - Park Street & North: 70236
  • Cleveland Circle - Green Line - Park Street & North: 70238
  • Prudential - Green Line - Park Street & North: 70240
  • Symphony - Green Line - Park Street & North: 70242
  • Northeastern University - Green Line - Park Street & North: 70244
  • Museum of Fine Arts - Green Line - Park Street & North: 70246
  • Longwood Medical Area - Green Line - Park Street & North: 70248
  • Brigham Circle - Green Line - Park Street & North: 70250
  • Fenwood Road - Green Line - Park Street & North: 70252
  • Mission Park - Green Line - Park Street & North: 70254
  • Riverway - Green Line - Park Street & North: 70256
  • Back of the Hill - Green Line - Park Street & North: 70258
  • Kenmore - Green Line - Park Street & North: 71150

Blue Line Stops

  • Government Center - Blue Line - Bowdoin: 70039
  • State - Blue Line - Bowdoin: 70041
  • Aquarium - Blue Line - Bowdoin: 70043
  • Maverick - Blue Line - Bowdoin: 70045
  • Airport - Blue Line - Bowdoin: 70047
  • Wood Island - Blue Line - Bowdoin: 70049
  • Orient Heights - Blue Line - Bowdoin: 70051
  • Suffolk Downs - Blue Line - Bowdoin: 70053
  • Beachmont - Blue Line - Bowdoin: 70055
  • Revere Beach - Blue Line - Bowdoin: 70057
  • Wonderland - Blue Line - Bowdoin: 70059
  • Wonderland - Blue Line - Exit Only: 70060
  • Bowdoin - Blue Line - Exit Only: 70838
  • Bowdoin - Blue Line - Wonderland: 70038
  • Government Center - Blue Line - Wonderland: 70040
  • State - Blue Line - Wonderland: 70042
  • Aquarium - Blue Line - Wonderland: 70044
  • Maverick - Blue Line - Wonderland: 70046
  • Airport - Blue Line - Wonderland: 70048
  • Wood Island - Blue Line - Wonderland: 70050
  • Orient Heights - Blue Line - Wonderland: 70052
  • Suffolk Downs - Blue Line - Wonderland: 70054
  • Beachmont - Blue Line - Wonderland: 70056
  • Revere Beach - Blue Line - Wonderland: 70058