-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs.html
More file actions
924 lines (835 loc) · 33.9 KB
/
Copy pathdocs.html
File metadata and controls
924 lines (835 loc) · 33.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documentation - Transport API</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" />
<link rel="stylesheet" href="media/css/layout.css" />
</head>
<body>
<div class="container">
<div class="col-sm-8 col-sm-offset-2">
<header>
<h1><a href="./">Transport</a></h1>
<p>Swiss public transport API</p>
</header>
<article>
<h2 id="documentation">API Documentation</h2>
<ul>
<li><a href="#rate-limiting">Rate limiting</a></li>
<li>
<a href="#api-resources">Resources</a>
<ul>
<li><a href="#locations">/locations</a></li>
<li><a href="#connections">/connections</a></li>
<li><a href="#stationboard">/stationboard</a></li>
</ul>
</li>
<li>
<a href="#api-objects">Objects</a>
<ul>
<li><a href="#location">location</a></li>
<li><a href="#coordinates">coordinates</a></li>
<li><a href="#connection">connection</a></li>
<li><a href="#prognosis">prognosis</a></li>
<li><a href="#stop">stop</a></li>
<li><a href="#section">section</a></li>
<li><a href="#journey">journey</a></li>
</ul>
</li>
<li>
<a href="#limit-response">Limit response</a>
</li>
</ul>
<h3 id="rate-limiting">Rate Limit</h3>
<p>The number of HTTP requests you can send is constraint by the <a href="https://timetable.search.ch/api/help">rate limit of timetable.search.ch</a>.</p>
<h3 id="api-resources">API Resources</h3>
<p>The Transport API builds on REST style resources which respond in JSON. Individual resources are detailed below. Cross Origin Resource Sharing (CORS) is enabled, so you can easily use the API on transport.opendata.ch from any website (avoid setting custom headers though).</p>
<hr/>
<h3 id="locations">/locations</h3>
<p>Returns the matching locations for the given parameters. Either <code>query</code> or ( <code>x</code> and <code>y</code> ) are required.</p>
<p>The locations in the response are scored to determine which is the most exact location.</p>
<p>This method can return a refine response, what means that the request has to be redone.</p>
<h4>Resource URL</h4>
<pre>http://transport.opendata.ch/v1/locations</pre>
<h4>Request Parameters</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Required</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>query</code></td>
<td>optional</td>
<td>Specifies the location name to search for</td>
<td>Basel</td>
</tr>
<tr>
<td><code>x</code></td>
<td>optional</td>
<td>Latitude</td>
<td>47.476001</td>
</tr>
<tr>
<td><code>y</code></td>
<td>optional</td>
<td>Longitude</td>
<td>8.306130</td>
</tr>
<tr>
<td><code>type</code></td>
<td>optional</td>
<td>
Only with <code>query</code> parameter.
Specifies the location type, possible types are:
<ul>
<li>all (default): Looks up for all types of locations</li>
<li>station: Looks up for stations (train station, bus station)</li>
<li>poi: Looks up for points of interest (Clock tower, China garden)</li>
<li>address: Looks up for an address (Zurich Bahnhofstrasse 33)</li>
</ul>
</td>
<td>address</td>
</tr>
</tbody>
</table>
<h4>Response parameters</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>stations</code></td>
<td>A list of <a href="#location">locations</a></td>
</tr>
</tbody>
</table>
<h4>Example Request</h4>
<pre>GET http://transport.opendata.ch/v1/locations?query=Basel</pre>
<h4>Example response</h4>
<pre>
{
"stations": [
{
"id": "000000022",
"name": "Basel",
"score": null,
"coordinate": {
"type": "WGS84",
"x": 47.547408,
"y": 7.589547
},
"distance": null
}
]
}
</pre>
<hr/>
<h3 id="connections">/connections</h3>
<p>Returns the next connections from a location to another.</p>
<h4>Resource URL</h4>
<pre>http://transport.opendata.ch/v1/connections</pre>
<h4>Request Parameters</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Required</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>from</code></td>
<td>required</td>
<td>Specifies the departure location of the connection</td>
<td>Lausanne</td>
</tr>
<tr>
<td><code>to</code></td>
<td>required</td>
<td>Specifies the arrival location of the connection</td>
<td>Genève</td>
</tr>
<tr>
<td><code>via</code></td>
<td>optional</td>
<td class="description">Specifies up to five via locations. When specifying several vias, array notation (<code>via[]=via1&via[]=via2</code>) is required.</td>
<td>Bern</td>
</tr>
<tr>
<td><code>date</code></td>
<td>optional</td>
<td>Date of the connection, in the format YYYY-MM-DD</td>
<td>2012-03-25</td>
</tr>
<tr>
<td><code>time</code></td>
<td>optional</td>
<td>Time of the connection, in the format hh:mm</td>
<td>17:30</td>
</tr>
<tr>
<td><code>isArrivalTime</code></td>
<td>optional</td>
<td>defaults to <code>0</code>, if set to <code>1</code> the passed <code>date</code> and <code>time</code> is the arrival time</td>
<td>1</td>
</tr>
<tr>
<td><code>transportations</code></td>
<td>optional</td>
<td class="description">Transportation means; one or more of <code>train</code>, <code>tram</code>, <code>ship</code>, <code>bus</code>, <code>cableway</code></td>
<td>transportations[]=tram&<br/>transportations[]=bus</td>
</tr>
<tr>
<td><code>limit</code></td>
<td>optional</td>
<td>1 - 16. Specifies the number of connections to return. If several connections depart at the same time they are counted as 1.</td>
<td>4</td>
</tr>
<tr>
<td><code>page</code></td>
<td>optional</td>
<td>0 - 3. Allows pagination of connections. Zero-based, so first page is 0, second is 1, third is 2 and so on.</td>
<td>3</td>
</tr>
</tbody>
</table>
<h4>Response parameters</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>connections</code></td>
<td>A list of <a href="#connection">connections</a></td>
</tr>
</tbody>
</table>
<h4>Example Requests</h4>
<pre>GET http://transport.opendata.ch/v1/connections?from=Lausanne&to=Genève</pre>
<p>which is the same as</p>
<pre>GET http://transport.opendata.ch/v1/connections?from=008501120&to=008501008</pre>
<h4>Example response</h4>
<pre>
{
"connections" : [
{
"from" : {
"arrival" : null,
"arrivalTimestamp" : null,
"departure" : "2012-03-31T08:58:00+02:00",
"departureTimestamp" : 1333177080,
"platform" : "7",
"prognosis" : {
"platform" : null,
"arrival" : null
"departure" : null
"capacity1st" : "-1",
"capacity2nd" : "-1",
},
"station" : {
"coordinate" : {
"type" : "WGS84",
"x" : "6629086",
"y" : "46516785"
},
"id" : "008501120",
"name" : "Lausanne",
"score" : null
}
},
"to" : {
"arrival" : "2012-03-31T09:46:00+02:00",
"arrivalTimestamp" : 1333179960,
"departure" : null,
"departureTimestamp" : null,
"platform" : "2",
"prognosis" : {
"platform" : null,
"arrival" : null,
"departure" : null
"capacity1st" : null,
"capacity2nd" : null,
},
"station" : {
"coordinate" : {
"type" : "WGS84",
"x" : "6142437",
"y" : "46210217"
},
"id" : "008501008",
"name" : "Genève",
"score" : null
}
}
},
],
// ...
}
</pre>
<hr/>
<h3 id="stationboard">/stationboard</h3>
<p>Returns the next connections leaving from a specific location.</p>
<h4>Resource URL</h4>
<pre>http://transport.opendata.ch/v1/stationboard</pre>
<h4>Request Parameters</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Required</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>station</code></td>
<td>required</td>
<td>Specifies the location of which a stationboard should be returned</td>
<td>Aarau</td>
</tr>
<tr>
<td><code>id</code></td>
<td>optional</td>
<td>The id of the station whose stationboard should be returned.
<br />Alternative to the station parameter; one of these two is required.
<br />If both an id and a station are specified the id has precedence.
</td>
<td>8503059 <em>(for Zurich Stadelhofen)</em></td>
</tr>
<tr>
<td><code>limit</code></td>
<td>optional</td>
<td>Number of departing connections to return.
<br />This is not a hard limit - if multiple connections leave at the same time it'll return any connections that leave at the same time as the last connection within the limit.<br />
For example: limit=4 will return connections leaving at :
<ul><li>19:30</li><li>19:32</li><li>19:32</li><li>19:35</li><li>19:35</li></ul>
Because one of the connections leaving at 19:35 is within the limit, all connections leaving at 19:35 are shown.
</td>
<td>15</td>
</tr>
<tr>
<td><code>transportations</code></td>
<td>optional</td>
<td class="description">Transportation means; one or more of <code>train</code>, <code>tram</code>, <code>ship</code>, <code>bus</code>, <code>cableway</code></td>
<td>?transportations[]=tram&transportations[]=bus</td>
</tr>
<tr>
<td><code>datetime</code></td>
<td>optional</td>
<td>Date and time of departing connections, in the format <code>YYYY-MM-DD hh:mm</code>.</td>
<td>2012-03-25 17:30</td>
</tr>
<tr>
<td><code>type</code></td>
<td>optional</td>
<td class="description"><code>departure</code> (default) or <code>arrival</code></td>
<td>arrival</td>
</tr>
</tbody>
</table>
<h4>Response parameters</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>station</code></td>
<td>The first matched <a href="#location">location</a> based on the query. The stationboard will be displayed if this is a station.</td>
</tr>
<tr>
<td><code>stationboard</code></td>
<td>A list of <a href="#journey">journeys</a> with the <a href="#stop">stop</a> of the line leaving from that station.</td>
</tr>
</tbody>
</table>
<h4>Example Requests</h4>
<pre>GET http://transport.opendata.ch/v1/stationboard?station=Aarau&limit=10</pre>
<p>which is the same as</p>
<pre>GET http://transport.opendata.ch/v1/stationboard?id=008502113&limit=10</pre>
<h4>Example response</h4>
<pre>
{
"stationboard" : [
{
"stop":
{
"station":
{
"id": "8502996",
"name": "Aarau, Bahnhof",
"score": null,
"coordinate":
{
"type" : "WGS84",
"x": "8050864",
"y": "47392020"
}
},
"arrival": null,
"arrivalTimestamp": null,
"departure": "2012-03-31T14:39:00+02:00",
"departureTimestamp": 1333197540,
"platform": "",
"prognosis":
{
"platform": null,
"arrival": null,
"departure": null,
"capacity1st": "-1",
"capacity2nd": "-1"
}
},
"name": "BUS13543",
"category": "BUS",
"number": "13543",
"operator": null,
"to": "Frick, Bahnhof"
},{
"stop":
{
"station":
{
"id": "8502996",
"name": "Aarau, Bahnhof",
"score": null,
"coordinate":
{
"type": "WGS84",
"x": "8050864",
"y": "47392020"
}
},
"arrival": null,
"arrivalTimestamp": null,
"departure": "2012-03-31T14:39:00+02:00",
"departureTimestamp": 1333197540,
"platform": "",
"prognosis":
{
"platform": null,
"arrival": null,
"departure": null,
"capacity1st": "-1",
"capacity2nd": "-1"
}
},
"name": "Bus 2",
"category": "Bus",
"number": "2",
"operator": "BBA",
"to": "Aarau Rohr, Unterdorf"
},
// ...
]
}
</pre>
<hr/>
<h3 id="api-objects">API Objects</h3>
<p>API responses are composites of the following objects:</p>
<h4 id="location">Location Object</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>id</code></td>
<td>The id of the location</td>
</tr>
<tr>
<td><code>type</code></td>
<td>
Type of the location, can contain:
<ul>
<li>station: Location is a train station, bus station</li>
<li>poi: Location is a point of interest (Clock tower, China garden)</li>
<li>address: Location is an address</li>
<li>refine: Location is not defined, the user has to relocate</li>
</ul>
</td>
</tr>
<tr>
<td><code>name</code></td>
<td>The location name</td>
</tr>
<tr>
<td><code>score</code></td>
<td>The accuracy of the result</td>
</tr>
<tr>
<td><code>coordinates</code></td>
<td>The location <a href="#coordinates">coordinates</a></td>
</tr>
<tr>
<td><code>distance</code></td>
<td>If search has been with coordinates, distance to original point in meters</td>
</tr>
</tbody>
</table>
<h4 id="coordinates">Coordinates Object</h4>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>type</code></td>
<td>The type of the given coordinate</td>
</tr>
<tr>
<td><code>x</code></td>
<td>Latitude</td>
</tr>
<tr>
<td><code>y</code></td>
<td>Longitude</td>
</tr>
</tbody>
</table>
<h4 id="connection">Connection Object</h4>
<p>A connection represents a possible journey between two locations.</p>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>from</code></td>
<td colspan="2">The departure <a href="#stop"> checkpoint</a> of the connection</td>
</tr>
<tr>
<td><code>to</code></td>
<td colspan="2">The arrival <a href="#stop"> checkpoint</a> of the connection</td>
</tr>
<tr>
<td><code>duration</code></td>
<td>Duration of the journey</td>
<td>00d00:43:00</td>
</tr>
<tr>
<td><code>service</code></td>
<td colspan="2"><a href="#service">Service</a> information about how regular the connection operates</td>
</tr>
<tr>
<td><code>products</code></td>
<td>Array with transport products</td>
<td>IR, S9</td>
</tr>
<tr>
<td><code>capacity1st</code></td>
<td>The maximum estimated occupation load of 1st class coaches</td>
<td>1</td>
</tr>
<tr>
<td><code>capacity2nd</code></td>
<td>The maximum estimated occupation load of 2nd class coaches</td>
<td>2</td>
</tr>
<tr>
<td><code>sections</code></td>
<td colspan="2">A list of <a href="#section">sections</a></td>
</tr>
</tbody>
</table>
<h4 id="service">Service Object</h4>
<p>Operation information for a connection.</p>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>regular</code></td>
<td>Information about how regular a connection operates.</td>
<td>daily</td>
</tr>
<tr>
<td><code>irregular</code></td>
<td>Additional information about irregular operation dates.</td>
<td>not 23., 24. Jun 2012</td>
</tr>
</tbody>
</table>
<h4 id="prognosis">Prognosis Object</h4>
<p>A prognosis contains "realtime" informations on the status of a connection checkpoint.</p>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>platform</code></td>
<td>The estimated arrival/departure platform</td>
<td>8</td>
</tr>
<tr>
<td><code>departure</code></td>
<td>The departure time prognosis to the checkpoint<br>Date format: <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a></td>
<td>2012-03-31T08:58:00+02:00</td>
</tr>
<tr>
<td><code>arrival</code></td>
<td>The arrival time prognosis to the checkpoint<br>Date format: <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a></td>
<td>2012-03-31T09:35:00+02:00</td>
</tr>
<tr>
<td><code>capacity1st</code></td>
<td>The estimated occupation load of 1st class coaches</td>
<td>1</td>
</tr>
<tr>
<td><code>capacity2nd</code></td>
<td>The estimated occupation load of 2nd class coaches</td>
<td>2</td>
</tr>
</tbody>
</table>
<h4 id="stop">Stop Object</h4>
<p>A checkpoint represents an arrival or a departure point (in time and space) of a connection.</p>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>station</code></td>
<td colspan="2">A <a href="#location">location</a> object showing this line's stop at the requested station.</td>
</tr>
<tr>
<td><code>arrival</code></td>
<td>The arrival time to the checkpoint</td>
<td>14:58:00</td>
</tr>
<tr>
<td><code>departure</code></td>
<td>The departure time from the checkpoint</td>
<td>null</td>
</tr>
<tr>
<td><code>delay</code></td>
<td>The delay at this checkpoint, can be null if no <a href="#prognosis">prognosis</a> is available.</td>
<td>2</td>
</tr>
<tr>
<td><code>platform</code></td>
<td>The arrival/departure platform </td>
<td>8</td>
</tr>
<tr>
<td><code>prognosis</code></td>
<td colspan="2">The checkpoint <a href="#prognosis">prognosis</a></td>
</tr>
</tbody>
</table>
<h4 id="section">Section Object</h4>
<p>A connection consists of one or multiple sections.</p>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>journey</code></td>
<td colspan="2">A <a href="#journey">journey</a>, the transportation used by this section. Can be null</td>
</tr>
<tr>
<td><code>walk</code></td>
<td>Information about walking distance, if available</td>
<td>null</td>
</tr>
<tr>
<td><code>departure</code></td>
<td colspan="2">The departure <a href="#stop"> checkpoint</a> of the connection</td>
</tr>
<tr>
<td><code>arrival</code></td>
<td colspan="2">The arrival <a href="#stop"> checkpoint</a> of the connection</td>
</tr>
</tbody>
</table>
<h4 id="journey">Journey Object</h4>
<p>The actual transportation of a section, e.g. a bus or a train between two stations.</p>
<table class="table table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>name</code></td>
<td>The name of the transportation</td>
<td>019351</td>
</tr>
<tr>
<td><code>category</code></td>
<td>Category of the transportation</td>
<td>S</td>
</tr>
<tr>
<td><code>categoryCode</code></td>
<td>An internal category code of the transportation</td>
<td>1</td>
</tr>
<tr>
<td><code>number</code></td>
<td>The number of the transportation line</td>
<td>13</td>
</tr>
<tr>
<td><code>operator</code></td>
<td>The company performing the transportation</td>
<td>8</td>
</tr>
<tr>
<td><code>to</code></td>
<td>Final destination of the train</td>
<td>Zürich HB</td>
</tr>
<tr>
<td><code>passList</code></td>
<td colspan="2"><a href="#stop">Checkpoints</a> the train passed on the journey</td>
</tr>
<tr>
<td><code>capacity1st</code></td>
<td>The maximum estimated occupation load of 1st class coaches</td>
<td>1</td>
</tr>
<tr>
<td><code>capacity2nd</code></td>
<td>The maximum estimated occupation load of 2nd class coaches</td>
<td>2</td>
</tr>
</tbody>
</table>
<h3 id="limit-response">Limit response</h3>
<p>You can limit the response data with the <code>fields</code> parameter.
If any <code>fields[]</code> is passed, only the specified fields are in the response.
The API is aware of the hierarchy, if you set a field, everything below is in the response unless a more specific (further down in the hierarchy) field is set.
</p>
<h4>Example Request</h4>
<pre>GET http://transport.opendata.ch/v1/connections?from=Lausanne&to=Genève&fields[]=connections/from/departure&fields[]=connections/to/arrival</pre>
<h4>Example response</h4>
<pre>
{
"connections":[
{
"from":{
"departure":"2012-05-01T19:42:00+0200",
},
"to":{
"arrival":"2012-05-01T20:15:00+0200",
}
},
],
//....
}
</pre>
<h4>Example Request</h4>
<pre>GET http://transport.opendata.ch/v1/connections?from=Lausanne&to=Genève&fields[]=connections/from&fields[]=connections/to/station</pre>
<h4>Example response</h4>
<pre>
{
"connections":[
{
"from":{
"station":{
"id":"008501120",
"name":"Lausanne",
"score":null,
"coordinate":{
"type":"WGS84",
"x":6.629086,
"y":46.516785
}
},
"arrival":null,
"arrivalTimestamp":null,
"departure":"2012-05-01T19:42:00+0200",
"departureTimestamp":1335894120,
"platform":"5",
"prognosis":{
"platform":null,
"arrival":null,
"departure":null,
"capacity1st":"1",
"capacity2nd":"1"
}
},
"to":{
"station":{
"id":"008501008",
"name":"Gen\u00e8ve",
"score":null,
"coordinate":{
"type":"WGS84",
"x":6.142437,
"y":46.210217
}
}
}
},
],
// ...
}
</pre>
</article>
<footer class="footer">
<hr>
<p>Powered by <a href="http://opendata.ch/">Opendata.ch.</a> <a href="https://donate.raisenow.io/bxqvn" target="_blank">Donate now to support open data in Switzerland</a>.</p>
<p>Thanks to <a href="https://nine.ch" target="_blank">nine</a> for donating the server.</p>
</footer>
</div>
</div>
</body>
</html>