Package: dvb
An unofficial python module giving you a few options to query a
collection of publicly accessible API methods for Dresden’s public
transport system.Want something like this for another language, lookno further🙂The documentation is locatedhere.Get dvbpy from PyPi :)pipinstalldvbAnd then just import it.importdvbMonitor a single stopMonitor a single stop to see every bus or tram leaving this stop after
the specified time offset.importdvbstop='Helmholtzstraße'time_offset=0# how many minutes in the future, 0 for nownum_results=2city='Dresden'dvb.monitor(stop,time_offset,num_results,city)[{'line':'85','direction':'Striesen','arrival':5},{'line':'85','direction':'Löbtau Süd','arrival':7}]You can also callmonitor()without city, num_results or
time_offset. City will default to Dresden.Find routesQuery the server for possible routes from one stop to another. Returns
multiple possible trips, the bus-/tramlines to be taken, the single
stops, their arrival and departure times and their GPS coordinates.importdvbimporttimeorigin='Zellescher Weg'city_origin='Dresden'destination='Postplatz'city_destination='Dresden'time=int(time.time())# a unix timestamp is wanted heredeparr='dep'# set to 'arr' for arrival time, 'dep' for departure timedvb.route(origin,destination,city_origin,city_destination,time,deparr){'trips':[{'interchange':0,'nodes':[{'line':'11','mode':'Straßenbahn','direction':'Dresden Bühlau Ullersdorfer Platz','path':[[13.745754,51.02816],[13.745848,51.028393],...],'departure':{'time':'18:01','stop':'Zellescher Weg','coords':'13745754,51028160'},'arrival':{'time':'18:14','stop':'Postplatz','coords':'13733717,51050544'}}],'duration':'00:13','departure':'18:01','arrival':'18:14'},...}],'origin':'Dresden, Zellescher Weg','destination':'Dresden, Postplatz'}Everything besides origin and destination is optional and only needs to
be included if necessary. City for origin and destination defaults to
Dresden, time to now and is handled as the departure time.The path property contains a list consisting of all the coordinates
describing the path of this node. Useful for example if you want to draw
it on a map.If you use recommendations for interchanges, each of the nodes (except
the last one)in every trip will have arecommendationfield. The
field will tell where you should enter this route to get an optimal
interchange experience. This is of course only if there are any
interchanges. The positions are0for front,1for middle and2for back. If there are no recommendations availableNoneis
returned.Find stops by nameSearch for a single stop in the network of the DVB.importdvbdvb.find('zellesch')[{'name':'Zellescher Weg','city':'Dresden','coords':[51.028366,13.745847]}]The fieldscityandcoordsare optional as they are not
available for every stop. So don’t forget to check for their existence
first.[stopforstopindvb.find('Post')if'city'instopifstop['city']=='Dresden']Find other POIs with coordinatesSearch for all kinds of POIs inside a given square.importdvbsouthwest_lat=51.04120southwest_lng=13.70106northeast_lat=51.04615northeast_lng=13.71368pintypes='stop'# can be poi, platform, rentabike, ticketmachine, parkandride, carsharing or stopdvb.pins(southwest_lat,southwest_lng,northeast_lat,northeast_lng,pintypes)pintypesdefaults to ‘stop’ if no other input is given.[{"connections":"1:7~8~9~10~11~12","coords":{"lat":51.04373256804444,"lng":13.70625638110702},"id":33000143,"name":"Saxoniastraße"},{"connections":"2:61~90","coords":{"lat":51.04159705545878,"lng":13.7053650905211},"id":33000700,"name":"Ebertplatz"},{"connections":"1:6~7~8~9~10~11~12#2:61~63~90~A#3:333","coords":{"lat":51.04372841952444,"lng":13.703461228676069},"id":33000144,"name":"Tharandter Straße"},...]Look up coordinates for POIFind the coordinates for a given POI id.importdvbdvb.poi_coords(33000755){'lat':51.018745307424005,'lng':13.758700156062707}Address for coordinates - WIPLook up the address for a given set of coordinates.importdvblat=51.04373lng=13.70320dvb.address(lat,lng){'city':u'Dresden','address':u'Kesselsdorfer Straße 1'}Other stuffStop names in queries are very forgiving. As long as the server sees it
as a unique hit, it’ll work. ‘Helmholtzstraße’ finds the same data as
‘helmholtzstrasse’, ‘Nürnberger Platz’ = ‘nuernbergerplatz’ etc.One last note, be sure not to run whatever it is you’re building from
inside the network of the TU Dresden. Calls todvb.route()anddvb.find()will time out. This is unfortunately expected behavior as
API calls from these IP ranges are blocked.