search.ch

API Spezifikation

Anfragen

API-Anfragen werden mittels REST als HTTPS-URIs gesendet. Der Server antwortet mit JSON.

Anfragebegrenzung

Die Anzahl täglicher Anfragen ist limitiert auf 1000 Routensuchen und 10080 Abfahrtstabellen. Bitte kontaktieren Sie uns bei Erreichung dieses Limits. Wir sind interessiert Ihre Anwendung kennenzulernen und eine Lösung zu diskutieren.

Achtung

Beachten Sie, dass das API jederzeit ändern kann! Sie können sich hier registrieren, wenn Sie über Änderungen informiert werden möchten:

E-Mail*
Anwendungsfall
 
Felder mit * müssen ausgefüllt sein.

Vervollständigung

GET https://search.ch/fahrplan/api/completion.json?term=lu

Parameter Zwingend Beschreibung Beispiel Default
term zwingend Benutzereingabe lu
nofavorites optional Keine Smartfavorites von fahrplan.search.ch 1 0
show_ids optional Zeige ids der Stationen 1 0
show_coordinates optional Zeige Koordinaten der Stationen (x=E, y=N) 1 0
Beispielantwort
[
   {
      "label" : "Luzern",
      "html" : "<span class=\"sl-keyword\">Lu</span>zern",
      "iconclass" : "sl-icon-type-zug"
   },
   [..]
]

Koordinaten zu Stationen

GET https://search.ch/fahrplan/api/completion.json?latlon=46.948004,7.448134&accuracy=10

Parameter Zwingend Beschreibung Beispiel Default
latlon zwingend Koordinaten 46.948004,7.448134
accuracy optional Genauigkeit in Meter 10 0
show_ids optional Zeige ids der Stationen 1 0
show_coordinates optional Zeige Koordinaten der Stationen (x=E, y=N) 1 0
Beispielantwort
[
	{
		"label": "Zytgloggelaube, Bern",
		"dist": 15,
		"iconclass": "sl-icon-type-adr"
	},
	{
		"label": "Bern, Zytglogge",
		"dist": 51,
		"iconclass": "sl-icon-type-tram"
	},
	{
		"label": "Bern, Bundesplatz",
		"dist": 337,
		"iconclass": "sl-icon-type-bus"
	},
	[..]
]

Routensuchen

GET https://search.ch/fahrplan/api/route.json?from=Einsiedeln&to=Z%C3%BCrich,+F%C3%B6rrlibuckstr.+60

