Transport for Switzerland API

Transportation / API Key Intermediate HTTPS
Varies by plan (check documentation)

Overview

Transport for Switzerland (opentransportdata.swiss) is the official Swiss open data platform for public transport, offering timetables, real-time data, and GTFS feeds. It covers trains, buses, trams, and boats operated by Swiss transit companies. An API key is required and can be obtained by registering for a free account on the platform.

💡

Beginner Tip

Start by registering at opentransportdata.swiss to get your API key — the GTFS static feed is easiest to begin with for timetable data. Use the Journey Planning API for real-time trip routing.

Available Data

match scores and results
team standings
player statistics
schedule and fixtures

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

OJPResponse Root element of the Open Journey Planning response.
TripResult List of trip options matching the requested journey.
Trip.Duration Total travel duration in ISO 8601 duration format.
LegTrack Individual segments of the journey with transport modes.
ServiceJourney.OperatingDayRef Reference to the operating day for the service.

Implementation Example

const url = "https://opentransportdata.swiss/en/";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "X-API-Key": "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 API key is missing or invalid in the Authorization header.
Include your API key as a Bearer token in the header: Authorization: Bearer YOUR_API_KEY.
400 Bad Request Required parameters such as departure or arrival stop IDs are missing.
Check the API documentation for required parameters and ensure all mandatory fields are included.
Empty journey results The stop names may not match the Swiss transport naming convention.
Use the location search endpoint to find the exact stop name or ID before planning a journey.

Matrix Score Breakdown

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

Partially tested on Apr 5, 2026

Technical Specifications

Auth API Key
HTTPS REQUIRED
CORS UNKNOWN
Category Transportation
Difficulty Intermediate
Verified: 2026-04-04

Similar APIs

View All →