Deutsche Bahn Train Tickets and Connections Scraper
Pricing
from $3.00 / 1,000 train connections
Deutsche Bahn Train Tickets and Connections Scraper
Scrape Deutsche Bahn train connections, departure and arrival times, changes, operators, current prices, ticket offers, delays, platforms, and service alerts.
Pricing
from $3.00 / 1,000 train connections
Rating
0.0
(0)
Developer
Muhammad Afzal
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
5 days ago
Last modified
Categories
Share
Deutsche Bahn Train Tickets & Connections Scraper
Search Deutsche Bahn passenger connections and export structured schedules, current starting prices, ticket offers, train products, operators, delays, platforms, changes, and service notices. The Actor resolves human-readable station names, queries Deutsche Bahn’s first-party journey interfaces, and saves one validated dataset row per connection.
This is a read-only research and automation tool. It does not reserve seats, book journeys, purchase tickets, manage a Bahn account, or bypass authentication. Availability and prices can change after collection; confirm important journey details on the official Deutsche Bahn website before travel.
What the Actor collects
Each result can contain:
- resolved origin and destination names and Deutsche Bahn station IDs;
- actual and planned departure and arrival timestamps;
- duration, number of changes, and direct/cancelled flags;
- current journey-level starting price and currency when supplied;
- refreshed ticket offer names and prices when requested and available;
- service products such as ICE, IC, EC, RE, RB, S-Bahn, U-Bahn, tram, or bus;
- operating companies;
- individual journey legs with platforms, delays, direction, walking distance, and load factor;
- traffic notices and other source remarks;
- the search parameters, source profile, source URL, and collection timestamp.
The Actor never exposes Deutsche Bahn’s opaque refresh token in dataset results. It hashes that token into a short connection identifier, which is useful for deduplication without leaking the source session value.
Input
Set origin and destination to station or stop names. Berlin Hbf and München Hbf are the default example. Leave travelDate empty to search tomorrow in the Europe/Berlin time zone; this makes saved Actor Tasks evergreen. Set travelTime in HH:MM form and choose whether it means departure-at-or-after or arrive-by.
Passenger inputs support one to five adults of a shared age, first or second class, and a common BahnCard 25, 50, or 100 discount. directOnly limits results to connections without public-transport changes. includeLocalTransport controls S-Bahn, U-Bahn, tram, bus, and ferry legs. bike requests bicycle-compatible itineraries.
When includeTicketOffers is enabled, the Actor refreshes every selected journey once to obtain fare names and ticket-level prices. This produces richer results but makes one extra source request per connection. Disable it when schedules and journey-level starting prices are sufficient.
maxResults is deliberately capped at 20. It is both the result limit and a predictable cost boundary. A German residential proxy is configured by default because Deutsche Bahn’s journey endpoints commonly reject datacenter traffic. Keep one sticky proxy session throughout a run so location lookup, journey search, and fare refreshes share coherent network identity.
Example input:
{"origin": "Berlin Hbf","destination": "München Hbf","travelTime": "08:00","searchBy": "departure","adults": 1,"adultAge": 30,"travelClass": "second","bahnCard": "none","directOnly": false,"includeLocalTransport": true,"includeTicketOffers": true,"language": "en","maxResults": 5}
Output
Results are stored in the default dataset. The connections view puts the most useful columns first: departure, arrival, duration, stations, changes, price, services, operators, cancellation status, and ticket offers. Nested legs retain the route details for downstream analysis.
The default key-value store record named OUTPUT contains a terminal summary. Its outcome is one of:
DATA: one or more validated connections were delivered;EMPTY: the query completed but returned no matching connections;REJECTED: the input was invalid, such as identical stations or a past date;BLOCKED: Deutsche Bahn rejected both bounded source-profile attempts;FAILED: an unexpected Actor failure occurred.
OUTPUT also records source-request counts, resolved stations, warnings, the source profile used, result charges, and whether a maximum charge limit stopped the run. Use this record to distinguish an authentic empty timetable from an access failure.
Pricing and cost controls
The pay-per-event model charges $0.005 once when a run starts and $0.003 for each connection written to the dataset. Invalid, blocked, and empty searches do not generate connection charges. The Actor displays the maximum event-charge estimate at startup. With maxResults: 5, that estimate is $0.020; Apify platform usage and residential proxy traffic may be billed separately according to your account plan.
Use a low maxResults while integrating. Add an Apify maxTotalChargeUsd run limit when you need a hard account-side ceiling. Result charging happens only after a record passes normalization and is written successfully.
Reliability behavior
The Actor begins with the web journey profile used by bahn.de and falls back across Deutsche Bahn’s Navigator/mobile profiles. When Akamai rejects those inexpensive HTTP paths, it starts a displayed Camoufox/Firefox browser on a fresh sticky German residential IP, warms the normal Deutsche Bahn homepage, keeps cookies, locale, fingerprint, and IP coherent, and makes the page-owned request from that browser session. All routes remain first-party Deutsche Bahn data paths. Pagination is bounded to four pages, every result is deduplicated, and each ticket refresh failure is isolated so schedule records can still be returned with a warning.
Source websites evolve. A sudden BLOCKED result is not equivalent to “no trains”; retry with the default German residential proxy and a fresh session. A genuine zero-result search returns EMPTY and succeeds. Avoid high-frequency polling, overlapping runs, or unnecessarily large searches.
Responsible use
Deutsche Bahn’s interfaces and data are governed by Deutsche Bahn’s terms, applicable database rights, and local law. Before sustained or commercial use, obtain any permission required for your intended volume and downstream use. Do not use the Actor to overload services, reproduce a competing timetable database, evade access controls, or mislead travelers. Store only what you need and respect notices from the source operator.
This project uses the independent ISC-licensed db-vendo-client; see THIRD_PARTY_NOTICES.md. The Actor is not endorsed by or affiliated with Deutsche Bahn AG. Deutsche Bahn product names are used descriptively to identify the data source.
Local development
The Actor requires Node.js 20 or newer.
npm installnpm testnpm run validate:inputnpm run preflightapify call
Local direct requests may be blocked even when the code is correct. The meaningful integration check is a private Apify cloud run with the default residential proxy. Unit tests cover input constraints, Europe/Berlin daylight-saving conversion, journey normalization, ticket cents-to-currency conversion, and refresh-token redaction.