Parameter Zwingend Beschreibung Beispiel Default
from zwingend Abfahrtsstation, ID oder Addresse Einsiedeln
to zwingend Ankunftsstation, ID oder Addresse Zürich, Förrlibuckstr. 60
via optional Viastationen; Array Notation für mehr als eine Station verwenden: via[]=via1&via[]=via2 Wädenswil
date optional Datum 28.03.2024 today
time optional Zeit 13:52 now
time_type optional Spezifiziert ob date/time als Abfahrt oder Ankunft gemeint ist arrival depart
num optional Wieviele Verbindungen zurückgegeben werden sollen 8 4
pre optional Wieviele zusätzliche Verbindungen vor der gegebenen Zeit zurückgegeben werden sollen 4 0
show_delays optional Zeige Verspätungen 1 0
show_trackchanges optional Zeige Gleiswechsel (markiert durch Ausrufezeichen) 1 0
one_to_many optional Suche Routen zu mehreren Zielen oder von mehreren Starts gleichzeitig. Siehe Beispiel weiter unten. 1 0
interest_duration optional Suche Routen in diesem Zeitraum (in Minuten) ab der angegebenen Abfahrts- oder Ankunftszeit. 1440 5760
transportation_types optional Erlaubte Transportmittel, komma-separiert (train,tram,bus,ship,cableway) tram,bus
summary optional Zusammenfassung 1 0
Beispielantwort
{
   "count": 4,
   "min_duration": 4140,
   "max_duration": 4920,
   "connections" : [
      {
         "from" : "Einsiedeln",
         "arrival" : "2016-10-27 20:12:00",
         "disruptions" : [],
         "legs" : [
            {
               "type" : "str",
               "track" : "4",
               "terminal" : "Wädenswil",
               "fgcolor" : "fff",
               "number" : "S13 19371",
               "bgcolor" : "039",
               "tripid" : "T2016_19371_000082_101_df5a79b_0",
               "exit" : {
                  "arrival" : "2016-10-27 19:25:00",
                  "sbb_name" : "Wädenswil",
                  "name" : "Wädenswil",
                  "stopid" : "8503206",
                  "waittime" : 240
               },
               "runningtime" : 1620,
               "stopid" : "8503283",
               "line" : "S13",
               "stops" : [
                  {
                     "stopid" : "8503284",
                     "name" : "Biberbrugg",
                     "departure" : "27.10.2016 19:07"
                  },
                  {
                     "name" : "Schindellegi-Feusisberg",
                     "departure" : "27.10.2016 19:11",
                     "stopid" : "8503285"
                  },
                  {
                     "name" : "Samstagern",
                     "departure" : "27.10.2016 19:17",
                     "stopid" : "8503286"
                  },
                  {
                     "stopid" : "8503293",
                     "departure" : "27.10.2016 19:18",
                     "name" : "Grüenfeld"
                  },
                  {
                     "stopid" : "8503287",
                     "name" : "Burghalden",
                     "departure" : "27.10.2016 19:21"
                  }
               ],
               "sbb_name" : "Einsiedeln",
               "name" : "Einsiedeln",
               "departure" : "2016-10-27 18:58:00"
            },
            {
               "arrival" : "2016-10-27 19:25:00",
               "departure" : "2016-10-27 19:29:00",
               "name" : "Wädenswil",
               "stops" : [
                  {
                     "departure" : "27.10.2016 19:39",
                     "name" : "Thalwil",
                     "stopid" : "8503202"
                  },
                  {
                     "stopid" : "0000176",
                     "departure" : null,
                     "name" : "Zimmerberg-Basistunnel"
                  }
               ],
               "type" : "express_train",
               "normal_time" : 180,
               "sbb_name" : "Wädenswil",
               "runningtime" : 1140,
               "exit" : {
                  "arrival" : "2016-10-27 19:48:00",
                  "name" : "Zürich HB",
                  "sbb_name" : "Zürich HB",
                  "waittime" : 0,
                  "stopid" : "8503000"
               },
               "line" : "RE",
               "stopid" : "8503206",
               "waittime" : 240,
               "tripid" : "T2016_05082_000011_101_c92bac7_0",
               "bgcolor" : "f00",
               "number" : "RE 5082",
               "terminal" : "Zürich HB",
               "track" : "2",
               "fgcolor" : "fff"
            },
            {
               "arrival" : "2016-10-27 19:48:00",
               "normal_time" : 420,
               "sbb_name" : "Zürich HB",
               "name" : "Zürich HB",
               "departure" : "2016-10-27 19:48:00",
               "exit" : {
                  "sbb_name" : "Zürich, Sihlquai/HB",
                  "name" : "Zürich, Sihlquai/HB",
                  "arrival" : "2016-10-27 19:55:00",
                  "waittime" : 360,
                  "stopid" : "8591368"
               },
               "runningtime" : 420,
               "stopid" : "8503000",
               "waittime" : 0,
               "stops" : null
            },
            {
               "name" : "Zürich, Sihlquai/HB",
               "departure" : "2016-10-27 20:01:00",
               "arrival" : "2016-10-27 19:55:00",
               "stops" : [
                  {
                     "stopid" : "8591282",
                     "departure" : "27.10.2016 20:02",
                     "name" : "Zürich, Museum für Gestaltung"
                  },
                  {
                     "stopid" : "8591257",
                     "departure" : "27.10.2016 20:03",
                     "name" : "Zürich, Limmatplatz"
                  },
                  {
                     "stopid" : "8591306",
                     "name" : "Zürich, Quellenstr.",
                     "departure" : "27.10.2016 20:04"
                  },
                  {
                     "departure" : "27.10.2016 20:05",
                     "name" : "Zürich, Dammweg",
                     "stopid" : "8591110"
                  },
                  {
                     "stopid" : "8580522",
                     "name" : "Zürich, Escher-Wyss-Platz",
                     "departure" : "27.10.2016 20:06"
                  }
               ],
               "type" : "tram",
               "sbb_name" : "Zürich, Sihlquai/HB",
               "stopid" : "8591368",
               "waittime" : 360,
               "line" : "17",
               "exit" : {
                  "stopid" : "8591135",
                  "arrival" : "2016-10-27 20:08:00",
                  "name" : "Zürich, Förrlibuckstr.",
                  "sbb_name" : "Zürich, Förrlibuckstrasse"
               },
               "runningtime" : 420,
               "number" : "T 34826",
               "bgcolor" : "9d1b6e",
               "tripid" : "T2016_34826_003849_001_494a519_0",
               "fgcolor" : "fff",
               "terminal" : "Zürich, Werdhölzli"
            },
            {
               "arrival" : "2016-10-27 20:08:00",
               "name" : "Zürich, Förrlibuckstr.",
               "normal_time" : 0,
               "sbb_name" : "Zürich, Förrlibuckstrasse",
               "departure" : "2016-10-27 20:08:00",
               "exit" : {
                  "stopid" : "681270,249530",
                  "isaddress" : true,
                  "sbb_name" : null,
                  "name" : "Zürich, Förrlibuckstr. 60",
                  "arrival" : "2016-10-27 20:12:00"
               },
               "runningtime" : 240,
               "stopid" : "8591135",
               "stops" : null,
               "type" : "walk"
            },
            {
               "isaddress" : true,
               "stopid" : "681270,249530",
               "arrival" : "2016-10-27 20:12:00",
               "sbb_name" : null,
               "name" : "Zürich, Förrlibuckstr. 60"
            }
         ],
         "duration" : 4440,
         "to" : "Zürich, Förrlibuckstr. 60",
         "departure" : "2016-10-27 18:58:00"
      }
   ]
}

