Discover/Trenitalia API
live

Trenitalia APItrenitalia.com

Access real-time Trenitalia train status, delays, station departure/arrival boards, ticket search, and traffic alerts via 8 structured API endpoints.

Endpoint health
verified 7d ago
get_station_autocomplete
get_train_status
get_station_arrivals
get_train_autocomplete
search_trains
8/8 passing latest checkself-healing
Endpoints
8
Updated
21d ago

What is the Trenitalia API?

The Trenitalia API exposes 8 endpoints covering live train status, station boards, ticket availability, and network alerts across Italy's rail network. Use get_train_status to retrieve a train's current delay in minutes, its full stop itinerary, and origin/destination data, or call search_trains to query fares and schedules between any two stations by their 9-digit location IDs.

Try it
Station name prefix to search (e.g. 'Roma', 'Milano', 'Napoli')
api.parse.bot/scraper/0bea8d74-c4a1-467d-8b53-8e860a100320/<endpoint>
Ready to send
Fill in the parameters and hit sign in to send to see live response data here.
Call it over HTTPgrab a free API key at signup
curl -X GET 'https://api.parse.bot/scraper/0bea8d74-c4a1-467d-8b53-8e860a100320/get_station_autocomplete?query=Roma' \
  -H 'X-API-Key: $PARSE_API_KEY'
Python SDK · recommended

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 trenitalia-com-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.

"""Trenitalia SDK — search trains, check live status, browse station boards."""
from parse_apis.trenitalia_api import Trenitalia, TrainNotFound

client = Trenitalia()

# Search stations for ticket booking (returns 9-digit IDs for search_trains)
roma = client.locations.search(query="Roma", limit=3).first()
print(f"Location: {roma.name} (ID: {roma.id}, multistation: {roma.multistation})")

# Get real-time station board — departures from Roma Termini
station = client.stations.search(query="Roma", limit=1).first()
for dep in station.departures(limit=5):
    print(f"  Train {dep.numero_treno} to {dep.destinazione} at {dep.comp_orario_partenza} (delay: {dep.ritardo} min)")

# Check live status of a specific train
try:
    status = client.trainstatuses.get(train_number="9611")
    print(f"Train {status.numero_treno}: {status.origine} → {status.destinazione}, delay {status.ritardo} min")
except TrainNotFound as exc:
    print(f"Train not found: {exc.train_number}")

# Browse current traffic alerts
for alert in client.alerts.list(limit=2):
    print(f"Alert: {alert.title} ({alert.date})")

# Search tickets Roma → Milano
result = client.trainsearches.search(origin_id="830008409", destination_id="830001700")
for sol in result.solutions[:3]:
    print(f"  {sol.origin} → {sol.destination}: departs {sol.departure_time}, duration {sol.duration}")

print("exercised: locations.search / stations.search / station.departures / trainstatuses.get / alerts.list / trainsearches.search")
All endpoints · 8 totalmissing one? ·

Autocomplete station name search for real-time data (ViaggiaTreno). Returns stations matching the given prefix with their IDs for use in departure/arrival board and train status endpoints. Each station has a short ID (e.g. 'S08409') usable with get_station_departures and get_station_arrivals.

Input
ParamTypeDescription
queryrequiredstringStation name prefix to search (e.g. 'Roma', 'Milano', 'Napoli')
Response
{
  "type": "object",
  "fields": {
    "data": "array of station objects with id, label, nomeBreve, nomeLungo",
    "status": "string, always 'success'"
  }
}

About the Trenitalia API

Station and Train Lookup

Two autocomplete endpoints handle identifier resolution before you query live data. get_station_autocomplete accepts a station name prefix and returns objects with id, nomeBreve, and nomeLungo fields — the id values (e.g. S08409 for Roma Termini) feed get_station_departures and get_station_arrivals. For ticket searches you need a different ID format: get_location_search returns 9-digit numeric IDs such as 830008409, along with displayName, multistation, and centroidId, which are required by search_trains. get_train_autocomplete resolves a train number to an origin_id and timestamp in milliseconds, both needed for precise status lookups.

Real-Time Train and Station Data

get_train_status returns a full picture of a running train: ritardo (delay in minutes), origine, destinazione, numeroTreno, and a fermate array listing each stop with its own timing and status. If you omit origin_id and timestamp, the endpoint auto-resolves them using the train number. Station boards are split into two endpoints: get_station_departures returns compOrarioPartenza, destinazione, ritardo, and categoriaDescrizione per train; get_station_arrivals mirrors that structure with origine and compOrarioArrivo.

Ticket Search and Traffic Alerts

search_trains takes an origin_id, destination_id, optional departure_time in ISO format (YYYY-MM-DDTHH:MM:SS.mmm), and optional passenger counts for adults and children. The response includes a searchId, cartId, and a solutions array with pricing, duration, and available service classes per train. get_traffic_info requires no parameters and returns current network disruption alerts with title, date, and content fields in Italian, sourced from the Infotraffico service.

Reliability & maintenanceVerified

The Trenitalia API is a managed, monitored endpoint for trenitalia.com — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when trenitalia.com 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 trenitalia.com 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.

