🚌 Polaris Transit API

Real-time transit data for multiple agencies with enhanced route information

Overview

The Polaris Transit API provides comprehensive transit data for multiple agencies, including real-time updates, scheduled departures, and enhanced route information.

🚀 Real-time Data

GTFS-RT integration for live vehicle positions and trip updates

🎨 Smart Filtering

Automatically filters out past departures, showing only upcoming services

📍 Location Search

Find nearby stops and transit options based on your location

🎨 Enhanced Routes

Detailed route information including colors, names, and destinations

API Endpoints

GET /transit-options

Find nearby stops with routes and next departures in a single comprehensive call. Perfect for mobile applications.

https://polaris-transit-api.jb-ff9.workers.dev/transit-options
lat Required Latitude coordinate
lon Required Longitude coordinate
radius_m Optional Search radius in meters (default: 500)
agency_id Optional Specific agency ID (e.g., "ttc")
curl "https://polaris-transit-api.jb-ff9.workers.dev/transit-options?lat=43.65&lon=-79.38&radius_m=500&agency_id=ttc"

GET /departures

Get scheduled departures for a stop. Automatically filters out past departures.

https://polaris-transit-api.jb-ff9.workers.dev/departures
stop_id Required Stop identifier
agency_id Optional Agency ID
curl "https://polaris-transit-api.jb-ff9.workers.dev/departures?stop_id=2479&agency_id=ttc"

GET /rt

Get real-time departures for a stop. Automatically filters out past departures.

https://polaris-transit-api.jb-ff9.workers.dev/rt
stop_id Required Stop identifier
agency_id Optional Agency ID
curl "https://polaris-transit-api.jb-ff9.workers.dev/rt?stop_id=2479&agency_id=ttc"

GET /nearby

Find stops within a radius of a location.

https://polaris-transit-api.jb-ff9.workers.dev/nearby
lat Required Latitude coordinate
lon Required Longitude coordinate
limit Optional Maximum number of stops (default: 10)
agency_id Optional Agency ID
curl "https://polaris-transit-api.jb-ff9.workers.dev/nearby?lat=43.65&lon=-79.38&limit=5&agency_id=ttc"

Transit Options Endpoint

The /transit-options endpoint is designed specifically for mobile applications, providing everything needed in a single API call:

Perfect for Mobile Apps: This endpoint combines the functionality of /nearby, /departures, and /rt into a single, comprehensive API call.

Enhanced Route Information

The API now provides comprehensive route information including colors, names, and destinations for better visual representation and user experience.

Route Information Fields

  • route_id - Route identifier as a number (e.g., 501)
  • route_short_name - Route number/name (e.g., "501")
  • route_long_name - Descriptive route name from static data (e.g., "QUEEN")
  • route_color - Hex color code for route branding (e.g., "FF0000")
  • destination - Extracted from headsign (e.g., "NEVILLE PARK")
  • next_departure - Next departure time for this route
  • delay_seconds - Real-time delay in seconds (if available)
  • is_realtime - Boolean indicating if data is real-time or scheduled

Example Route Data

{ "route_id": 501, "route_short_name": "501", "route_long_name": "QUEEN", "route_color": "FF0000", "destination": "NEVILLE PARK", "next_departure": "8:47:50", "delay_seconds": 0, "is_realtime": false }

Enhanced Departures

Each departure in the next_departures array also includes full route information:

{ "trip_id": "48926716", "route": "19", "headsign": "NORTH - 19 BAY towards DUPONT", "time": "9:06:15", "route_info": { "route_id": 19, "route_short_name": "19", "route_long_name": "BAY", "route_color": "FF0000", "destination": "DUPONT" } }

Departure Filtering

All departure endpoints automatically filter out past departures and show only upcoming services for a cleaner, more relevant user experience.

How it works:
  • Converts current time to the agency's local timezone
  • Handles GTFS times that extend beyond 24 hours (e.g., "26:04:12" for 2 AM next day)
  • For real-time data, uses predicted times when available
  • Provides graceful fallback if filtering fails

Example

If it's currently 2:30 PM and a stop has departures at 1:00 PM, 2:00 PM, 3:00 PM, and 2:04 AM tomorrow, only the 3:00 PM and 2:04 AM departures will be returned.

// Before filtering { "departures": [ {"time": "13:00:00", "route": "325"}, // Past {"time": "14:00:00", "route": "325"}, // Past {"time": "15:00:00", "route": "325"}, // Future {"time": "26:04:12", "route": "325"} // Next day ] } // After filtering (current time: 14:30:00) { "departures": [ {"time": "15:00:00", "route": "325"}, // Future {"time": "26:04:12", "route": "325"} // Next day ] }

Quick Start Examples

Find Transit Options Near You

curl "https://polaris-transit-api.jb-ff9.workers.dev/transit-options?lat=43.65&lon=-79.38&radius_m=500&agency_id=ttc"

Get Departures for a Stop

curl "https://polaris-transit-api.jb-ff9.workers.dev/departures?stop_id=2479&agency_id=ttc"

Get Real-time Updates

curl "https://polaris-transit-api.jb-ff9.workers.dev/rt?stop_id=2479&agency_id=ttc"

Find Nearby Stops

curl "https://polaris-transit-api.jb-ff9.workers.dev/nearby?lat=43.65&lon=-79.38&limit=5&agency_id=ttc"