Skip to content

Add Spain's Renfe trains to Interrail - #101

Open
davd-gzl wants to merge 1 commit into
interrail-feesfrom
interrail-spain
Open

davd-gzl wants to merge 1 commit into
interrail-feesfrom
interrail-spain

Conversation

@davd-gzl

@davd-gzl davd-gzl commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Before: Interrail only knows SNCF's trains, so Paris → Madrid finds nothing: SNCF stops at Barcelona.

After: Interrail also reads Renfe's long-distance trains, so Paris → Madrid comes out as a TGV to Barcelona, a change, then an AVE to Madrid. Typing "Madrid", "Sevilla" or "Valencia" finds the city's main station, a Renfe train books on renfe.com, and Spanish stations show on the map.

Stacked on #97 (which is on #83): merge those first.

How

  • Source. Renfe's timetable comes from train-api (<base>/renfe/interrail/all.json), fetched next to SNCF's. There is no bundled snapshot of it: without train-api, or when its file is entirely in the past, Interrail shows SNCF's trains alone, as today. The MAX passes never ask for it.
  • Joining the networks. src/data/operators.ts describes Renfe. Its stations SNCF also serves take SNCF's id, by name with accents, case and punctuation aside (Barcelona Sants, Perpignan, Marseille St Charles…) or by a short mapping (Lyon Part Dieu, Nîmes, Valence TGV). A train both feeds carry is kept once.
  • Changes. Connections only happen at hub stations. The Interrail profile now adds Barcelona Sants and Spain's main stations to the French hubs, registered per timetable (setNetworkHubs in connections.ts), so the MAX searches and their caches are unchanged.
  • Booking. A train carries its operator; Renfe trains book on renfe.com (the direct-train button says "Book on Renfe", and a connection's step list links each train to its own site).
  • Stations. Renfe's names keep their own spelling ("Madrid-Puerta de Atocha-Almudena Grandes"). City names resolve to the main station, and about 35 Spanish cities get map coordinates.
  • Fees. Show Interrail reservation fees as an opt-in setting #97's fee table covers SNCF only, so a journey with a Renfe train shows no estimate rather than a wrong one.
  • Search worker. The dataset reports train-api as its source whenever any of its trains came from there, so the worker loads the same trains as the page.
  • Copy. The Interrail tagline and "How does it work?" note now say SNCF and Renfe, in all 11 locales. README, docs/user-flows.md and llms.txt are updated.

Before merging

Renfe's file is published today with every pair of stops of every regional train (3.4 million trains), too big for a browser. offware-apps/train-api#13 keeps those trains between the long-distance stations only; merge it before this one.

Checks

tsc, npm test (244 passed, including tests/spain.test.ts: joining stations, dropping duplicates, Paris → Madrid via Barcelona, no fee estimate, SNCF-only fallback, city names), npm run build, npm run verify and npm run test:e2e (25/25). The e2e gates run without train-api, so they cover the SNCF-only path. I also opened the built app against a local train-api serving SNCF's Interrail file and a Renfe sample: ?card=interrail&mode=od&from=paris&to=madrid resolved Madrid, showed Paris → Barcelona Sants → Madrid with a 2 h 58 change, and the booking steps linked SNCF Connect for the TGV and renfe.com for the AVE.

Interrail now reads Renfe's long-distance trains from train-api next to
SNCF's. Renfe stations SNCF also serves take SNCF's id, and Barcelona Sants
and Spain's main stations are interchange hubs, so Paris to Madrid comes out
as a TGV to Barcelona and an AVE on. A Renfe train books on renfe.com, a
city name like Madrid finds its main station, and the reservation-fee
estimate leaves out journeys with a Renfe train. Without train-api,
Interrail shows SNCF's trains alone, as before.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant