Monorepo for Swedish public transport tools, built on Trafiklab APIs.
| API | What it does | Auth | Coverage | Update frequency |
|---|---|---|---|---|
| SL Transport | Departures, sites, lines, stop points | None | Stockholm | Real-time |
| SL Deviations | Disruptions, reroutes, maintenance | None | Stockholm | Real-time |
| Trafiklab Stops | Search stops by name, list all stops | TRAFIKLAB_API_KEY |
Sweden | Static |
| Trafiklab Timetables | Departures and arrivals with delays | TRAFIKLAB_API_KEY |
Sweden | Real-time |
| GTFS-RT Alerts | Service alerts (disruptions, reroutes) | TRAFIKLAB_GTFS_KEY |
Sweden | ~15 sec |
| GTFS-RT Trip Updates | Per-trip delays, cancellations, predictions | TRAFIKLAB_GTFS_KEY |
Sweden | ~15 sec |
| GTFS-RT Vehicle Positions | Live GPS, speed, bearing, occupancy | TRAFIKLAB_GTFS_KEY |
Sweden | ~3 sec |
| Combined Nearby | Vehicles near a location with mode classification | TRAFIKLAB_GTFS_KEY |
Stockholm | Real-time |
Stockholm (SL) APIs work without any keys. For other Swedish operators (Uppsala, Skane, etc.), use the GTFS-RT APIs.
| Package | Description | Docs |
|---|---|---|
@transit-se/sdk |
TypeScript SDK for Trafiklab realtime APIs | README |
@transit-se/mcp |
MCP server — exposes the SDK as AI-callable tools | README |
import { TransitClient } from '@transit-se/sdk';
const client = new TransitClient({ apiKey: process.env.TRAFIKLAB_API_KEY! });
const stops = await client.stops.searchByName('T-Centralen');
const deps = await client.timetables.getDepartures('740000001');
const slDeps = await client.sl.getDepartures(9192); // no key neededSee the SDK README for the full API reference.
Add to your MCP client config (no installation required):
{
"mcpServers": {
"transit-se": {
"command": "npx",
"args": ["-y", "@transit-se/mcp"],
"env": {
"TRAFIKLAB_API_KEY": "your-key-here",
"TRAFIKLAB_GTFS_KEY": "your-key-here"
}
}
}
}See the MCP README for detailed setup instructions for Claude Desktop, Claude Code, and Cursor.
The SL APIs (Transport, Deviations) work without any API key. The other APIs each require a Trafiklab key:
| Key | Trafiklab product | Unlocks |
|---|---|---|
TRAFIKLAB_API_KEY |
Trafiklab Realtime APIs | Stop Lookup, Timetables |
TRAFIKLAB_GTFS_KEY |
GTFS Sweden 3 Realtime | Service Alerts, Trip Updates, Vehicle Positions, Nearby Vehicles |
- Sign up at developer.trafiklab.se
- Create a project and enable the API products you need
- Copy your API keys from the project dashboard
cp .env.example .env
# Edit .env and paste your keysgit clone git@github.com:rebelliard/transit-se.git
cd transit-se
bun install| Command | Description |
|---|---|
bun run check |
Type-check + lint |
bun run test |
Run all tests |
bun run --filter @transit-se/mcp inspect |
Open the MCP Inspector web UI |
bun run --filter @transit-se/sdk inspect |
Open the SDK Swagger UI |
MIT — Data provided by Trafiklab.se under CC-BY 4.0.