RFI APIrfi.it ↗
Access live Italian train departures/arrivals, station search with region filters, circulation alerts, and station service details via the RFI.it API.
What is the RFI API?
The RFI.it API covers Italy's national railway network across 5 endpoints, returning live departure and arrival boards, station metadata, and real-time circulation alerts. The get_live_monitor endpoint streams current train status — including delay, platform, and carrier — for any Italian station identified by name or numeric place ID. Companion endpoints handle station search with geographic filters, detailed service listings, and the full station-to-placeId mapping table.
No input parameters required.
curl -X GET 'https://api.parse.bot/scraper/776b2149-49fb-4540-acd6-822e63ec0345/get_station_mappings' \ -H 'X-API-Key: $PARSE_API_KEY'
Typed, relational, agent-ready
A generated client with real types, enums, and the links between objects — the structure a flat JSON response can't carry. Autocompletes in your editor and reads cleanly to coding agents.
- Fully typed · autocompletes
- Objects link to objects
- Typed errors & pagination
Typed Python client. Set up the SDK in your uv project, then pull this API’s typed client:
uv add parse-sdk uv run parse init uv run parse add --marketplace rfi-it-api
uv run parse add --marketplace pulls a pinned snapshot of this canonical API — it won’t change underneath you. To customize it, subscribe and swap to your own copy.
"""Walkthrough: RFI Italian Railway API — bounded, re-runnable; every call capped."""
from parse_apis.rfi_italian_railway_api import RFI, Station, StationDetail, LiveBoard, StationMapping, Alert, BoardType, StationNotFound
rfi = RFI()
# Fetch full station-name-to-placeId mapping
mapping = rfi.stationmappings.fetch()
print(mapping.total, list(mapping.mappings.items())[:3])
# Search for stations in the Lazio region containing "Roma"
for station in rfi.stations.search(region="Lazio", query="Roma", limit=5):
print(station.name, station.province, station.passenger_service)
# Get detailed station info by slug
detail = rfi.stationdetails.get(slug="roma-termini")
print(detail.name, detail.slug, detail.services, detail.accessibility)
# Fetch live departure board using the BoardType enum
board = rfi.liveboards.fetch(station_name="ROMA TERMINI", type=BoardType.DEPARTURES)
print(board.station, board.type)
for train in board.trains[:3]:
print(train.train_number, train.category, train.destination, train.scheduled_time, train.delay)
# Retrieve current circulation alerts
current_alerts = rfi.alerts.list()
for msg in current_alerts.alerts[:3]:
print(msg)
# Typed error handling: catch StationNotFound for an invalid slug
try:
rfi.stationdetails.get(slug="nonexistent-station-xyz")
except StationNotFound as exc:
print(f"Station not found: {exc.station_slug}")
print("exercised: stationmappings.fetch / stations.search / stationdetails.get / liveboards.fetch / alerts.list / StationNotFound")
Retrieve the complete station name to placeId mapping used by the live monitor. Returns all Italian railway station names mapped to their numeric place IDs.
No input parameters required.
{
"type": "object",
"fields": {
"total": "integer count of stations",
"mappings": "object mapping uppercase station names to string place IDs"
},
"sample": {
"data": {
"total": 2426,
"mappings": {
"ABANO TERME": "364",
"ROMA TERMINI": "2218",
"MILANO CENTRALE": "1700"
}
},
"status": "success"
}
}About the RFI API
Live Train Boards
The get_live_monitor endpoint returns the real-time departures or arrivals board for a given station. Pass either a place_id (numeric string from get_station_mappings) or a full uppercase station_name such as ROMA TERMINI. The response includes an array of train objects, each carrying carrier, category, train_number, destination (or origin for arrivals), scheduled_time, delay, and platform. The type field in the response confirms whether you received a departures or arrivals board.
Station Search and Details
search_stations queries the RFI GIS service and supports filtering by region (e.g. Lombardia), province, municipality, and a partial-match query string. Each result includes name, region, province, municipality, type, passenger_service, and manager. The limit parameter caps the result count. For richer per-station data, get_station_details accepts a station_slug (e.g. roma-termini) and returns arrays of services (such as Bar, caffetteria, ristorazione or Bici) and accessibility features.
Station Mappings and Alerts
get_station_mappings returns the complete lookup table that maps uppercase station names to their numeric place_id strings — useful for building autocomplete or validating station names before calling get_live_monitor. The get_infomobilita_alerts endpoint pulls the current Infomobilità ticker from the RFI homepage and returns an alerts array of plain-text strings describing active line disruptions, speed restrictions, and service updates across the network.
The RFI API is a managed, monitored endpoint for rfi.it — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when rfi.it changes and a check fails, the API is automatically queued for repair and re-verified. It is built to keep working as the site underneath it changes.
This isn't an official rfi.it API — it's an independent, maintained REST wrapper over public data. Where the source has no official API (or only a limited one), Parse gives you a stable contract over a source that never promised one, and keeps it current. Need a new endpoint or field? You can revise it yourself in plain English and the agent rebuilds it against the live site in minutes — contributing the change back to the shared API is free.
Will this API break when the source site changes?+
Is this an official API from the source site?+
Can I fix or extend this API myself if I need a new endpoint or field?+
What happens if I call an endpoint that has an issue?+
- Build a departure board widget for Italian stations using
get_live_monitorwith real-time delay and platform data. - Filter stations by region or province via
search_stationsto populate a geographic station picker. - Display current service disruptions in a travel app by polling
get_infomobilita_alertsfor active circulation messages. - Map station names to place IDs at startup using
get_station_mappingsto avoid manual lookup tables. - Show accessible station options to mobility-impaired travellers using the
accessibilityarray fromget_station_details. - Aggregate delay statistics across multiple stations by periodically calling
get_live_monitorand recording thedelayfield per train.
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 100 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 100 req/min |
One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.
Does RFI have an official public developer API?+
What does `get_live_monitor` return, and how do I identify the station?+
trains array where each object contains carrier, category, train_number, destination (or origin for arrivals), scheduled_time, delay, and platform, plus a top-level station name and type field. You identify the station with either a place_id string (from get_station_mappings) or a full uppercase station_name such as MILANO CENTRALE.Does the API cover historical train schedules or only the current live board?+
get_live_monitor reflects the current real-time board only; no historical departure or arrival records are returned. The API covers live status, station metadata, and current alerts. You can fork it on Parse and revise it to add an endpoint targeting historical timetable data if that surface becomes available.Can I filter `get_infomobilita_alerts` by specific line or region?+
alerts array. You can fork the API on Parse and revise it to add server-side filtering logic.