dvb


Namedvb JSON
Version 1.4 PyPI version JSON
download
home_pagehttps://github.com/kiliankoe/dvbpy
Summaryquery Dresden's public transport system for current bus- and tramstop data in python
upload_time2023-11-19 15:31:19
maintainer
docs_urlNone
authorkiliankoe
requires_python
licenseMIT
keywords dvb vvo tram bus public transport dresden
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            dvbpy
-----

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, look `no further <https://github.com/kiliankoe/vvo#libraries>`__ 🙂

The documentation is located `here <https://kiliankoe.github.io/dvbpy/>`__.

Get dvbpy from PyPi :)

.. code:: shell

    pip install dvb

And then just import it.

.. code:: python

    import dvb


Monitor a single stop
~~~~~~~~~~~~~~~~~~~~~

Monitor a single stop to see every bus or tram leaving this stop after
the specified time offset.

.. code:: python

    import dvb

    stop = 'Helmholtzstraße'
    time_offset = 0 # how many minutes in the future, 0 for now
    num_results = 2
    city = 'Dresden'

    dvb.monitor(stop, time_offset, num_results, city)

.. code:: python

    [{
        'line': '85',
        'direction': 'Striesen',
        'arrival': 5
    },
    {
        'line': '85',
        'direction': 'Löbtau Süd',
        'arrival': 7
    }]

You can also call ``monitor()`` without city, num\_results or
time\_offset. City will default to Dresden.

Find routes
~~~~~~~~~~~

Query 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.

.. code:: python

    import dvb
    import time

    origin = 'Zellescher Weg'
    city_origin = 'Dresden'
    destination = 'Postplatz'
    city_destination = 'Dresden'
    time = int(time.time()) # a unix timestamp is wanted here
    deparr = 'dep'  # set to 'arr' for arrival time, 'dep' for departure time

    dvb.route(origin, destination, city_origin, city_destination, time, deparr)

