# SBB Scraper — Swiss Train Timetable & Connections (`studio-amba/sbb-scraper`) Actor

Scrape Swiss Federal Railways (SBB) train connections, timetables, and schedules. Search by station name and date. Returns departure times, arrival times, duration, train types, platforms, and transfer details. No login or cookies required.

- **URL**: https://apify.com/studio-amba/sbb-scraper.md
- **Developed by:** [Studio Amba](https://apify.com/studio-amba) (community)
- **Categories:** Travel
- **Stats:** 2 total users, 1 monthly users, 86.7% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 result scrapeds

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?

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

## SBB Scraper

Scrape Swiss Federal Railways (SBB) train connections, timetables, and schedules. Search by station name and travel date to get real-time departure and arrival information for any route in Switzerland.

This actor uses the public Swiss transport API (transport.opendata.ch) for fast, reliable data extraction. No login, cookies, or browser automation required.

### How to scrape SBB data

1. Go to the [SBB Scraper](https://apify.com/studio-amba/sbb-scraper) page on Apify Store.
2. Click **Try for free** to open the actor in Apify Console.
3. Enter your departure station (e.g. "Zurich HB") and arrival station (e.g. "Bern").
4. Optionally set a travel date and time.
5. Click **Start** and wait for the run to finish.
6. Download your data in JSON, CSV, Excel, or any other supported format.

### Input parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `fromStation` | string | `Zurich HB` | Departure station name |
| `toStation` | string | `Bern` | Arrival station name |
| `date` | string | today | Travel date in YYYY-MM-DD format |
| `time` | string | now | Departure time in HH:MM format |
| `isArrivalTime` | boolean | `false` | Search by arrival time instead of departure |
| `maxResults` | integer | `20` | Maximum connections to return (1-200) |
| `proxyConfiguration` | object | Apify Residential | Proxy settings |

### Input example

```json
{
    "fromStation": "Zurich HB",
    "toStation": "Bern",
    "date": "2026-06-15",
    "time": "08:00",
    "maxResults": 20
}
```

### Output example

Each connection in the dataset contains the following fields:

```json
{
    "origin": "Zurich HB",
    "destination": "Bern",
    "departureTime": "2026-06-15T08:02:00+0200",
    "arrivalTime": "2026-06-15T08:58:00+0200",
    "duration": "0h 56min",
    "durationMinutes": 56,
    "trainType": "IC",
    "trainNumber": "1",
    "platform": "6",
    "arrivalPlatform": "4",
    "transfers": 0,
    "carrier": "SBB",
    "sections": [
        {
            "from": "Zurich HB",
            "to": "Bern",
            "departure": "2026-06-15T08:02:00+0200",
            "arrival": "2026-06-15T08:58:00+0200",
            "platform": "6",
            "arrivalPlatform": "4",
            "trainType": "IC",
            "trainNumber": "1",
            "operator": "SBB",
            "isWalk": false
        }
    ],
    "departurePlatformChanged": false,
    "departureDelay": "",
    "arrivalDelay": "",
    "url": "https://www.sbb.ch/en/timetable/timetable.html?from=Zurich%20HB&to=Bern&date=15.06.2026&time=08:02",
    "scrapedAt": "2026-06-09T10:00:00.000Z"
}
```

### Output fields

| Field | Type | Description |
|-------|------|-------------|
| `origin` | string | Departure station name |
| `destination` | string | Arrival station name |
| `departureTime` | string | ISO 8601 departure timestamp |
| `arrivalTime` | string | ISO 8601 arrival timestamp |
| `duration` | string | Human-readable duration (e.g. "0h 56min") |
| `durationMinutes` | integer | Duration in minutes |
| `trainType` | string | Train category (IC, IR, RE, S, ICE, etc.) |
| `trainNumber` | string | Train service number |
| `platform` | string | Departure platform |
| `arrivalPlatform` | string | Arrival platform |
| `transfers` | integer | Number of required transfers |
| `carrier` | string | Operating carrier (SBB, BLS, SOB, etc.) |
| `sections` | array | Individual journey legs with full details |
| `departurePlatformChanged` | boolean | Whether platform has changed from scheduled |
| `departureDelay` | string | Real-time departure delay (e.g. "+5 min") |
| `arrivalDelay` | string | Real-time arrival delay |
| `url` | string | Direct link to the timetable on sbb.ch |
| `scrapedAt` | string | ISO 8601 timestamp of data collection |

### How much does it cost?

This actor is billed $0.02 per run plus $0.002 per result:

- **20 connections**: ~$0.06
- **100 connections**: ~$0.22
- **1,000 connections**: ~$2.02

Your run's usage cost only settles after the run reports SUCCEEDED — reading a mid-run dataset understates the eventual cost.

### Popular Swiss train routes

Here are some commonly searched routes you can use:

- Zurich HB to Bern (56 min, IC direct)
- Zurich HB to Geneva (2h 45min)
- Bern to Basel SBB (55 min, IC direct)
- Zurich HB to Luzern (45 min)
- Zurich HB to Interlaken Ost (1h 50min)
- Lausanne to Bern (1h 6min)
- Basel SBB to Zurich HB (53 min)
- Geneva to Lausanne (33 min)
- Bern to Zurich Flughafen (1h 15min)
- Zurich HB to St. Gallen (1h 5min)

### Supported station names

The actor accepts any Swiss public transport station name recognized by the SBB system. This includes:

- Major train stations: Zurich HB, Bern, Basel SBB, Geneva, Lausanne, Luzern
- Regional stations: Thun, Interlaken Ost, Winterthur, St. Gallen, Biel/Bienne
- Airport stations: Zurich Flughafen, Geneva Aeroport
- International connections: stations in neighboring countries reachable by SBB

Station names should be entered as they appear on SBB timetables. The API handles partial matches, so "Zurich" will resolve to "Zurich HB".

### Data coverage

- All Swiss public transport: SBB trains, regional railways (BLS, SOB, etc.), PostBus, trams, ships
- Real-time delay information when available
- Platform numbers and platform change alerts
- Connections with transfers including walking segments
- International connections to/from Switzerland

### Use cases

- **Travel planning**: Find the best connections for your Swiss trip
- **Commuter analysis**: Monitor train schedules for daily commutes
- **Research**: Analyze Swiss public transport patterns and connectivity
- **Integration**: Feed timetable data into travel apps or dashboards
- **Delay monitoring**: Track real-time delays on specific routes

### Rate limiting

The underlying transport API limits requests to 3 per second per IP address. The actor automatically respects this limit with built-in delays between requests. For large result sets (100+ connections), expect the actor to run for 15-30 seconds.

### Tips

- Use the exact SBB station name for best results (e.g. "Zurich HB" not just "Zurich")
- Leave date and time empty to search from the current moment
- Set `isArrivalTime` to `true` if you need to arrive by a specific time
- The `sections` array contains full details for multi-leg journeys
- Platform change alerts and delays reflect real-time data from SBB

# Actor input Schema

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

Departure station name (e.g. 'Zurich HB', 'Bern', 'Basel SBB', 'Geneva').

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

Arrival station name (e.g. 'Bern', 'Luzern', 'Interlaken Ost', 'Lausanne').

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

Travel date in YYYY-MM-DD format (e.g. '2026-06-15'). Defaults to today.

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

Departure time in HH:MM format (e.g. '08:00'). Defaults to current time.

## `isArrivalTime` (type: `boolean`):

If enabled, the time is treated as desired arrival time instead of departure time.

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

Maximum number of connections to return. The API returns up to 6 per page; this actor paginates automatically.

## `proxyConfiguration` (type: `object`):

Proxy settings. The SBB transport API is public but may rate-limit without proxy.

## Actor input object example

```json
{
  "fromStation": "Zurich HB",
  "toStation": "Bern",
  "isArrivalTime": false,
  "maxResults": 20,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "CH"
  }
}
```

# 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 = {
    "fromStation": "Zurich HB",
    "toStation": "Bern",
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "CH"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("studio-amba/sbb-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 = {
    "fromStation": "Zurich HB",
    "toStation": "Bern",
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "CH",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("studio-amba/sbb-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 '{
  "fromStation": "Zurich HB",
  "toStation": "Bern",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "CH"
  }
}' |
apify call studio-amba/sbb-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,studio-amba/sbb-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/NPHqBumIsFlDY4dsK/builds/1zzU88USt3oK5XRcW/openapi.json
