Skip to content

Add bus routes to metadata, findstops utility - #44

Merged
nolanbconaway merged 11 commits into
nolanbconaway:mainfrom
WardBrian:bus-metadata
Dec 22, 2025
Merged

Add bus routes to metadata, findstops utility#44
nolanbconaway merged 11 commits into
nolanbconaway:mainfrom
WardBrian:bus-metadata

Conversation

@WardBrian

Copy link
Copy Markdown
Collaborator

Closes #28, I think?

Note: despite what the MTA documentation says, the GTFS realtime data does not seem to require an API key. This might be intentional, and the docs are out of date, or it might be naughty.

Example:

> underground findstops pitkin av --buses
ID: 301334   Direction: (BUS)    Lat/Lon: 40.668304,-73.919571    Name: PITKIN AV/HOWARD AV
ID: 301429   Direction: (BUS)    Lat/Lon: 40.675584,-73.869956    Name: CRESCENT ST/PITKIN AV
ID: 301503   Direction: (BUS)    Lat/Lon: 40.675032,-73.871889    Name: EUCLID AV/PITKIN AV
ID: 301521   Direction: (BUS)    Lat/Lon: 40.668716,-73.916831    Name: PITKIN AV/SARATOGA AV
ID: 301522   Direction: (BUS)    Lat/Lon: 40.668984,-73.915036    Name: PITKIN AV/HERZL ST
ID: 301589   Direction: (BUS)    Lat/Lon: 40.67023,-73.907496    Name: PITKIN AV/MOTHER GASTON BLVD
ID: 301590   Direction: (BUS)    Lat/Lon: 40.669965,-73.909288    Name: PITKIN AV/OSBORN ST
ID: 301591   Direction: (BUS)    Lat/Lon: 40.669678,-73.911206    Name: PITKIN AV/ROCKAWAY AV
ID: 301593   Direction: (BUS)    Lat/Lon: 40.669124,-73.91492    Name: PITKIN AV/AMBOY ST
ID: 301594   Direction: (BUS)    Lat/Lon: 40.66885,-73.916762    Name: PITKIN AV/STRAUSS ST
ID: 301595   Direction: (BUS)    Lat/Lon: 40.668646,-73.918151    Name: PITKIN AV/LEGION ST
ID: 301967   Direction: (BUS)    Lat/Lon: 40.672234,-73.895908    Name: PENNSYLVANIA AV/PITKIN AV
ID: 302030   Direction: (BUS)    Lat/Lon: 40.671576,-73.895908    Name: PENNSYLVANIA AV/PITKIN AV
ID: 305065   Direction: (BUS)    Lat/Lon: 40.669115,-73.910666    Name: ROCKAWAY AV/PITKIN AV
ID: 306707   Direction: (BUS)    Lat/Lon: 40.669683,-73.910341    Name: PITKIN AV/ROCKAWAY AV
ID: 306708   Direction: (BUS)    Lat/Lon: 40.669956,-73.908477    Name: PITKIN AV/OSBORN ST
ID: 306709   Direction: (BUS)    Lat/Lon: 40.669911,-73.907025    Name: MOTHER GASTON BLVD/PITKIN AV
ID: 306728   Direction: (BUS)    Lat/Lon: 40.670002,-73.910745    Name: ROCKAWAY AV/PITKIN AV
ID: 307122   Direction: (BUS)    Lat/Lon: 40.669262,-73.913114    Name: PITKIN AV/THOMAS S BOYLAND ST
ID: 307370   Direction: (BUS)    Lat/Lon: 40.669408,-73.912998    Name: PITKIN AV/BRISTOL ST
ID: 350000   Direction: (BUS)    Lat/Lon: 40.675497,-73.871784    Name: PITKIN AV /EUCLID AV
ID: 350175   Direction: (BUS)    Lat/Lon: 40.676439,-73.865362    Name: PITKIN AV/GRANT AV
ID: 350176   Direction: (BUS)    Lat/Lon: 40.675993,-73.868463    Name: PITKIN AV /AUTUMN AV
ID: 350180   Direction: (BUS)    Lat/Lon: 40.676448,-73.865538    Name: GRANT AV /PITKIN AV
ID: 350231   Direction: (BUS)    Lat/Lon: 40.675357,-73.872065    Name: PITKIN AV /EUCLID AV
ID: 350232   Direction: (BUS)    Lat/Lon: 40.675944,-73.868059    Name: PITKIN AV /AUTUMN AV
ID: 350233   Direction: (BUS)    Lat/Lon: 40.676414,-73.864666    Name: PITKIN AV /ELDERT LN
ID: 350238   Direction: (BUS)    Lat/Lon: 40.674778,-73.87596    Name: PITKIN AV/LOGAN ST
ID: 550143   Direction: (BUS)    Lat/Lon: 40.675415,-73.852697    Name: PITKIN AV/84 ST
ID: 550145   Direction: (BUS)    Lat/Lon: 40.676743,-73.85812    Name: PITKIN AV/79 ST
ID: 550146   Direction: (BUS)    Lat/Lon: 40.676753,-73.86101    Name: PITKIN AV/76 ST
ID: 550247   Direction: (BUS)    Lat/Lon: 40.676708,-73.859582    Name: PITKIN AV/77 ST
ID: 550250   Direction: (BUS)    Lat/Lon: 40.675495,-73.853635    Name: PITKIN AV/83 ST
ID: 550426   Direction: (BUS)    Lat/Lon: 40.672357,-73.843019    Name: CROSS BAY BLVD/PITKIN AV
ID: 550427   Direction: (BUS)    Lat/Lon: 40.672344,-73.843378    Name: CROSS BAY BLVD/PITKIN AV
ID: 553360   Direction: (BUS)    Lat/Lon: 40.672086,-73.843357    Name: CROSS BAY BLVD/PITKIN AV
ID: 553361   Direction: (BUS)    Lat/Lon: 40.672061,-73.842954    Name: CROSS BAY BLVD/PITKIN AV
ID: 982155   Direction: (BUS)    Lat/Lon: 40.675513,-73.871665    Name: PITKIN AV /EUCLID AV
>>> from underground import SubwayFeed
>>> feed = SubwayFeed.get("B14")
>>> feed.extract_stop_dict()['B14']['301521']
[datetime.datetime(2025, 12, 6, 14, 56, 43, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), datetime.datetime(2025, 12, 6, 14, 34, 56, tzinfo=zoneinfo.ZoneInfo(key='America/New_York'))]

