# 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, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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 |

### 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"
  }
}
```

# 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("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=studio-amba/sbb-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "SBB Scraper — Swiss Train Timetable & Connections",
        "description": "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.",
        "version": "0.1",
        "x-build-id": "pQoQMm88iUa0Fn8fP"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/studio-amba~sbb-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-studio-amba-sbb-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/studio-amba~sbb-scraper/runs": {
            "post": {
                "operationId": "runs-sync-studio-amba-sbb-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/studio-amba~sbb-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-studio-amba-sbb-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "fromStation": {
                        "title": "From Station",
                        "type": "string",
                        "description": "Departure station name (e.g. 'Zurich HB', 'Bern', 'Basel SBB', 'Geneva')."
                    },
                    "toStation": {
                        "title": "To Station",
                        "type": "string",
                        "description": "Arrival station name (e.g. 'Bern', 'Luzern', 'Interlaken Ost', 'Lausanne')."
                    },
                    "date": {
                        "title": "Date",
                        "type": "string",
                        "description": "Travel date in YYYY-MM-DD format (e.g. '2026-06-15'). Defaults to today."
                    },
                    "time": {
                        "title": "Time",
                        "type": "string",
                        "description": "Departure time in HH:MM format (e.g. '08:00'). Defaults to current time."
                    },
                    "isArrivalTime": {
                        "title": "Search by Arrival Time",
                        "type": "boolean",
                        "description": "If enabled, the time is treated as desired arrival time instead of departure time.",
                        "default": false
                    },
                    "maxResults": {
                        "title": "Max Results",
                        "minimum": 1,
                        "maximum": 200,
                        "type": "integer",
                        "description": "Maximum number of connections to return. The API returns up to 6 per page; this actor paginates automatically.",
                        "default": 20
                    },
                    "proxyConfiguration": {
                        "title": "Proxy Configuration",
                        "type": "object",
                        "description": "Proxy settings. The SBB transport API is public but may rate-limit without proxy."
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
