@@ -358,6 +358,43 @@ def get_departures(station_id):
358
358
return departures
359
359
360
360
361
+ def get_lines (station_id ):
362
+ """Get the lines being served for `station_id`.
363
+
364
+ Change in 1.3.2: accepts both 'old-style' integer IDs which were used
365
+ by the API before this version and the new string IDs which
366
+ look like `de:09162:6`.
367
+
368
+ To get the `station_id` associated with a station name,
369
+ use :func:`get_id_for_station`.
370
+
371
+ Returns a list like::
372
+
373
+ [
374
+ {
375
+ "destination" : "Aying",
376
+ "sev" : false,
377
+ "partialNet" : "ddb",
378
+ "product" : "SBAHN",
379
+ "lineNumber" : "S7",
380
+ "divaId" : "92M07"
381
+ },
382
+ ]
383
+
384
+ Note: The api seemingly only returns a single object per
385
+ line served, meaning that both directions of a line are
386
+ represented only by a single line in the response.
387
+ """
388
+ if isinstance (station_id , int ):
389
+ station_id = _convert_id (station_id )
390
+ elif not _station_sanity_check (station_id ):
391
+ raise TypeError ("Please give the int station_id of the station.\
392
+ You can find it out by running \
393
+ get_id_for_station('Station name')" )
394
+ url = departure_url .format (id = station_id )
395
+ return _perform_api_request (url )['servingLines' ]
396
+
397
+
361
398
def get_interruptions ():
362
399
url = interruptions_url
363
400
interruptions = _perform_api_request (url )
@@ -389,5 +426,8 @@ def __init__(self, station):
389
426
def get_departures (self ):
390
427
return get_departures (self .id )
391
428
429
+ def get_lines (self ):
430
+ return get_lines (self .id )
431
+
392
432
def __repr__ (self ):
393
433
return "Station(id=%s, name='%s')" % (self .id , self .name )
0 commit comments