One to many

GET https://search.ch/fahrplan/api/route.json?from=Bern&to%5B0%5D=Basel+SBB&to%5B1%5D=Lausanne&to%5B2%5D=Luzern&to%5B3%5D=Winterthur&one_to_many=1

Parameter Zwingend Beschreibung Beispiel Default
Gleiche Parameter wie Routensuche. Beachten Sie: bei mehreren Zielen ist nur time_type=depart möglich, bei mehreren Starts nur time_type=arrival.
Beispielantwort
{
	"results": [
		{
			"count": 4,
			"min_duration": 3180,
			"max_duration": 3300,
			"connections": [ ... ],
			"url": "https://fahrplan.search.ch/Bern..Basel-SBB",
			"points": [
				{
					"text": "Bern",
					"url": "https://map.search.ch/Bern",
					"id": "8507000",
					"x": "600037",
					"y": "199749"
				},
				{
					"text": "Basel SBB",
					"url": "https://map.search.ch/Basel-SBB",
					"id": "8500010",
					"x": "611362",
					"y": "266309"
				}
			],
			"description": "Von Bern nach Basel SBB am Dienstag 31.10.2017"
		},
		{
			"count": 4,
			"min_duration": 3960,
			"max_duration": 3960,
			"connections": [ ... ],
			"url": "https://fahrplan.search.ch/Bern..Lausanne",
			"points": [
				{
					"text": "Bern",
					"url": "https://map.search.ch/Bern",
					"id": "8507000",
					"x": "600037",
					"y": "199749"
				},
				{
					"text": "Lausanne",
					"url": "https://map.search.ch/Lausanne",
					"id": "8501120",
					"x": "537875",
					"y": "152041"
				}
			],
			"description": "Von Bern nach Lausanne am Dienstag 31.10.2017"
		},
		{
			"count": 4,
			"min_duration": 3600,
			"max_duration": 3600,
			"connections": [ ... ],
			"url": "https://fahrplan.search.ch/Bern..Luzern",
			"points": [
				{
					"text": "Bern",
					"url": "https://map.search.ch/Bern",
					"id": "8507000",
					"x": "600037",
					"y": "199749"
				},
				{
					"text": "Luzern",
					"url": "https://map.search.ch/Luzern",
					"id": "8505000",
					"x": "666223",
					"y": "211383"
				}
			],
			"description": "Von Bern nach Luzern am Dienstag 31.10.2017"
		},
		{
			"count": 4,
			"min_duration": 5100,
			"max_duration": 5460,
			"connections": [ ... ],
			"url": "https://fahrplan.search.ch/Bern..Winterthur",
			"points": [
				{
					"text": "Bern",
					"url": "https://map.search.ch/Bern",
					"id": "8507000",
					"x": "600037",
					"y": "199749"
				},
				{
					"text": "Winterthur",
					"url": "https://map.search.ch/Winterthur",
					"id": "8506000",
					"x": "696830",
					"y": "261857"
				}
			],
			"description": "Von Bern nach Winterthur am Dienstag 31.10.2017"
		}
	],
	"request": "route",
	"eof": 1
}

