A real-time NYC transit app that connects to the MTA API to provide accurate subway information, including routes, stations, arrival times, and service status.
- Real-time Arrivals: Live arrival times from MTA GTFS real-time feeds
- Interactive Map: View all subway stations with their actual routes
- Route Information: Accurate route data with colors and names
- Service Status: Real-time service status for all subway lines
- Trip Planning: Plan trips between stations
- Station Details: View which routes serve each station
- Python 3.8+
- Node.js 16+
- MTA API Key (get one from MTA Developer Portal)
cd backend
# Install Python dependencies
pip install -r requirements.txt
# Set up environment variables
cp .env.example .env
# Edit .env and add your MTA_API_KEY
# Set up database and import MTA data
python setup_database.py
# Start the backend server
python run.pyThe backend will be available at http://localhost:5001
cd mobile
# Install dependencies
npm install
# Start the development server
npm startThe app uses SQLite for the database. The setup script will:
- Create all necessary tables
- Download GTFS data from MTA APIs
- Import routes, stops, and stop-route relationships
- Set up real-time data connections
GET /api/v1/routes- Get all subway routesGET /api/v1/stops- Get all subway stops with route informationGET /api/v1/stops/{stop_id}/routes- Get routes for a specific stop
GET /api/v1/realtime/{stop_id}- Get real-time arrivals for a stopGET /api/v1/service-status- Get service status for all routesGET /api/v1/realtime/health- Check health of real-time feeds
GET /api/v1/map/stations- Get all stations for map displayPOST /api/v1/plan-trip- Plan a trip between two stops
The app uses real data from:
- MTA GTFS Static Data: Routes, stops, and schedules
- MTA GTFS Real-time Feeds: Live arrival times and service updates
- MTA API: Service status and alerts
app/models/transit.py- Database models for routes, stops, tripsapp/routes/transit_routes.py- API endpointsapp/services/realtime_service.py- Real-time data processingimport_gtfs_data.py- Data import from MTA APIs
src/screens/- Main app screenssrc/services/api.ts- API clientsrc/components/- Reusable components
- routes: Subway routes with colors and names
- stops: Subway stations with coordinates
- stop_routes: Many-to-many relationship between stops and routes
- trips: Individual train trips
The app connects to MTA's GTFS real-time feeds:
- 123456: 1, 2, 3, 4, 5, 6 trains
- ace: A, C, E trains
- bdfm: B, D, F, M trains
- g: G train
- jz: J, Z trains
- nqrw: N, Q, R, W trains
- l: L train
- si: Staten Island Railway
- 7: 7 train
- Check that the backend is running
- Verify MTA API key is set correctly
- Check database has been populated with data
- Look at backend logs for API errors
- Check MTA real-time feed health
- Verify API key has real-time access
- Check network connectivity to MTA APIs
- Delete the database file and re-run setup
- Check MTA API key permissions
- Verify GTFS data is being downloaded correctly
- Update database models if needed
- Add API endpoints in
transit_routes.py - Update frontend API service
- Add UI components
# Backend tests
cd backend
python -m pytest
# Frontend tests
cd mobile
npm testThis project is for educational purposes. Please respect MTA's API terms of service.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues related to:
- MTA API access: Contact MTA Developer Support
- App functionality: Check the troubleshooting section above
- Setup issues: Verify all prerequisites are installed