{ "info": { "author": "Pascal Sch\u00e4rli", "author_email": "pas.schaerli@sunrise.ch", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# pySBB\n\nThis is an unofficial python wrapper for the SBB [API](https://transport.opendata.ch/docs.html). [SBB](https://www.sbb.ch) stands for the \"Schweizerische Bundes Bahnen\" (Swiss Federal Transport).\n\n# Installation\n`pip3 install pySBB`\n\n# Usage\nThis package lets you access the SBB api easily. Here is how to use it:\n\n## Get Connections\nIt is very simple to get connections between two stations:\n```\nimport pySBB\n\nconnections = pySBB.get_connections(\"Z\u00fcrich\", \"Bern\")\nfor c in connections:\n\tprint(c)\n```\nExample Output:\n```\nZ\u00fcrich HB (18:32, Plat. 32) -> Bern (19:28, Plat. 32) | 56min\nZ\u00fcrich HB (19:02, Plat. 31) -> Bern (19:58, Plat. 31) | 56min\nZ\u00fcrich HB (19:32, Plat. 32) -> Bern (20:28, Plat. 32) | 56min\nZ\u00fcrich HB (20:02, Plat. 31) -> Bern (20:58, Plat. 31) | 56min\n```\nFurther parameters (see [connections](https://transport.opendata.ch/docs.html#connections)) for more info:\n- via: Specifies up to five via locations.\n- date: Date of the connection, in the format YYYY-MM-DD\n- time: Time of the connection, in the format hh:mm\n- isArrivalTime: Defaults to False, if set to True the passed date and time is the arrival time\n- transportations: Transportation means; one or more of train, tram, ship, bus, cableway\n- limit: 1 - 16. Specifies the number of connections to return. If several connections depart at the same time they are counted as 1.\n- page: 0 - 3. Allows pagination of connections. Zero-based, so first page is 0, second is 1, third is 2 and so on.\n- direct: defaults to False, if set to True only direct connections are allowed\n- sleeper: defaults to False, if set to True only direct connections are allowed\n- couchette: defaults to False, if set to True only night trains containing couchettes are allowed, implies direct=True\n- bike: defaults to False, if set to True only trains allowing the transport of bicycles are allowed\n- accessibility: Possible values are independent_boarding, assisted_boarding, and advanced_notice\n\n## Get Locations\nThe api allows you to find locations such as train stations, addresses and other point of interests (eg. Clock Tower or China Garden)\n```\nimport pySBB\n\nlocations = pySBB.get_locations(query=\"Lidostrasse 5 Luzern\")\nfor l in locations:\n print(l)\n```\nExample Output:\n```\nLuzern, Lidostr. 5\nVerkehrshaus der Schweiz, Luzern, Lidostr. 5\nRestaurant Piccard im Verkehrshaus der Schweiz, Luzern, Lidostr. 5\n...\n```\nFurther parameters (see [locations](https://transport.opendata.ch/docs.html#locations) for more info:\n- query: Specifies the location name to search for\n- x: Latitude\n- y: Longitude\n- type: Only with query parameter. Specifies the location type, possible types are:\n\t* all (default): Looks up for all types of locations\n\t* station: Looks up for stations (eg. train station, bus station)\n\t* poi: Looks up for points of interest (eg. Clock tower, China garden)\n\t* address: Looks up for an address (eg. Zurich Bahnhofstrasse 33)\n\n## Get Stationboards\nStationboards are the big blue boards that can be seen at trainstations. These are also available via the api.\n```\nimport pySBB\n\nentries = pySBB.get_stationboard(\"Lugano\")\nfor e in entries:\n print(e)\n```\nExample Output:\n```\nLugano (18:51, Plat. 2) -> Chiasso\nLugano (18:55, Plat. 4) -> Bellinzona\nLugano (19:05, Plat. 2) -> Chiasso\nLugano (19:22, Plat. 2) -> Monza\nLugano (19:25, Plat. 4) -> Bellinzona\n...\n```\nFurther parameters (see [stationboard](https://transport.opendata.ch/docs.html#stationboard)) for more info:\n- id: The id of the station whose stationboard should be returned. Overwrites to the station parameter.\n- limit: Number of departing connections to return.\n- transportations: Transportation means; one or more of train, tram, ship, bus, cableway\n- date: Date of departing connections, in the format YYYY-MM-DD\n- time: Time of departing connections, in the format hh:mm\n- type: departure (default) or arrival\n\n# Objects\nThe objects are the same as the ones used by the API, which are documented [here](https://transport.opendata.ch/docs.html#api-objects)\n\nThe only difference is that any strings containing times or durations have been converted to [datetime](https://docs.python.org/3/library/datetime.html) objects.\n\nSometimes it can also help to look at the unprocessed data returned by the API, in order to figure out how the classes are structured. The unprocessed data is stored for every Object in the `_data` parameter and can be accessed like this (I also used the [json](https://docs.python.org/3.5/library/json.html) module to format the dictionary nicely with indentations)\n```\nimport pySBB\nimport json\nentry = pySBB.get_stationboard(\"Lugano\", limit=1)[0]\n\nprint(json.dumps(entry._data, indent=1))\n```\n\n# Further Examples\n## Get all transfer stations\nThe following code lets you see all transfer stations for a given connection\n```\nimport pySBB\n\nconnection = pySBB.get_connections(\"Mauraz\", \"Amriswil\", limit=1)[0]\n\nprint(connection)\nfor section in connection.sections:\n print(\" {}\".format(section))\n```\n```\nMauraz (11:48) -> Amriswil (16:05, Plat. 33) | 4h 17min\n Mauraz (11:48) -> Pampigny-S\u00e9very (12:04)\n Pampigny-S\u00e9very (12:04) -> L'Isle (12:13)\n L'Isle (12:13) -> L'Isle, gare (12:15)\n L'Isle, gare (12:15) -> Cossonay-Penthalaz, gare (12:35)\n Cossonay-Penthalaz, gare (12:35) -> Cossonay-Penthalaz (12:37)\n Cossonay-Penthalaz (12:37, Plat. 1) -> Yverdon-les-Bains (13:00, Plat. 1)\n Yverdon-les-Bains (13:00, Plat. 1) -> Z\u00fcrich HB (14:56, Plat. 13)\n Z\u00fcrich HB (14:56, Plat. 33) -> Amriswil (16:05, Plat. 2)\n```\n\n## Get passed stations with coordinates\nThe following code prints all station names that are passed, together with its coordinates.\n```\nimport pySBB\n\nconnection = pySBB.get_connections(\"Brugg\", \"Basel\", limit=1)[0]\n\nprint(connection)\nfor section in connection.sections:\n for passList in section.journey.passList:\n station = passList.station\n print(\" {} {}\".format(station.name, station.coordinate))\n```\n\n```\nBrugg AG (11:41, Plat. 2) -> Basel SBB (12:24, Plat. 2) | 43min\n Brugg AG (47.48085, 8.208829)\n Frick (47.507341, 8.01309)\n Rheinfelden (47.551208, 7.792162)\n Basel SBB (47.547403, 7.589577)\n```\n\n## Get all follwing station for first stationboard entry\nThe following code prints all stations of the first ship departing from \"Luzern Bahnhofquai\" at a given date:\n```\nimport pySBB\n\nentry = pySBB.get_stationboard(\"Luzern Bahnhofquai\", transportations=\"ship\", datetime=\"2019-10-10 12:00\", limit=1)[0]\n\nprint(entry)\nfor passList in entry.passList:\n print(\" {}\".format(passList))\n```\n\n```\nLuzern Bahnhofquai (12:00, Plat. 1) -> Vitznau\n Verkehrshaus-Lido (12:10)\n Hertenstein (See) (12:30)\n Weggis (12:40)\n Vitznau (12:54)\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pascscha/pySBB", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pySBB", "package_url": "https://pypi.org/project/pySBB/", "platform": "", "project_url": "https://pypi.org/project/pySBB/", "project_urls": { "Homepage": "https://github.com/pascscha/pySBB" }, "release_url": "https://pypi.org/project/pySBB/1.1.0/", "requires_dist": null, "requires_python": "", "summary": "An unofficial python wrapper for the SBB api.", "version": "1.1.0" }, "last_serial": 5714258, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "fb84985c28a6c9020bdb14cb74f00aba", "sha256": "53b8d12c3eae09199532db39eb16fc0f6306b98121dd9970d7ee44e45db9b393" }, "downloads": -1, "filename": "pySBB-1.0.0-py3.6.egg", "has_sig": false, "md5_digest": "fb84985c28a6c9020bdb14cb74f00aba", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": null, "size": 13154, "upload_time": "2019-08-22T09:52:49", "url": "https://files.pythonhosted.org/packages/24/2a/d9d99f38cf9ee4ec0e88db86861200848af695b4bcc6ad2b223b74f522ea/pySBB-1.0.0-py3.6.egg" }, { "comment_text": "", "digests": { "md5": "b6a537f862c9237ce67bab1d0efbc51d", "sha256": "9ddd66c9e7ceb8deec4cf704d49e10016346ac3950f6b96a0c956fd360ef6b65" }, "downloads": -1, "filename": "pySBB-1.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b6a537f862c9237ce67bab1d0efbc51d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8105, "upload_time": "2019-02-06T19:05:00", "url": "https://files.pythonhosted.org/packages/72/36/6c86b97fc2cde17934a6d44aed8782e70c36851a33aa74d5f39330b59918/pySBB-1.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "db760f91c7739bd032a0d0e9d674da1b", "sha256": "17459671d2a1a88d070ac6bb6e795aeeb486bbf2a166ef4d857ae8aba9c05d32" }, "downloads": -1, "filename": "pySBB-1.0.0.tar.gz", "has_sig": false, "md5_digest": "db760f91c7739bd032a0d0e9d674da1b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6713, "upload_time": "2019-02-06T19:05:03", "url": "https://files.pythonhosted.org/packages/89/6c/a47082f80056a759730224d0d65d5f378f76b70ddf827d61d7e1615faee3/pySBB-1.0.0.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "588bb19f994083c7b26d34ed52e2ecb9", "sha256": "7740ee6c458eaf0ea3611bdf5172afc307adde8a0078db6398c0ce8fc055ddbd" }, "downloads": -1, "filename": "pySBB-1.1.0.tar.gz", "has_sig": false, "md5_digest": "588bb19f994083c7b26d34ed52e2ecb9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7783, "upload_time": "2019-08-22T09:52:53", "url": "https://files.pythonhosted.org/packages/fd/e7/97a0c4d2af78d43e5d45d6c7032930a8308bc5ce244d56998534161d2b72/pySBB-1.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "588bb19f994083c7b26d34ed52e2ecb9", "sha256": "7740ee6c458eaf0ea3611bdf5172afc307adde8a0078db6398c0ce8fc055ddbd" }, "downloads": -1, "filename": "pySBB-1.1.0.tar.gz", "has_sig": false, "md5_digest": "588bb19f994083c7b26d34ed52e2ecb9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7783, "upload_time": "2019-08-22T09:52:53", "url": "https://files.pythonhosted.org/packages/fd/e7/97a0c4d2af78d43e5d45d6c7032930a8308bc5ce244d56998534161d2b72/pySBB-1.1.0.tar.gz" } ] }