Transport for Sweden API

Transportation / OAuth Advanced HTTPS
60 per window (58 remaining at test time)
95 A+
Measured Score 0 50 100 Speed 28/30 Consistency 17/20 Security 20/20 Browser access 15/15 Transparency 15/15 TESTED 2026-08-10

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.

Measurement Record

What actually happened when we called this API from our own infrastructure. Every value below was recorded by the request, not copied from the provider's documentation.

Request
GET https://developer.trafiklab.se/api/trafiklab-se/incidents
Result
HTTP 200 · application/json · 714 bytes · compressed
Response time
36 ms (median of 3) · fastest 33 ms
Transport
TLSv1.3 · TLS_AES_256_GCM_SHA384 · certificate issued by Let's Encrypt
Browser CORS
Allowed — Access-Control-Allow-Origin: *
Rate limit
60 per window (58 remaining at test time)
Served by
cloudflare
Recorded
2026-08-10

Fields Returned

Top-level fields present in the response we captured, with the type and value we actually received.

Field Type Value received
title string Siri-ET SL and Siri-VM Skånetrafiken are down
report_type string automatic
starts_at string (date) 2026-08-10T12:11:47.589Z
starts_at_formatted string Mon Aug 10 12:11
ends_at null null
href string (url) https://status.trafiklab.se/incident/1007346
affected_resources array [1 item]
status_updates array [1 item]

Captured Response

Captured from a real request to https://developer.trafiklab.se/api/trafiklab-se/incidents on 2026-08-10. Long arrays and nested objects are truncated to keep the shape readable.

JSON Response · Captured
[
  {
    "title": "Siri-ET SL and Siri-VM Skånetrafiken are down",
    "report_type": "automatic",
    "starts_at": "2026-08-10T12:11:47.589Z",
    "starts_at_formatted": "Mon Aug 10 12:11",
    "ends_at": null,
    "href": "https://status.trafiklab.se/incident/1007346",
    "affected_resources": [
      {
        "…": "(4 more fields)"
      }
    ],
    "status_updates": [
      {
        "…": "(2 more fields)"
      }
    ]
  }
]

Implementation Example

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
const url = "https://api.resrobot.se/v2.1/departureBoard?id=740000001&format=json&accessId=YOUR_API_KEY";
// 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.

How This API Fails

We deliberately sent this API a broken request and recorded exactly what came back on 2026-08-10. Knowing the shape of an error before you hit it makes error handling much easier to write.

HTTP 404 Requesting a path that does not exist application/json
{
  "message": "The route api/trafiklab-se/incidents/apisscore-nonexistent-path could not be found."
}

Common Errors & Troubleshooting

Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.

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.

Measured Score Breakdown

Live HTTP request to the API endpoint

Speed 28/30
Consistency 17/20
Security 20/20
Browser access 15/15
Transparency 15/15
Endpoint Response Time 36ms

Fully tested on Aug 10, 2026

Technical Specifications

Auth OAuth
HTTPS REQUIRED
CORS UNKNOWN
Category Transportation
Difficulty Advanced
Endpoint last called: 2026-08-10

Similar APIs

View All →