Station

GET https://search.ch/fahrplan/api/station.json?stop=Einsiedeln

Parameter Zwingend Beschreibung Beispiel Default
stop zwingend Station oder ID Einsiedeln
Beispielantwort
{
	"id": "8503283",
	"name": "Einsiedeln",
	"type": "strain",
	"x": "699076",
	"y": "220557",
	"lon": 8.744481,
	"lat": 47.128578,
	"request": "station",
	"eof": 1
}

Abfahrts-/Ankunftstabellen

GET https://search.ch/fahrplan/api/stationboard.json?stop=Einsiedeln

Parameter Zwingend Beschreibung Beispiel Default
stop zwingend Station oder ID Einsiedeln
date optional Datum 28.03.2024 today
time optional Zeit 13:52 now
mode optional Spezifiziert ob Abfahrts- oder Ankunftstabelle gemeint ist arrival depart
limit optional Anzahl Verbinungen, welche zurückgegeben werden. Das API gibt mehr zurück, falls in der letzten Minute mehrere Verbindungen sind. 0 für unlimitiert (24h Abdeckung) 15 0
show_tracks optional Zeige Geleise 1 0
show_subsequent_stops optional Zeige nachfolgende Stationen 1 0
show_delays optional Zeige Verspätungen 1 0
show_trackchanges optional Zeige Gleiswechsel (markiert durch Ausrufezeichen) 1 0
transportation_types optional Erlaubte Transportmittel, komma-separiert (train,tram,bus,ship,cableway) tram,bus
Beispielantwort
{
	"stop": {
		"id": "8503283",
		"name": "Einsiedeln",
		"x": "699075",
		"y": "220557",
		"lon": 8.744468,
		"lat": 47.128579
	},
	"connections": [
		{
			"time": "2021-02-08 13:46:00",
			"*G": "S",
			"*L": "40",
			"*Z": "016951",
			"type": "strain",
			"line": "S40",
			"operator": "SOB-sob",
			"color": "039~fff~",
			"type_name": "S-Bahn",
			"terminal": {
				"id": "8503110",
				"name": "Rapperswil SG",
				"x": 704370,
				"y": 231356,
				"lon": 8.816743,
				"lat": 47.224885
			}
		},
		{
			"time": "2021-02-08 13:59:00",
			"*G": "S",
			"*L": "13",
			"*Z": "019351",
			"type": "strain",
			"line": "S13",
			"operator": "SOB-sob",
			"color": "039~fff~",
			"type_name": "S-Bahn",
			"terminal": {
				"id": "8503206",
				"name": "Wädenswil",
				"x": 693645,
				"y": 231669,
				"lon": 8.675218,
				"lat": 47.229306
			}
		},
		[..]
	],
	"request": "stationboard",
	"eof": 1
}