Unofficial CLI for TriMet Portland transit data
npm install 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.
``bash`
npm install -g trimet-cli
Or run directly with npx:
`bash`
npx trimet-cli --help
Get a free API key from the TriMet Developer Portal, then set it:
`bash`
export TRIMET_APP_ID="your-api-key"
Add this to your shell profile (~/.zshrc, ~/.bashrc, etc.) to persist it.
Get real-time arrivals at a stop:
`bash`
trimet arrivals 8383 # Arrivals at stop 8383
trimet arrivals 8383 --line 90 # Only MAX Red Line
trimet arrivals 8383 --json # Output as JSON
Plan a trip between two locations:
`bash`
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 JSON
You can also use addresses:
`bash`
trimet trip -f "Pioneer Square, Portland" -t "PDX Airport"
Simplified view of next departures:
`bash`
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 Line
Get current service alerts:
`bash`
trimet alerts # All alerts
trimet alerts --route 90 # Alerts for route 90
trimet alerts --json # Output as JSON
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) |
| Variable | Description |
|----------|-------------|
| TRIMET_APP_ID | Required. Your TriMet API key |NO_COLOR
| | Disable colored output (any value) |
| Code | Meaning |
|------|---------|
| 0 | Success |1
| | Generic failure |2
| | Invalid usage (bad arguments) |3
| | Authentication failure (missing API key) |
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
`bash
$ trimet arrivals 8383
Upcoming Arrivals:
90 Beaverton TC 3 min
190 Blue to Hillsboro 8 min
90 Beaverton TC 18 min ⚠️ DELAYED
`
`bash
$ 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 TC
`
`bash
$ 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 Line
`
`bash
$ 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.
`
`bash`
trimet arrivals 8383 --json | jq '.[] | select(.minutes < 10)'
This package also exports a TypeScript client for programmatic use:
`typescript
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();
`
`bash``
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 8383
MIT © Matt Russell
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.