Transport for Sweden API

Transportation / OAuth Advanced HTTPS
Varies by plan (check documentation)

Overview

Transport for Sweden (Trafiklab) is a developer platform providing access to public transport data across all of Sweden. It offers real-time departures, trip planning, and historical data from operators like SL (Stockholm) and Skanetrafiken. OAuth authentication is required, so you will need to register for a free developer account at trafiklab.se.

💡

Beginner Tip

Register at trafiklab.se to get your API keys — most datasets offer a generous free tier for development. Start with the ResRobot API for nationwide trip planning as it covers all Swedish public transport.

Available Data

match scores and results
team standings
player statistics
schedule and fixtures
Use case: Integrate public transport consumer data into web and mobile applications

Example Response

JSON Response
{
  "route": "Line 1",
  "origin": "Station A",
  "destination": "Station B",
  "departure": "08:30",
  "arrival": "09:15",
  "status": "On Time",
  "delays_min": 0
}

Field Reference

Departure List of upcoming departures from the requested stop.
Departure[].name Name of the transport line or service.
Departure[].time Scheduled departure time in HH:MM:SS format.
Departure[].date Scheduled departure date in YYYY-MM-DD format.
Departure[].stop Name of the departure stop.
Departure[].transportNumber The line number or service identifier.

Implementation Example

// ⚠️ Note: This URL may be a documentation page. Check official docs for actual API endpoint.
const url = "https://www.trafiklab.se/api";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "Authorization": "Bearer YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

401 Unauthorized Missing or invalid OAuth token or API key in the request.
Register at https://www.trafiklab.se and obtain a valid API key, then include it as a query parameter.
429 Too Many Requests You have exceeded the rate limit for your subscription tier.
Check your subscription quota on the Trafiklab dashboard and consider upgrading or caching responses.
No departures found The station ID or stop name may be incorrect or spelled differently.
Use the location lookup endpoint first to resolve the correct stop ID before querying departures.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 5/20
🔒 Security 15/15
🛠 Developer XP 3/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth OAuth
HTTPS REQUIRED
CORS UNKNOWN
Category Transportation
Difficulty Advanced
Verified: 2026-04-04

Similar APIs

View All →