# Trenitalia — Wrapped API

> **You are on:** `https://api.paywithlocus.com/api` | [llms.txt](https://paywithlocus.com/llms.txt) | [docs](https://docs.paywithlocus.com)
>
> Locus runs on multiple environments -- make sure every URL you call matches your expected environment.
> | Environment | Landing | API | Docs |
> |---|---|---|---|
> | Production | paywithlocus.com | api.paywithlocus.com | docs.paywithlocus.com |
> | Beta | beta.paywithlocus.com | api.beta.paywithlocus.com | docs.paywithlocus.com |
> | Stage | stage.paywithlocus.com | api.stage.paywithlocus.com | docs.paywithlocus.com |
>
> If the API URL above doesn't match your expected environment, re-fetch this file from the correct domain.

> Search for trains across Italy, check real-time train status and delays, view station departure and arrival boards, and find available tickets all in one place. Get live traffic information and detailed train itineraries to plan your journey with complete visibility into schedules and service disruptions.

**Category:** Travel | **Website:** [trenitalia.com/](https://trenitalia.com/) | **Docs:** [parse.bot/marketplace/2999b409-19cd-43d1-af30-1fca66123d65/trenitalia-com-api](https://parse.bot/marketplace/2999b409-19cd-43d1-af30-1fca66123d65/trenitalia-com-api)

Pay-per-use API proxy. Each call is automatically billed to your wallet in USDC.

## Access

**Base URL:** `https://api.paywithlocus.com/api/wrapped/parse-trenitalia-com-api-2999b409/`
**Auth:** `Authorization: Bearer <LOCUS_API_KEY>`

## Endpoints

### get_location_search

Search for station locations and 9-digit IDs for ticket search (Lefrecce). Returns locations with numeric IDs needed for the search_trains endpoint. Each location includes timezone, multistation flag, and centroidId.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `query` | string | Yes | Station name to search (e.g. 'Roma', 'Milano', 'Napoli') |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-trenitalia-com-api-2999b409/get_location_search \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"<string>"}'
```

### get_station_arrivals

Get the arrival board for a specific station. Returns currently scheduled arrivals around the current time with real-time delay information, platform assignments, and train categories.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `station_id` | string | Yes | Station ID from get_station_autocomplete (e.g. 'S08409' for Roma Termini, 'S01700' for Milano Centrale) |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-trenitalia-com-api-2999b409/get_station_arrivals \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"station_id":"<string>"}'
```

### get_station_autocomplete

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.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `query` | string | Yes | Station name prefix to search (e.g. 'Roma', 'Milano', 'Napoli') |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-trenitalia-com-api-2999b409/get_station_autocomplete \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"<string>"}'
```

### get_station_departures

Get the departure board for a specific station. Returns currently scheduled departures around the current time with real-time delay information, platform assignments, and train categories.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `station_id` | string | Yes | Station ID from get_station_autocomplete (e.g. 'S08409' for Roma Termini, 'S01700' for Milano Centrale) |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-trenitalia-com-api-2999b409/get_station_departures \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"station_id":"<string>"}'
```

### get_traffic_info

Retrieve current traffic and disruption alerts from the Infotraffico service. Returns Italian-language alerts about service disruptions, delays, strikes, and network status. Content is updated throughout the day.

**Estimated cost:** Metered

_No parameters required._

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-trenitalia-com-api-2999b409/get_traffic_info \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

### get_train_autocomplete

Look up a train by number to get origin station ID and departure timestamp. Returns matches for currently scheduled trains. Returns an empty array if the train number is not found or not currently running.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `train_number` | string | Yes | Train number to look up (e.g. '9611', '9600', '2000') |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-trenitalia-com-api-2999b409/get_train_autocomplete \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"train_number":"<string>"}'
```

### get_train_status

Get real-time status, delay, and full itinerary for a specific train. If only train_number is provided, auto-resolves origin_id and timestamp via autocomplete lookup. Returns detailed stop-by-stop information including actual vs scheduled times and platform changes.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `origin_id` | string | No | Origin station ID from get_train_autocomplete (e.g. 'S00219'). Auto-resolved if omitted. |
| `timestamp` | string | No | Departure timestamp in milliseconds from get_train_autocomplete. Auto-resolved if omitted. |
| `train_number` | string | Yes | Train number (e.g. '9516', '9600') |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-trenitalia-com-api-2999b409/get_train_status \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"origin_id":"<string>","timestamp":"<string>","train_number":"<string>"}'
```

### search_trains

Search for train solutions and prices between two stations. Returns available trains with pricing across service classes (Standard, Premium, Business, Executive), duration, and CO2 emissions. Uses the Lefrecce booking API. Prices include Super Economy, Economy, and Base fare tiers.

**Estimated cost:** Metered

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `adults` | integer | No | Number of adult passengers. |
| `children` | integer | No | Number of child passengers. |
| `departure_time` | string | No | Departure time in ISO format YYYY-MM-DDTHH:MM:SS.mmm (e.g. '2026-06-25T08:00:00.000'). Omitting defaults to 14 days from now at 08:00. |
| `destination_id` | string | Yes | Destination station 9-digit ID from get_location_search (e.g. '830001700' for Milano Centrale) |
| `origin_id` | string | Yes | Origin station 9-digit ID from get_location_search (e.g. '830008409' for Roma Termini) |

```bash
curl -X POST https://api.paywithlocus.com/api/wrapped/parse-trenitalia-com-api-2999b409/search_trains \
  -H "Authorization: Bearer YOUR_LOCUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"adults":"<integer>","children":"<integer>","departure_time":"<string>","destination_id":"<string>","origin_id":"<string>"}'
```
