# Trenitalia & Italo Train Prices (+ OUIGO Spain) (`polyglot-data/trenitalia-italo-train-prices`) Actor

Live ticket prices and timetables from Trenitalia, Italo and OUIGO Spain in one dataset. Compare Frecciarossa and Italo on the same route, cheapest train flagged. Type city names and a date.

- **URL**: https://apify.com/polyglot-data/trenitalia-italo-train-prices.md
- **Developed by:** [Polyglot Data](https://apify.com/polyglot-data) (community)
- **Categories:** Travel, E-commerce
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Trenitalia & Italo Train Prices (+ OUIGO Spain)

![Trenitalia, Italo and OUIGO Spain train prices: example output](https://api.apify.com/v2/key-value-stores/5noGfeHp3GYPBOMYQ/records/trains-banner.png?signature=1qsMfhSaeablj0QaOfzhe)

Live ticket prices and timetables from **Trenitalia** and **Italo** for the same route and date, in one dataset, with the cheapest train flagged. **OUIGO Spain** is included for Madrid, Barcelona, Valencia, Seville and the rest of its network. Type city names and a date. The actor asks every operator that serves both cities.

- 🚄 **Frecciarossa vs Italo side by side**: Milan–Rome, Rome–Naples, Turin–Venice and every other route both run. One row per train with departure, arrival, duration, train number and price.
- 🏙️ **Just type the city**: "Milan" or "Milano" searches every station of the city (Centrale, Porta Garibaldi, Rogoredo...). Type a station name to search only that station.
- 💶 **Real prices, not estimates**: the cheapest fare on sale right now, for 1 to 9 adults, read from the operators' own booking systems.
- 🏷️ **Cheapest train flagged** across all operators of the route.
- ⚡ **Fast and light**: no browser, so runs take seconds to a minute per route and cost very little.
- 💸 **Pay per train**: $1 per 1,000 trains. Error items are free.

### 📦 What data you get

One item per train.

| Field | Example | Description |
|---|---|---|
| `operator` | Italo | Trenitalia, Italo or OUIGO Spain |
| `from`, `to`, `date` | Milan, Rome, 2027-01-15 | Your input (date defaults to two weeks from today) |
| `fromStation`, `toStation` | Milano Centrale, Roma Termini | Stations of this train |
| `departure`, `arrival` | 2027-01-15T06:04 | Local time |
| `durationMinutes` | 179 | Journey time |
| `trains` | \["FR 9511"] | Train number(s) |
| `changes` | 0 | 0 = direct |
| `isHighSpeed` | true | Frecciarossa / Frecciargento / Frecciabianca, Italo, OUIGO |
| `priceTotal` | 49.8 | Cheapest fare on sale, all adults, EUR |
| `pricePerAdult` | 24.9 | priceTotal / adults |
| `currency`, `adults` | EUR, 2 | |
| `isCheapestOnRoute` | true | Cheapest train(s) of this route and date |
| `bookingUrl` | https://www.italotreno.com/ | Where to book |
| `scrapedAt` | 2026-11-11T21:13:27+00:00 | When the price was read |

#### Example item

```json
{
  "operator": "Trenitalia",
  "from": "Milan",
  "to": "Rome",
  "date": "2026-12-15",
  "fromStation": "Milano Centrale",
  "toStation": "Roma Termini",
  "departure": "2026-12-15T05:09",
  "arrival": "2026-12-15T09:10",
  "durationMinutes": 241,
  "trains": ["FR 9505"],
  "changes": 0,
  "isHighSpeed": true,
  "priceTotal": 75.8,
  "pricePerAdult": 37.9,
  "currency": "EUR",
  "adults": 2,
  "isCheapestOnRoute": false,
  "bookingUrl": "https://www.trenitalia.com/",
  "scrapedAt": "2026-11-11T21:13:27+00:00"
}
```

#### ⚠️ Error items

When a route gives no trains you get one free item that says why:

| `error` | Meaning |
|---|---|
| `ROUTE_NOT_SERVED` | No selected operator sells tickets between these cities. Check the spelling. |
| `NO_TRAINS` | Nothing on sale that day: sold out, or tickets not on sale yet. |
| `OPERATOR_ERROR` | One operator did not answer. The other operators' trains are still saved. |
| `INVALID_ROUTE`, `DATE_IN_PAST`, `NO_ROUTES` | Fix the input. |

### 🚀 How to use

1. Add one or more **routes**:

```json
{
  "routes": [
    {"from": "Milan", "to": "Rome"},
    {"from": "Florence", "to": "Venice", "date": "2027-01-16"},
    {"from": "Madrid", "to": "Barcelona", "date": "2027-01-20"}
  ],
  "adults": 2
}
```

`date` is optional: without it the actor searches two weeks from today.
2\. Optional: pick the **operators** and the number of **adults**.
3\. Click **Start**. Download the results as JSON, CSV or Excel, or read them through the API.

### 🎯 Use cases

- **Price tracking**: schedule a daily run and watch how a route's fares move as the date gets closer.
- **Travel apps and trip planners**: real timetables and prices for Italian high-speed rail in your product.
- **Fare comparison**: Trenitalia vs Italo on the same route and day, one table.
- **Market research**: price levels by route, time of day and how far ahead you book.

### 💰 Pricing

**$0.001 per train saved** ($1 per 1,000 trains) plus a tiny start fee. A busy route such as Milan–Rome has about 100 trains a day across Trenitalia and Italo, so about $0.10. Error items are never charged. Set a maximum cost per run to cap spending.

### ❓ FAQ

**Which routes?** Every route Trenitalia sells (all of Italy plus the Paris–Lyon–Turin–Milan Frecciarossa), every Italo route, and OUIGO Spain. Renfe and Iryo are not included yet. Ask in the Issues tab if you need them.

**Is the price per person?** `priceTotal` is for all adults. `pricePerAdult` divides it.

**Which fare is it?** The cheapest fare on sale for that train at the moment of the run. Fares change during the day.

**Connections?** Trenitalia trips with changes are included with the full price. Italo results are direct trains only.

**Children, seniors, discount cards?** Not yet: adults only.

### ⚖️ Legal

The actor reads the public timetables and fares that the operators show to anyone on their websites. It does not log in or buy tickets. You are responsible for using the data in line with applicable laws and the terms of the sites involved.

# Actor input Schema

## `routes` (type: `array`):

One object per trip: {"from": "Milan", "to": "Rome", "date": "2026-12-20"}. City names in English or the local language (Milano, Roma, Firenze, Napoli, Madrid, Barcelona...) search all stations of the city. A station name ("Roma Tiburtina") searches only that station. Date as YYYY-MM-DD; without a date the actor searches two weeks from today.

## `operators` (type: `array`):

Operators to ask. Each route is sent only to the operators that serve both cities.

## `adults` (type: `integer`):

Number of adult passengers. priceTotal is for all of them; pricePerAdult is priceTotal / adults.

## `proxy` (type: `object`):

Not needed in normal use. Turn it on only if an operator starts returning OPERATOR_ERROR.

## Actor input object example

```json
{
  "routes": [
    {
      "from": "Milan",
      "to": "Rome"
    },
    {
      "from": "Madrid",
      "to": "Barcelona"
    }
  ],
  "operators": [
    "trenitalia",
    "italo",
    "ouigo"
  ],
  "adults": 1,
  "proxy": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `trains` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "routes": [
        {
            "from": "Milan",
            "to": "Rome"
        },
        {
            "from": "Madrid",
            "to": "Barcelona"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("polyglot-data/trenitalia-italo-train-prices").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "routes": [
        {
            "from": "Milan",
            "to": "Rome",
        },
        {
            "from": "Madrid",
            "to": "Barcelona",
        },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("polyglot-data/trenitalia-italo-train-prices").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "routes": [
    {
      "from": "Milan",
      "to": "Rome"
    },
    {
      "from": "Madrid",
      "to": "Barcelona"
    }
  ]
}' |
apify call polyglot-data/trenitalia-italo-train-prices --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,polyglot-data/trenitalia-italo-train-prices"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ByzqQyapoBrR7hPMu/builds/IvvYQ4JEBfyo6gDVx/openapi.json