Comment thread src/underground/cli/findstops.py Outdated
@nolanbconaway

Copy link
Copy Markdown
Owner

this is a very interesting find @WardBrian ! I don't see any reason why we oughtnt move forward with adding this support. Worst case scenario is that the mta starts enforcing api keys; at which point those requests just break probably.

I guess what's left to do is documentation and testing?

Comment thread src/underground/cli/findstops.py Outdated
@WardBrian

Copy link
Copy Markdown
Collaborator Author

I guess what's left to do is documentation and testing?

Yes! I've added a bit to the readme.

In terms of testing, I've been using this branch on a personal project to monitor some local bus stops on a small LED board, and it's been working as expected for a couple days now: WardBrian/mta-board#3. So nothing rigorous, but it does seem to work perfectly for that use

@nolanbconaway

Copy link
Copy Markdown
Owner

I guess what's left to do is documentation and testing?

Yes! I've added a bit to the readme.

In terms of testing, I've been using this branch on a personal project to monitor some local bus stops on a small LED board, and it's been working as expected for a couple days now: WardBrian/mta-board#3. So nothing rigorous, but it does seem to work perfectly for that use

Ok great! There is some testing infra already in the repo that I think this feature could use. Mind if i add some commits to this pr to get that part rolling?

@WardBrian

Copy link
Copy Markdown
Collaborator Author

Sure!

@nolanbconaway

Copy link
Copy Markdown
Owner

Sure!

Ok great. I'll try to get to it in the next couple weeks and will tag you when ready for eyes. Thanks again for bringing this up!

@nolanbconaway

Copy link
Copy Markdown
Owner

I added the testing and got CI running on github actions! This is your PR @WardBrian so i'll wait for the 👍 from you before merging.

@WardBrian

Copy link
Copy Markdown
Collaborator Author

All looks good to me!

@nolanbconaway
nolanbconaway merged commit fc8688f into nolanbconaway:main Dec 22, 2025
5 checks passed
@WardBrian
WardBrian deleted the bus-metadata branch December 22, 2025 17:05
@WardBrian

Copy link
Copy Markdown
Collaborator Author

image

Interesting timing... I wonder if the technical issue is allowing unauth'd access

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for MTA bus data

2 participants