Last verified
7d ago
Latest check
8/8 endpoints passing
Maintenance
Monitored & self-healing
Will this API break when the source site changes?+
It's built not to. Every endpoint is health-checked on a schedule with automated test probes. When the source site changes and a check fails, the API is automatically queued for repair and re-verified — that's the self-healing layer. Each API page shows when its endpoints were last verified. And because marketplace APIs are shared, any fix reaches everyone using it.
Is this an official API from the source site?+
No — Parse APIs are independent, managed REST wrappers over publicly available data. That is the point: where a site has no official API (or only a limited one), Parse gives you a maintained, monitored endpoint for that data and keeps it working as the site changes — so you get a stable contract over a source that never promised one.
Can I fix or extend this API myself if I need a new endpoint or field?+
Yes — and you don't have to wait on us. This API was generated by the Parse agent, which stays attached. Describe the change in plain English ("add an endpoint that returns reviews", "fix the price field") in the revise box on the API page or via the revise_api MCP tool, and the agent rebuilds it against the live site in minutes. Contributing the change back to the public API is free.
What happens if I call an endpoint that has an issue?+
Errors are machine-readable: a bad call returns a clean status with the list of available endpoints and a repair hint, so an agent (or you) can recover or trigger a fix instead of failing silently. Confirmed failures feed the automatic repair queue.
Common use cases
  • Display a live departure board for any Italian station using get_station_departures with real-time ritardo delay data.
  • Build a train delay tracker that polls get_train_status for ritardo and fermate stop-by-stop timing.
  • Integrate fare comparison into a travel app by querying search_trains with adult/child counts and a departure time.
  • Alert commuters to active service disruptions by surfacing get_traffic_info alerts filtered by title or date.
  • Resolve arbitrary station names to IDs programmatically using get_station_autocomplete before querying boards.
  • Look up whether a specific train number is currently running via get_train_autocomplete before fetching its status.
  • Power an arrival notification service by monitoring get_station_arrivals for a target origine and expected compOrarioArrivo.
Pricing & limitsSee full pricing →
TierPriceCredits/monthRate limit
Free$0/mo1005 req/min
Hobby$30/mo1,00020 req/min
Developer$100/mo5,000100 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.

Frequently asked questions
Does Trenitalia offer an official developer API?+
Trenitalia does not publish a documented public developer API or issue API keys for third-party access. The data surfaces used are the ViaggiaTreno real-time platform and the Lefrecce booking interface, both intended for end users.
What does `get_train_status` return, and do I always need to supply `origin_id` and `timestamp`?+
The endpoint returns ritardo (delay in minutes), origine, destinazione, numeroTreno, and a fermate array of stops with individual timing data. Both origin_id and timestamp are optional — if you omit them, the endpoint resolves them automatically from the train number using the autocomplete lookup. Supply them explicitly when you want to target a specific scheduled departure.
Does the API cover international trains or only domestic Italian routes?+
The endpoints reflect the Trenitalia network, which is primarily domestic Italian rail. Cross-border routes operated by or partnered with Trenitalia may appear in results, but full international coverage (e.g. Austrian or French legs) is not guaranteed. You can fork this API on Parse and revise it to add an endpoint targeting a different European rail data source.
Does the API support searching trains for a past date or historical schedule data?+
The station board endpoints (get_station_departures, get_station_arrivals) return departures and arrivals around the current time and do not accept a date parameter. search_trains accepts a future departure_time. Historical schedule data and past departure boards are not currently covered. You can fork this API on Parse and revise it to add the missing historical endpoint if that surface becomes accessible.
Are ticket prices returned in `search_trains` responses, and which passenger types are supported?+
Yes — the solutions array in the search_trains response includes pricing alongside duration and service class details per train. Passenger counts are configurable via the adults and children integer parameters. Senior, loyalty, or regional discount fares beyond the adult/child split are not exposed as separate parameters in the current endpoint.
Page content last updated . Spec covers 8 endpoints from trenitalia.com.
Related APIs in TravelSee all →
rfi.it API
Check real-time train schedules and station information across Italy's railway network, search for stations, and get live alerts about delays and service disruptions. Monitor train circulation status and access detailed station mappings to plan your journeys efficiently.
thetrainline.com API
Search UK train stations and find the cheapest fares across date ranges, then generate direct booking links to complete your purchase on Trainline.com. Get real-time journey information to compare prices and book your tickets in seconds.
railyatri.in API
Search trains between stations and get real-time information including live train status, timetables, seat availability, and PNR confirmation details. Find the perfect journey by autocompleting station and train names while checking current availability and train schedules.
amtrak.com API
Search for Amtrak trains across stations, compare fares, and discover discounts to plan your rail journey with current pricing and availability. Get detailed train information, autocomplete station names, and find the cheapest routes for your travel dates.
trainline.eu API
Search for train stations and routes across the UK and Europe, then find and compare available journeys with schedules and pricing. Book your ideal train trip by accessing real-time travel options directly from Trainline.com.
nationalrail.co.uk API
Check live train departure and arrival times at UK stations, search for specific stations, and get real-time service disruption alerts. Stay informed about rail service delays and changes to plan your journeys efficiently.
bahn.com API
Search German train schedules and stations, find connections between destinations, and compare ticket prices across Deutsche Bahn routes. Get real-time station information and transit association details to plan your train journey efficiently.
enquiry.indianrail.gov.in API
Search for trains between Indian stations, check schedules, and look up station details to plan your rail journeys. Get real-time train information with support for captcha-protected searches to ensure reliable access to Indian Railways data.