# SNCF Train Price Scraper — TGV INOUI, OUIGO, TER, Intercités (`dr1ms/sncf-train-price-scraper`) Actor

Scrape French train schedules and official price ranges from SNCF. Returns structured JSON with journeys, durations, segments, CO2 emissions, and official fare brackets. Covers TGV INOUI, OUIGO, TER, and Intercités.

- **URL**: https://apify.com/dr1ms/sncf-train-price-scraper.md
- **Developed by:** [Adrien](https://apify.com/dr1ms) (community)
- **Categories:** Travel, Integrations, Automation
- **Stats:** 7 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

## 🚄 SNCF Train Price Scraper — TGV INOUI, OUIGO, TER, Intercités

Retrieve French train schedules and official fare brackets for any route in France. Covers TGV INOUI, OUIGO, TER, Intercités, Lyria, and Eurostar via the official SNCF API.

### What data do you get?

For each journey found, the scraper returns:

- **Schedule**: departure/arrival times, duration, number of transfers
- **Train details**: carrier (TGV INOUI, OUIGO, TER...), train number, segments with connections
- **Official fare brackets**: min/max price from SNCF Open Data (e.g. €16–€99 for Paris→Lyon)
- **CO2 emissions**: grams of CO2 per journey (official SNCF data)
- **Metadata**: search date, days before departure, data attribution

> ⚠️ **Note on pricing**: The SNCF API provides schedules and official fare ranges, not real-time dynamic ticket prices. The `official_min_price_eur` and `official_max_price_eur` fields give you the official tariff brackets for each origin-destination pair.

### How to get an SNCF API key

1. Go to [numerique.sncf.com/startup/api](https://numerique.sncf.com/startup/api)
2. Create a free account
3. You get 90,000 API calls/month for free
4. Copy your API key and paste it in the `sncfApiKey` field

### Example input

```json
{
  "routes": [
    { "from": "Paris", "to": "Lyon", "date": "2026-04-15" },
    { "from": "Marseille", "to": "Bordeaux" }
  ],
  "sncfApiKey": "YOUR_SNCF_API_KEY",
  "maxResults": 10,
  "enrichWithOfficialFares": true
}
```

If `date` is omitted, tomorrow's date is used automatically.

### Example output

```json
{
  "departure_station": "Paris - Gare de Lyon - Hall 1 & 2",
  "departure_city": "Paris",
  "arrival_station": "Lyon Part Dieu",
  "arrival_city": "Lyon",
  "departure_time": "2026-04-15T10:00:00.000Z",
  "arrival_time": "2026-04-15T11:56:00.000Z",
  "duration_minutes": 116,
  "price_eur": null,
  "official_min_price_eur": 16,
  "official_max_price_eur": 99,
  "carrier": "TGV INOUI",
  "train_type": "Train grande vitesse",
  "train_number": "6607",
  "transport_mode": "train",
  "nb_transfers": 0,
  "co2_grams": 923,
  "segments": [
    {
      "departure_station": "Paris - Gare de Lyon - Hall 1 & 2",
      "arrival_station": "Lyon Part Dieu",
      "carrier": "TGV INOUI",
      "train_number": "6607",
      "duration_minutes": 116
    }
  ],
  "source": "sncf",
  "search_date": "2026-04-15",
  "data_attribution": "Données tarifs et gares : SNCF Open Data (ressources.data.sncf.com) — Licence ODbL"
}
```

### Supported cities

The scraper supports **any French city or station** served by SNCF. Popular routes are pre-mapped for instant resolution:

Paris, Lyon, Marseille, Bordeaux, Lille, Toulouse, Nantes, Strasbourg, Rennes, Montpellier, Nice, Grenoble, Annecy, Dijon

For other cities, the scraper automatically resolves station names via the SNCF API.

### Use cases

- **Travel comparison apps**: get train schedules and fare ranges for route planning
- **Business travel tools**: find fastest connections between French cities
- **Price monitoring**: track official fare brackets over time
- **Data journalism**: analyze French rail network coverage and pricing
- **Academic research**: CO2 emissions data for transport studies

### Data sources & attribution

This scraper uses the official SNCF Navitia API for schedules and the SNCF Open Data portal (ressources.data.sncf.com) for fare brackets and station data, published under the Open Database License (ODbL).

### Rate limits

The scraper respects SNCF API rate limits with configurable delays between requests (default: 1 second). The free SNCF API tier allows 90,000 calls/month.

# Actor input Schema

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

List of routes as JSON objects with 'from', 'to', and optional 'date' (YYYY-MM-DD). Example: \[{"from": "Paris", "to": "Lyon", "date": "2026-04-15"}]

## `sncfApiKey` (type: `string`):

Your SNCF API key from https://www.digital.sncf.com/startup/api

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

Maximum number of journeys to return per route

## `enrichWithOfficialFares` (type: `boolean`):

Cross-reference results with SNCF Open Data official fare brackets

## `delayBetweenRequestsMs` (type: `integer`):

Delay between API requests to respect rate limits

## Actor input object example

```json
{
  "routes": [
    {
      "from": "Paris",
      "to": "Lyon"
    }
  ],
  "maxResults": 20,
  "enrichWithOfficialFares": true,
  "delayBetweenRequestsMs": 1000
}
```

# Actor output Schema

## `results` (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": "Paris",
            "to": "Lyon"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dr1ms/sncf-train-price-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 = { "routes": [{
            "from": "Paris",
            "to": "Lyon",
        }] }

# Run the Actor and wait for it to finish
run = client.actor("dr1ms/sncf-train-price-scraper").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": "Paris",
      "to": "Lyon"
    }
  ]
}' |
apify call dr1ms/sncf-train-price-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dr1ms/sncf-train-price-scraper"
        }
    }
}

```

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/Kd51wCDeKZFUhRWs8/builds/G3Iglj5aW0mAxOVYi/openapi.json
