{"id":27129666,"url":"https://github.com/tutorialwork/deutsche_bahn_api","last_synced_at":"2025-04-07T19:56:57.444Z","repository":{"id":65278909,"uuid":"589234099","full_name":"Tutorialwork/deutsche_bahn_api","owner":"Tutorialwork","description":"This is a package to interact with the Deutsche Bahn timetables api","archived":false,"fork":false,"pushed_at":"2024-05-11T14:20:09.000Z","size":281,"stargazers_count":21,"open_issues_count":7,"forks_count":14,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-02T07:36:18.498Z","etag":null,"topics":["api","deutsche-bahn","home","package","python","train"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/deutsche-bahn-api","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tutorialwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-01-15T14:22:35.000Z","updated_at":"2025-02-01T01:21:22.000Z","dependencies_parsed_at":"2023-01-16T05:15:26.332Z","dependency_job_id":"eddeb2a6-0cf3-4b88-9beb-42e4413db220","html_url":"https://github.com/Tutorialwork/deutsche_bahn_api","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"d8b25cf544371516ad61fb4abf60a82cf7bef021"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tutorialwork%2Fdeutsche_bahn_api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tutorialwork%2Fdeutsche_bahn_api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tutorialwork%2Fdeutsche_bahn_api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tutorialwork%2Fdeutsche_bahn_api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tutorialwork","download_url":"https://codeload.github.com/Tutorialwork/deutsche_bahn_api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247721903,"owners_count":20985084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","deutsche-bahn","home","package","python","train"],"created_at":"2025-04-07T19:56:56.842Z","updated_at":"2025-04-07T19:56:57.433Z","avatar_url":"https://github.com/Tutorialwork.png","language":"Python","readme":"# Deutsche Bahn Api\n\nThis is a small Python package to access the Deutsche Bahn timetables api.\nThe timetable api is able to request the timetable of a specific station and access all dynamic changes on the timetable e.g. changed departure or arrival of the train, changed platform of arrival or a changed path of the train.\n\n## Setup\n\n- Create a account at: https://developers.deutschebahn.com\n- Create a new application using this url: https://developers.deutschebahn.com/db-api-marketplace/apis/application/new and choose a name that you want\n- After that save you the client id and the client secret. You need it to interact with the api\n- Navigate to all available apis page at: https://developers.deutschebahn.com/db-api-marketplace/apis/product and select the \"Timetables\" api\n- And click the red subscribe button and select your application\n- Now you are done and can start using the api\n\n### ApiAuthentication\n\nCreate a new ApiAuthentication class and pass to it the newly created client id and client secret.\nAnd test with the ```api.test_credentials()``` function if the api authentication works.\n\n```python\napi = ApiAuthentication(\"YOUR_CLIENT_ID\", \"YOUR_CLIENT_SECRET\")\nsuccess: bool = api.test_credentials()\n```\n\n### Stations\n\nTo get the timetable of a specific train station you can use the name or lat and long values.\n\n```python\nstation_helper = StationHelper()\nfound_stations = station_helper.find_stations_by_lat_long(47.996713, 7.842174, 10)\nfound_stations_by_name = station_helper.find_stations_by_name(\"Freiburg\")\n```\n\n### Timetable\n\nWith the station object you are able to request the timetable from the station using the following code.\n\n```python\ntimetable_helper = TimetableHelper(YOUR_STATION_OBJECT, YOUR_API_AUTHENTICATION_OBJECT)\ntrains_in_this_hour = timetable_helper.get_timetable()\ntrains_at_given_hour = timetable_helper.get_timetable(12)\n```\n\nThis method returns you a list with all trains that are scheduled for departure at this station in the current hour.\nYou can also pass the ```get_timetable()``` function the hour you want to request.\n**Important** this list **don't** contains delays, platform changes or changed stations.\nThis can be achieved by using the ```get_timetable_changes()``` function and passing the list from the previous step.\n\n```python\ntrains_with_changes = timetable_helper.get_timetable_changes(trains)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftutorialwork%2Fdeutsche_bahn_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftutorialwork%2Fdeutsche_bahn_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftutorialwork%2Fdeutsche_bahn_api/lists"}