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