search.ch
  1. Queries
  2. Completion
  3. Route Queries
  4. One to many
  5. Stationboard queries
  6. Terms of Use

API Specification

Queries

Requests are sent to the API as HTTPS-URIs, according to the concept of REST. The server responds with JSON.

Rate Limit

The number of daily requests is limited to 1000. If you reach the maximum number of requests please contact us, we are eager to hear your use case and discuss a solution.

Attention

This API might change at some point in the future! You can register yourself here to get informed about changes:

E-mail*
Use case
 
Fields with a * are mandatory.

Completion

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

Parameter Required Description Example Default
term required what the user entered lu
nofavorites optional don't use smart favorites from timetable.search.ch 1 0
show_ids optional Return station ids 1 0
show_coordinates optional Return coordinates of stations 1 0
Example response
[
   {
      "label" : "Luzern",
      "html" : "<span class=\"sl-keyword\">Lu</span>zern",
      "iconclass" : "sl-icon-type-zug"
   },
   [..]
]

Coordinate Reverse Lookup

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

Parameter Required Description Example Default
latlon required Coordinates 46.948004,7.448134
accuracy optional Accuracy in meter 10 0
show_ids optional Return station ids 1 0
show_coordinates optional Return coordinates of stations 1 0
Example response
[
	{
		"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"
	},
	[..]
]

Route Queries

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

Parameter Required Description Example Default
from required Departure station, id or address Einsiedeln
to required Arrival station, id or address Zürich, Förrlibuckstr. 60
via optional Via stations, for more than one via use array notation like via[]=via1&via[]=via2 Wädenswil
date optional Date 09/21/2018 today
time optional Time 05:03 now
time_type optional Specifies whether date/time is meant for departure or arrival arrival depart
num optional How many connections should be returned 8 4
pre optional How many additional connections should be returned before the given time 4 0
show_delays optional Return delays - ATTENTION: beta feature 1 0
show_trackchanges optional Show track changes (indicated by eclamation mark) - ATTENTION: beta feature 1 0
one_to_many optional Find routes to multiple targets or multiple starts simultaneously. See example below. 1 0
interest_duration optional Find routes during that time duration (in minutes) from the given arrival or departure time. 1440 5760
transportation_types optional Allowed transportation types, comma-separated (train,tram,bus,ship,cableway) tram,bus
Example response
{
   "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://timetable.search.ch/api/route.fr.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 Required Description Example Default
Same parameters than route queries. Please note: for multiple targets only time_type=depart is possible, for multiple starts only time_type=arrival.
Example response
{
	"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
}

Stationboard queries

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

Parameter Required Description Example Default
stop required Departure/arrival station or id Einsiedeln
date optional Date 09/21/2018 today
time optional Time 05:03 now
mode optional Specifies whether departure table or arrival table is meant arrival depart
limit optional Number of connections to return. API returns more if there are still connections in the last minute. 0 for unlimited (24 hours coverage) 15 0
show_tracks optional Return tracks 1 0
show_subsequent_stops optional Return subsequent stops 1 0
show_delays optional Return delays - ATTENTION: beta feature 1 0
show_trackchanges optional Show track changes (indicated by eclamation mark) - ATTENTION: beta feature 1 0
Example response
{
	"stop": {
		"id": "8503283",
		"name": "Einsiedeln",
		"x": "699075",
		"y": "220557"
	},
	"connections": [
		{
			"time": 1491216300,
			"*G": "S",
			"*L": "40",
			"type": "str",
			"line": "S40",
			"operator": "SOB-sob",
			"color": "039~fff~",
			"number": "S40 16947",
			"terminal": {
				"id": "8503110",
				"name": "Rapperswil",
				"x": 704369,
				"y": 231356
			}
		},
		{
			"time": 1491217080,
			"*G": "S",
			"*L": "13",
			"type": "str",
			"line": "S13",
			"operator": "SOB-sob",
			"color": "039~fff~",
			"number": "S13 19347",
			"terminal": {
				"id": "8503206",
				"name": "Wädenswil",
				"x": 693643,
				"y": 231668
			}
		},
		[..]
	],
	"request": "stationboard",
	"eof": 1
}