# SNCF/Transilien Schedules - Official API (`egarian/sncf-france-schedules`) Actor

Official SNCF/Transilien schedules and real-time traffic from the SNCF API (Navitia, api.sncf.com). TGV, TER, Intercités, Transilien, RER. Journey planning, departures, line info. Station names, UIC codes or Navitia IDs accepted. Perfect for mobility apps, journey planners, logistics.

- **URL**: https://apify.com/egarian/sncf-france-schedules.md
- **Developed by:** [Loïc Rossi](https://apify.com/egarian) (community)
- **Categories:** Travel
- **Stats:** 3 total users, 2 monthly users, 76.9% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 journey results

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

## SNCF Trains (France) — Schedules & Real-time — Official API

Train journeys, departure boards and lines for the French rail network, from the **official SNCF API** (Navitia-powered `api.sncf.com`): TGV, TER, Intercités and Transilien.

### What it does

- **Journeys between two stations** — best itineraries with transfers, duration and CO₂ emissions
- **Next departures from a station** — scheduled and real-time estimated times, platform, direction
- **Lines and routes** — line codes, colors, modes and the routes they serve
- **Station names or IDs accepted** — names are resolved automatically via the places endpoint; pure UIC codes are expanded to full Navitia ids
- Real-time data included when available (`includeRealtime`)
- Output verbosity: `minimal`, `standard`, `full` (full includes the raw Navitia payload)

### Input example

```json
{
  "fromStation": "Paris Gare de Lyon",
  "toStation": "Lyon Part-Dieu",
  "date": "2026-10-20",
  "maxResults": 10,
  "includeRealtime": true,
  "outputFields": "standard"
}
```

Main input fields: `fromStation`, `toStation`, `line`, `date`, `datetime`, `maxResults`, `includeRealtime`, `outputFields`.

### Output example (journey, standard)

```json
{
  "source": "sncf",
  "journeyId": "journey-id",
  "departure": {
    "station": "Paris Gare de Lyon",
    "uicCode": "stop_area:OCE:SA:87686006",
    "scheduledTime": "20261020T100400",
    "realTime": "20261020T100400"
  },
  "arrival": {
    "station": "Lyon Part-Dieu",
    "uicCode": "stop_area:OCE:SA:87723197",
    "scheduledTime": "20261020T120400",
    "realTime": "20261020T120400"
  },
  "duration": 7200,
  "transfers": 0,
  "co2Emissions": 1200,
  "sections": [
    { "type": "public_transport", "mode": "train", "line": "TGV INOUI", "lineCode": "TGV", "from": "Paris Gare de Lyon", "to": "Lyon Part-Dieu" }
  ]
}
```

Departure records expose `stopArea`, `uicCode`, `line`, `direction`, `scheduledDeparture`, `realTimeDeparture`, `platform`.

### Data source

- **SNCF Open Data API** (`api.sncf.com/v1/coverage/sncf`) — official SNCF schedules and real-time data for French trains

### Notes

- The SNCF API uses a **token** (free developer tier up to 150,000 requests/month, 5,000/day). The Actor runs with its configured token — you don't need your own; advanced users can override it with the `SNCF_API_KEY` environment variable. Free tokens can be requested at [numerique.sncf.com](https://numerique.sncf.com/startup/api/token-developpeur/).
- Times are returned in SNCF/Navitia format (`YYYYMMDDTHHMMSS`, Paris time).

# Actor input Schema

## `fromStation` (type: `string`):

Departure station name or UIC code

## `toStation` (type: `string`):

Arrival station name or UIC code

## `line` (type: `string`):

Line code (e.g., TGV, TER, RER_A, Transilien_L)

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

Journey date

## `datetime` (type: `string`):

Specific departure datetime

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

Maximum journeys/departures to return

## `includeRealtime` (type: `boolean`):

Include estimated/real-time times

## `outputFields` (type: `string`):

Output verbosity

## Actor input object example

```json
{
  "fromStation": "Paris Gare de Lyon",
  "toStation": "",
  "line": "",
  "date": "",
  "datetime": "",
  "maxResults": 50,
  "includeRealtime": true,
  "outputFields": "standard"
}
```

# Actor output Schema

## `results` (type: `string`):

Journey plans or departures from the SNCF/Navitia API. One item per journey or departure row.

# 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("egarian/sncf-france-schedules").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("egarian/sncf-france-schedules").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 '{}' |
apify call egarian/sncf-france-schedules --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,egarian/sncf-france-schedules"
        }
    }
}
```

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/5PwTh8kcpUP6DfLZ0/builds/xJMKGOF83f39F3zM9/openapi.json
