# 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 for Locus Pro. Each call burns credits from your workspace balance.

## Access

**Base URL:** `https://api.paywithlocus.com/api/wrapped/credits/trenitalia/`
**Auth:** `Authorization: Bearer <LOCUS_CREDITS_SECRET_KEY>` (an `lcr_` secret key or a scoped `lcac_` agent credential)
**Required header:** `Idempotency-Key: <fresh UUID per call>`. A retry with the same key replays the stored result without a new charge.
**Response:** the provider response after any endpoint-specific normalization. `X-Locus-Credits-Charged` carries the charge and `X-Locus-Credits-Balance` the remaining balance. Insufficient credits return `402` before the provider is called.
**Pricing:** estimated costs below are USD. Locus debits the credit equivalent at your workspace rate.

Full call contract: https://docs.paywithlocus.com/api-reference/introduction

> Using a Pay With Locus wallet key (`claw_` prefix)? Wallet routes are documented separately: https://docs.paywithlocus.com/wrapped-apis/for-agents

## 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/credits/trenitalia/get-location-search \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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/credits/trenitalia/get-station-arrivals \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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/credits/trenitalia/get-station-autocomplete \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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/credits/trenitalia/get-station-departures \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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/credits/trenitalia/get-traffic-info \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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/credits/trenitalia/get-train-autocomplete \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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/credits/trenitalia/get-train-status \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -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/credits/trenitalia/search-trains \
  -H "Authorization: Bearer $LOCUS_CREDITS_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"adults":"<integer>","children":"<integer>","departure_time":"<string>","destination_id":"<string>","origin_id":"<string>"}'
```

## Next steps

- [All wrapped API providers](https://paywithlocus.com/wapi/index.md): pick another provider.
- [Find and call tools](https://paywithlocus.com/agent/tools.md): price ceilings, async results, and errors.
- [Credits and billing](https://paywithlocus.com/agent/billing.md): what a call costs and how to add credits.
- [Agent docs index](https://paywithlocus.com/agent/index.md): every Locus agent page.