# Trenitalia Train Ticket and Connection Scraper (`jindrich.bar/trenitalia-ticket-scraper`) Actor

Scrape live Trenitalia train connections, schedules, ticket prices, transfers, delays, and fares across Italy and Europe. Extract structured Trenitalia timetable data for travel apps, price monitoring, analytics, and AI agents.

- **URL**: https://apify.com/jindrich.bar/trenitalia-ticket-scraper.md
- **Developed by:** [Jindřich Bär](https://apify.com/jindrich.bar) (community)
- **Categories:** Travel, Developer tools, Automation
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

from $1.50 / 1,000 trips

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Trenitalia / LeFrecce train tickets & connections scraper

Search Trenitalia train connections and ticket prices across Italy (and the international routes it
sells, such as Munich–Rome), and get back a structured dataset of routes, times, transfers, train
types, and per-class fares — ready to plug into spreadsheets, databases, dashboards, or AI agents.

Pulls live data from the official Trenitalia ticket shop ([lefrecce.it](https://www.lefrecce.it/)),
so you always get the same trains, prices, and schedules a passenger would see when booking online —
including **Frecciarossa**, **Frecciargento**, **Frecciabianca**, **Intercity**, and **Regionale**
services.

### What you can do with it

- **Compare ticket prices** between stations in real time — Roma–Milano, Roma–Napoli, Firenze–Venezia,
  and any other route the Trenitalia timetable covers, including high-speed Frecce services and
  cross-border connections.
- **See every fare class and offer** per train — STANDARD, PREMIUM, BUSINESS, EXECUTIVE — with the
  cheapest BASE / Economy / Super Economy price and remaining availability for each.
- **Monitor fares over time** by scheduling the actor to run daily / hourly and writing the results to
  your own datastore.
- **Build a travel-planning assistant** — feed the JSON output directly into an LLM agent that answers
  "what's the cheapest Frecciarossa from Rome to Milan tomorrow morning" or "is there a direct train
  from Florence to Venice this afternoon."

Typical use cases: travel comparison sites, price-monitoring tools, business-trip planners, train
spotters, journalists working on transport coverage, and AI agents that need a structured rail-data
source for Italy.

### Input

| Field | Required | Default | Description |
| --- | --- | --- | --- |
| `from` | yes | — | Departure station or city (e.g. `"Roma Termini"`, `"Milano Centrale"`, `"Firenze"`) |
| `to` | yes | — | Destination station or city |
| `date` | no | today | Departure date (date picker, ISO `YYYY-MM-DD`) |
| `time` | no | now | Departure time (`HH:MM`, 24-hour, Italy local time) |
| `adults` | no | `1` | Number of adult passengers (1–6) |
| `children` | no | `0` | Number of child passengers (0–6) |
| `maxResults` | no | `20` | Maximum number of connections to push to the dataset (1–200) |

Station names are resolved against Trenitalia's own **location autocomplete**, so partial names work:
`"Roma"` resolves to the multi-station "Roma ( Tutte Le Stazioni )" (all Rome stations), while
`"Roma Termini"` pins the single station. The actor prefers an exact (case-insensitive) match and
otherwise takes Trenitalia's top-ranked suggestion.

#### Good to know

A few things worth knowing about the results:

- **Some connections have no price.** Mixed itineraries that involve another operator's reservation
  system (or certain Intercity/Regionale transfers) come back with `priceAmount: null` and an
  informational note from Trenitalia — the schedule and trains are still returned.
- **Regionale legs may have no per-class fare grid.** Regional trains are flat-fare, so their `legs`
  can have an empty `offers` array even though the connection's overall `priceAmount` is set.
- **Transfers are supported.** Unlike a direct-only timetable, Trenitalia builds multi-leg itineraries;
  `transfers` and `requiresTransfer` reflect the number of train changes, and each leg is listed
  separately under `legs`.

### Output

Each dataset item is one connection (a "solution"):

```jsonc
{
  "id": "xc36fb263-fc28-4b9d-9b7d-58b9d76f957b",
  "from": "Roma Termini",
  "to": "Napoli Centrale",
  "fromId": "830008409",
  "toId": "830009218",
  "departure": "2026-06-18T08:05:00.000+02:00",
  "arrival": "2026-06-18T09:18:00.000+02:00",
  "durationMinutes": 73,
  "transfers": 0,
  "requiresTransfer": false,
  "priceAmount": 34.9,
  "priceCurrency": "EUR",
  "status": "SALEABLE",
  "trainCategories": ["Frecciarossa"],
  "legs": [
    {
      "trainNumber": "9608",
      "trainCategory": "Frecciarossa",
      "acronym": "FR",
      "denomination": "FRECCIAROSSA",
      "from": "Roma Termini",
      "to": "Napoli Centrale",
      "departure": "2026-06-18T08:05:00.000+02:00",
      "arrival": "2026-06-18T09:18:00.000+02:00",
      "durationMinutes": 73,
      "offers": [
        {
          "serviceId": 30005,
          "serviceName": "STANDARD",
          "offerName": "Super Economy",
          "priceAmount": 34.9,
          "priceCurrency": "EUR",
          "availableAmount": 12,
          "status": "SALEABLE"
        }
      ]
    }
  ]
}
````

| Field | Description |
| --- | --- |
| `id` | Trenitalia solution identifier |
| `from` / `to` | Connection origin / destination station names |
| `fromId` / `toId` | Trenitalia location ids used for the search |
| `departure` / `arrival` | ISO 8601 datetimes with Italy's local offset |
| `durationMinutes` | Total journey duration in minutes |
| `transfers` / `requiresTransfer` | Number of train changes (0 = direct) / whether a change is needed |
| `priceAmount` / `priceCurrency` | Cheapest fare for the connection (`EUR`), or `null` if no bookable offer |
| `status` | Bookability status, e.g. `SALEABLE` |
| `trainCategories` | Distinct train categories on the connection, e.g. `["Frecciarossa"]` |
| `legs[]` | Per-train legs, each with its train, times, duration, and `offers[]` |
| `legs[].offers[]` | Per-service-class fares: `serviceName` (STANDARD/PREMIUM/BUSINESS/EXECUTIVE), `offerName` (BASE/Economy/Super Economy), `priceAmount`, `availableAmount`, `status` |

### Need a different data source?

If you're scraping connections across multiple operators, check our companion actors:

- [**ÖBB ticket scraper**](https://apify.com/jindrich.bar/oebb-ticket-scraper) — Austrian and Central-European rail timetable and ticket prices.
- [**TCDD ticket scraper**](https://apify.com/jindrich.bar/tcdd-ticket-scraper) — Turkish State Railways timetable and ticket prices.
- [**Deutsche Bahn ticket scraper**](https://apify.com/jindrich.bar/deutsche-bahn-ticket-scraper) — German and European rail timetable and ticket prices.
- [**České dráhy connection scraper**](https://apify.com/jindrich.bar/ceske-drahy-connections) — Czech rail timetable and ticket prices.
- [**Flixbus connection scraper**](https://apify.com/jindrich.bar/flixbus-connections) — long-distance bus routes across Europe and the US.

All these actors emit a comparable schema (`from`, `to`, `departure`, `arrival`, `price`, leg-level
breakdown), so an aggregator agent can merge their outputs into a single multi-modal travel search.

# Actor input Schema

## `from` (type: `string`):

Departure station or city name (e.g. "Roma Termini", "Milano Centrale", "Firenze"). Matched against Trenitalia's official location autocomplete.

## `to` (type: `string`):

Destination station or city name.

## `date` (type: `string`):

Departure date (YYYY-MM-DD). Leave empty to use today.

## `time` (type: `string`):

Time in HH:MM (24h) format, Italy local time. Leave empty to use the current time.

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

Number of adult passengers.

## `children` (type: `integer`):

Number of child passengers.

## `maxResults` (type: `integer`):

Maximum number of journeys to push to the dataset (paged 10 per request).

## Actor input object example

```json
{
  "from": "Roma Termini",
  "to": "Milano Centrale",
  "adults": 1,
  "children": 0,
  "maxResults": 20
}
```

# Actor output Schema

## `journeys` (type: `string`):

Default dataset items — one entry per connection, with legs, transfer count and fare offers.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("jindrich.bar/trenitalia-ticket-scraper").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("jindrich.bar/trenitalia-ticket-scraper").call(run_input=run_input)

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

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

```

## CLI example

```bash
echo '{}' |
apify call jindrich.bar/trenitalia-ticket-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=jindrich.bar/trenitalia-ticket-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Trenitalia Train Ticket and Connection Scraper",
        "description": "Scrape live Trenitalia train connections, schedules, ticket prices, transfers, delays, and fares across Italy and Europe. Extract structured Trenitalia timetable data for travel apps, price monitoring, analytics, and AI agents.",
        "version": "0.0",
        "x-build-id": "qfkFr9YJxf3nOGZd4"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/jindrich.bar~trenitalia-ticket-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-jindrich.bar-trenitalia-ticket-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/jindrich.bar~trenitalia-ticket-scraper/runs": {
            "post": {
                "operationId": "runs-sync-jindrich.bar-trenitalia-ticket-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/jindrich.bar~trenitalia-ticket-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-jindrich.bar-trenitalia-ticket-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "from",
                    "to"
                ],
                "properties": {
                    "from": {
                        "title": "From station",
                        "type": "string",
                        "description": "Departure station or city name (e.g. \"Roma Termini\", \"Milano Centrale\", \"Firenze\"). Matched against Trenitalia's official location autocomplete.",
                        "default": "Roma Termini"
                    },
                    "to": {
                        "title": "To station",
                        "type": "string",
                        "description": "Destination station or city name.",
                        "default": "Milano Centrale"
                    },
                    "date": {
                        "title": "Departure date",
                        "type": "string",
                        "description": "Departure date (YYYY-MM-DD). Leave empty to use today."
                    },
                    "time": {
                        "title": "Departure time",
                        "pattern": "^\\d{1,2}:\\d{2}$",
                        "type": "string",
                        "description": "Time in HH:MM (24h) format, Italy local time. Leave empty to use the current time."
                    },
                    "adults": {
                        "title": "Adults",
                        "minimum": 1,
                        "maximum": 6,
                        "type": "integer",
                        "description": "Number of adult passengers.",
                        "default": 1
                    },
                    "children": {
                        "title": "Children",
                        "minimum": 0,
                        "maximum": 6,
                        "type": "integer",
                        "description": "Number of child passengers.",
                        "default": 0
                    },
                    "maxResults": {
                        "title": "Max results",
                        "minimum": 1,
                        "maximum": 200,
                        "type": "integer",
                        "description": "Maximum number of journeys to push to the dataset (paged 10 per request).",
                        "default": 20
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