.. code:: python

    {
        '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 a ``recommendation`` field. 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 are ``0`` for front, ``1`` for middle and
``2`` for back. If there are no recommendations available ``None`` is
returned.

Find stops by name
~~~~~~~~~~~~~~~~~~

Search for a single stop in the network of the DVB.

.. code:: python

    import dvb

    dvb.find('zellesch')

.. code:: python

    [{
        'name': 'Zellescher Weg',
        'city': 'Dresden',
        'coords': [51.028366, 13.745847]
    }]

The fields ``city`` and ``coords`` are optional as they are not
available for every stop. So don't forget to check for their existence
first.

.. code:: python

    [stop for stop in dvb.find('Post') if 'city' in stop if stop['city'] == 'Dresden']

Find other POIs with coordinates
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Search for all kinds of POIs inside a given square.

.. code:: python

    import dvb

    southwest_lat = 51.04120
    southwest_lng = 13.70106
    northeast_lat = 51.04615
    northeast_lng = 13.71368

    pintypes = 'stop'
    # can be poi, platform, rentabike, ticketmachine, parkandride, carsharing or stop

    dvb.pins(southwest_lat, southwest_lng, northeast_lat, northeast_lng, pintypes)

``pintypes`` defaults to 'stop' if no other input is given.

.. code:: python

    [
       {
          "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 POI
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Find the coordinates for a given POI id.

.. code:: python

    import dvb

    dvb.poi_coords(33000755)

.. code:: python

    {'lat': 51.018745307424005, 'lng': 13.758700156062707}

Address for coordinates - WIP
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Look up the address for a given set of coordinates.

.. code:: python

    import dvb

    lat = 51.04373
    lng = 13.70320

    dvb.address(lat, lng)

.. code:: python

    {
        'city': u'Dresden',
        'address': u'Kesselsdorfer Straße 1'
    }

Other stuff
~~~~~~~~~~~

Stop 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 to ``dvb.route()`` and
``dvb.find()`` will time out. This is unfortunately expected behavior as
API calls from these IP ranges are blocked.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kiliankoe/dvbpy",
    "name": "dvb",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "dvb vvo tram bus public transport dresden",
    "author": "kiliankoe",
    "author_email": "me@kilian.io",
    "download_url": "https://files.pythonhosted.org/packages/df/4f/958eb069ead4a53f11bd7fbe43e9084001ac6853104c756b32b94def3ad8/dvb-1.4.tar.gz",
    "platform": null,
    "description": "dvbpy\n-----\n\nAn unofficial python module giving you a few options to query a\ncollection of publicly accessible API methods for Dresden's public\ntransport system.\n\nWant something like this for another language, look `no further <https://github.com/kiliankoe/vvo#libraries>`__ \ud83d\ude42\n\nThe documentation is located `here <https://kiliankoe.github.io/dvbpy/>`__.\n\nGet dvbpy from PyPi :)\n\n.. code:: shell\n\n    pip install dvb\n\nAnd then just import it.\n\n.. code:: python\n\n    import dvb\n\n\nMonitor a single stop\n~~~~~~~~~~~~~~~~~~~~~\n\nMonitor a single stop to see every bus or tram leaving this stop after\nthe specified time offset.\n\n.. code:: python\n\n    import dvb\n\n    stop = 'Helmholtzstra\u00dfe'\n    time_offset = 0 # how many minutes in the future, 0 for now\n    num_results = 2\n    city = 'Dresden'\n\n    dvb.monitor(stop, time_offset, num_results, city)\n\n.. code:: python\n\n    [{\n        'line': '85',\n        'direction': 'Striesen',\n        'arrival': 5\n    },\n    {\n        'line': '85',\n        'direction': 'L\u00f6btau S\u00fcd',\n        'arrival': 7\n    }]\n\nYou can also call ``monitor()`` without city, num\\_results or\ntime\\_offset. City will default to Dresden.\n\nFind routes\n~~~~~~~~~~~\n\nQuery the server for possible routes from one stop to another. Returns\nmultiple possible trips, the bus-/tramlines to be taken, the single\nstops, their arrival and departure times and their GPS coordinates.\n\n.. code:: python\n\n    import dvb\n    import time\n\n    origin = 'Zellescher Weg'\n    city_origin = 'Dresden'\n    destination = 'Postplatz'\n    city_destination = 'Dresden'\n    time = int(time.time()) # a unix timestamp is wanted here\n    deparr = 'dep'  # set to 'arr' for arrival time, 'dep' for departure time\n\n    dvb.route(origin, destination, city_origin, city_destination, time, deparr)\n\n.. code:: python\n\n    {\n        'trips': [{\n            'interchange': 0,\n            'nodes': [{\n                'line': '11',\n                'mode': 'Stra\u00dfenbahn',\n                'direction': 'Dresden B\u00fchlau Ullersdorfer Platz',\n                'path': [\n                    [13.745754, 51.02816],\n                    [13.745848, 51.028393],\n                    ...\n                ],\n                'departure': {\n                    'time': '18:01',\n                    'stop': 'Zellescher Weg',\n                    'coords': '13745754,51028160'\n                },\n                'arrival': {\n                    'time': '18:14',\n                    'stop': 'Postplatz',\n                    'coords': '13733717,51050544'\n                }\n            }],\n            'duration': '00:13',\n            'departure': '18:01',\n            'arrival': '18:14'\n        },\n        ...\n        }],\n        'origin': 'Dresden, Zellescher Weg',\n        'destination': 'Dresden, Postplatz'\n    }\n\nEverything besides origin and destination is optional and only needs to\nbe included if necessary. City for origin and destination defaults to\nDresden, time to now and is handled as the departure time.\n\nThe path property contains a list consisting of all the coordinates\ndescribing the path of this node. Useful for example if you want to draw\nit on a map.\n\nIf you use recommendations for interchanges, each of the nodes (except\nthe last one)in every trip will have a ``recommendation`` field. The\nfield will tell where you should enter this route to get an optimal\ninterchange experience. This is of course only if there are any\ninterchanges. The positions are ``0`` for front, ``1`` for middle and\n``2`` for back. If there are no recommendations available ``None`` is\nreturned.\n\nFind stops by name\n~~~~~~~~~~~~~~~~~~\n\nSearch for a single stop in the network of the DVB.\n\n.. code:: python\n\n    import dvb\n\n    dvb.find('zellesch')\n\n.. code:: python\n\n    [{\n        'name': 'Zellescher Weg',\n        'city': 'Dresden',\n        'coords': [51.028366, 13.745847]\n    }]\n\nThe fields ``city`` and ``coords`` are optional as they are not\navailable for every stop. So don't forget to check for their existence\nfirst.\n\n.. code:: python\n\n    [stop for stop in dvb.find('Post') if 'city' in stop if stop['city'] == 'Dresden']\n\nFind other POIs with coordinates\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nSearch for all kinds of POIs inside a given square.\n\n.. code:: python\n\n    import dvb\n\n    southwest_lat = 51.04120\n    southwest_lng = 13.70106\n    northeast_lat = 51.04615\n    northeast_lng = 13.71368\n\n    pintypes = 'stop'\n    # can be poi, platform, rentabike, ticketmachine, parkandride, carsharing or stop\n\n    dvb.pins(southwest_lat, southwest_lng, northeast_lat, northeast_lng, pintypes)\n\n``pintypes`` defaults to 'stop' if no other input is given.\n\n.. code:: python\n\n    [\n       {\n          \"connections\":\"1:7~8~9~10~11~12\",\n          \"coords\":{\n             \"lat\":51.04373256804444,\n             \"lng\":13.70625638110702\n          },\n          \"id\":33000143,\n          \"name\":\"Saxoniastra\u00dfe\"\n       },\n       {\n          \"connections\":\"2:61~90\",\n          \"coords\":{\n             \"lat\":51.04159705545878,\n             \"lng\":13.7053650905211\n          },\n          \"id\":33000700,\n          \"name\":\"Ebertplatz\"\n       },\n       {\n          \"connections\":\"1:6~7~8~9~10~11~12#2:61~63~90~A#3:333\",\n          \"coords\":{\n             \"lat\":51.04372841952444,\n             \"lng\":13.703461228676069\n          },\n          \"id\":33000144,\n          \"name\":\"Tharandter Stra\u00dfe\"\n       }, ...\n    ]\n\nLook up coordinates for POI\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nFind the coordinates for a given POI id.\n\n.. code:: python\n\n    import dvb\n\n    dvb.poi_coords(33000755)\n\n.. code:: python\n\n    {'lat': 51.018745307424005, 'lng': 13.758700156062707}\n\nAddress for coordinates - WIP\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nLook up the address for a given set of coordinates.\n\n.. code:: python\n\n    import dvb\n\n    lat = 51.04373\n    lng = 13.70320\n\n    dvb.address(lat, lng)\n\n.. code:: python\n\n    {\n        'city': u'Dresden',\n        'address': u'Kesselsdorfer Stra\u00dfe 1'\n    }\n\nOther stuff\n~~~~~~~~~~~\n\nStop names in queries are very forgiving. As long as the server sees it\nas a unique hit, it'll work. 'Helmholtzstra\u00dfe' finds the same data as\n'helmholtzstrasse', 'N\u00fcrnberger Platz' = 'nuernbergerplatz' etc.\n\nOne last note, be sure not to run whatever it is you're building from\ninside the network of the TU Dresden. Calls to ``dvb.route()`` and\n``dvb.find()`` will time out. This is unfortunately expected behavior as\nAPI calls from these IP ranges are blocked.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "query Dresden's public transport system for current bus- and tramstop data in python",
    "version": "1.4",
    "project_urls": {
        "Homepage": "https://github.com/kiliankoe/dvbpy"
    },
    "split_keywords": [
        "dvb",
        "vvo",
        "tram",
        "bus",
        "public",
        "transport",
        "dresden"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df4f958eb069ead4a53f11bd7fbe43e9084001ac6853104c756b32b94def3ad8",
                "md5": "b2cf5f7b7faedd7cffb98b31ce27d786",
                "sha256": "dde76c1e0e2066ff75d06c6d6bed625014041f155c6e43f9efe829ee26e87dfe"
            },
            "downloads": -1,
            "filename": "dvb-1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "b2cf5f7b7faedd7cffb98b31ce27d786",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8383,
            "upload_time": "2023-11-19T15:31:19",
            "upload_time_iso_8601": "2023-11-19T15:31:19.919578Z",
            "url": "https://files.pythonhosted.org/packages/df/4f/958eb069ead4a53f11bd7fbe43e9084001ac6853104c756b32b94def3ad8/dvb-1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-19 15:31:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kiliankoe",
    "github_project": "dvbpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "dvb"
}
        
Elapsed time: 0.13884s