trimet-cli
v0.1.0
Published
Unofficial CLI for TriMet Portland transit data
Maintainers
Readme
trimet-cli
⚠️ Unofficial CLI for TriMet
Not affiliated with or endorsed by TriMet.
A command-line interface for TriMet Portland transit data. Check arrivals, plan trips, and view service alerts.
Installation
npm install -g trimet-cliOr run directly with npx:
npx trimet-cli --helpSetup
Get a free API key from the TriMet Developer Portal, then set it:
export TRIMET_APP_ID="your-api-key"Add this to your shell profile (~/.zshrc, ~/.bashrc, etc.) to persist it.
Commands
Arrivals
Get real-time arrivals at a stop:
trimet arrivals 8383 # Arrivals at stop 8383
trimet arrivals 8383 --line 90 # Only MAX Red Line
trimet arrivals 8383 --json # Output as JSONTrip Planning
Plan a trip between two locations:
trimet trip -f 8383 -t 9969 # Basic trip
trimet trip -f 8383 -t 9969 --arrive-by "5:30 PM" # Arrive by time
trimet trip -f 8383 -t 9969 --depart-at "2:00 PM" # Depart at time
trimet trip -f 8383 -t 9969 --json # Output as JSONYou can also use addresses:
trimet trip -f "Pioneer Square, Portland" -t "PDX Airport"Next Departures
Simplified view of next departures:
trimet next -f 8383 -t 9969 # Next 3 options
trimet next -f 8383 -t 9969 -c 5 # Next 5 options
trimet next -f 8383 -t 9969 --line 90 # Only MAX Red LineService Alerts
Get current service alerts:
trimet alerts # All alerts
trimet alerts --route 90 # Alerts for route 90
trimet alerts --json # Output as JSONOptions
Global flags available on all commands:
| Flag | Description |
|------|-------------|
| -h, --help | Show help |
| -V, --version | Show version number |
| --no-color | Disable colored output |
| --json | Output as JSON (where applicable) |
Environment Variables
| Variable | Description |
|----------|-------------|
| TRIMET_APP_ID | Required. Your TriMet API key |
| NO_COLOR | Disable colored output (any value) |
Exit Codes
| Code | Meaning |
|------|---------|
| 0 | Success |
| 1 | Generic failure |
| 2 | Invalid usage (bad arguments) |
| 3 | Authentication failure (missing API key) |
Finding Stop IDs
Stop IDs are displayed at TriMet stops, or you can find them:
- On the TriMet website
- In the TriMet app
- On stop signs and shelters
Common Portland stops:
- Pioneer Courthouse Square: 8383 (westbound), 8384 (eastbound)
- PDX Airport: 10579
- Portland Union Station: 7787
Examples
Check arrivals at a stop
$ trimet arrivals 8383
Upcoming Arrivals:
90 Beaverton TC 3 min
190 Blue to Hillsboro 8 min
90 Beaverton TC 18 min ⚠️ DELAYEDPlan a trip
$ trimet trip -f 8383 -t 9969
Found 3 trip option(s):
Option 1: 5:15 PM → 5:45 PM (30 min)
🚶 Walk from Pioneer Square to MAX Station
5:18 PM - Blue Line to Beaverton TC
Option 2: 5:25 PM → 5:55 PM (30 min)
5:25 PM - Red Line to Beaverton TC
Option 3: 5:35 PM → 6:05 PM (30 min)
5:35 PM - Blue Line to Beaverton TCQuick view of next departures
$ trimet next -f 8383 -t 9969 -c 3
Next Departures:
5:15 PM → 5:45 PM (30 min) - Blue Line
5:25 PM → 5:55 PM (30 min) - Red Line
5:35 PM → 6:05 PM (30 min) - Blue LineCheck service alerts
$ trimet alerts --route 90
2 Active Alert(s):
[12345] MAX Red Line Delay
Routes: 90
Expect 10-15 minute delays due to signal issues near Gateway.
[12346] Weekend Service Changes
Routes: 90, 190
Reduced frequency on weekends through January.Script: Get arrivals as JSON
trimet arrivals 8383 --json | jq '.[] | select(.minutes < 10)'API Client
This package also exports a TypeScript client for programmatic use:
import { TriMetAPI } from 'trimet-cli';
const api = new TriMetAPI(process.env.TRIMET_APP_ID);
const arrivals = await api.getArrivals('8383');
const trip = await api.planTrip('8383', '9969');
const alerts = await api.getAlerts();Development
git clone https://github.com/mjrussell/trimet-cli
cd trimet-cli
npm install
npm run build
TRIMET_APP_ID="your-key" node dist/cli.js arrivals 8383License
MIT © Matt Russell
Disclaimer
This is an unofficial tool created by the community. TriMet is a trademark of the Tri-County Metropolitan Transportation District of Oregon. This project is not affiliated with, endorsed by, or connected to TriMet in any way.
