# Berlin Transit Station, Route and Departure Scraper (`nimbryxo-studio/berlin-transit-station-route-and-departure-scraper`) Actor

Look up Berlin-area transit stations, plan journeys between two stops with transfers and prices, or pull a live departure board with delays, across the Berlin/Brandenburg S-Bahn, U-Bahn, tram, bus and regional-rail network.

- **URL**: https://apify.com/nimbryxo-studio/berlin-transit-station-route-and-departure-scraper.md
- **Developed by:** [Nimbryxo-studio](https://apify.com/nimbryxo-studio) (community)
- **Categories:** Travel, Automation, Integrations
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.49 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Berlin Transit Station, Route and Departure Scraper

Berlin and Brandenburg run one of Europe's densest local transit networks — S-Bahn, U-Bahn, trams, buses, ferries and regional rail under the VBB fare union. This actor gives you three ways into that network: find a stop by name, plan a journey between two stops, or pull a live departure board for a single stop.

### What this actor does

- **Station lookup** — search any Berlin/Brandenburg stop name and get back matches with coordinates and the transport modes served there.
- **Journey planning** — resolve an origin and destination stop by name and return upcoming journeys with timing, transfers and price.
- **Live departures** — pull the next scheduled departures from a specific stop, including real-time delay minutes when reported.
- Covers every local transport mode in the network: suburban (S-Bahn), subway (U-Bahn), tram, bus, ferry, express and regional trains that call at a covered stop.
- Fields that aren't available for a given record (e.g. no delay reported, or no price for a journey) are omitted rather than returned empty.

### Output: per station (mode=`stations`)

- `stationId` — unique stop identifier
- `stationName` — station or stop name
- `type` — stop/station type as reported by the network
- `lat`, `lng` — coordinates
- `transportModes` — list of modes served at this stop (e.g. `suburban`, `bus`)
- `lines` — up to 10 line names serving this stop
- `recordType` — always `station`
- `scrapedAt` — ISO 8601 timestamp of collection

### Output: per journey (mode=`routes`)

- `origin`, `destination` — resolved stop names
- `departure`, `arrival` — timestamps for the first and last leg
- `durationMinutes` — total journey time
- `transfers` — number of changes
- `price`, `currency` — fare, when the route carries pricing data
- `transportModes` — modes used across all legs (includes `walking` for transfer walks)
- `lines` — line names used, leg by leg
- `recordType` — always `journey`
- `scrapedAt` — ISO 8601 timestamp of collection

### Output: per departure (mode=`departures`)

- `stationId`, `stationName` — the stop the board is for
- `line` — line name (e.g. `S1`, `M41`)
- `mode` — transport mode of that line
- `operator` — operating company
- `towards` — destination/direction shown on the board
- `scheduledAt` — scheduled departure time
- `delayMinutes` — reported delay in minutes, when available
- `recordType` — always `departure`
- `scrapedAt` — ISO 8601 timestamp of collection

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `mode` | string | `stations` | `stations`, `routes`, or `departures` |
| `query` | string | `Berlin` | Stop name to search (mode=`stations`), or to resolve a departure board when `stationId` isn't set (mode=`departures`) |
| `origin` | string | `Berlin Hauptbahnhof` | Departure stop name (mode=`routes`) |
| `destination` | string | `Hamburg Hauptbahnhof` | Arrival stop name (mode=`routes`) — see FAQ: use a Berlin/Brandenburg stop name for a real match |
| `stationId` | string | – | Specific stop ID to use directly for a departure board (mode=`departures`), skips the name lookup |
| `maxItems` | integer | `20` | Maximum records to return (1–200) |

#### Example: search for a stop

```json
{
  "mode": "stations",
  "query": "Alexanderplatz"
}
```

#### Example: plan a journey

```json
{
  "mode": "routes",
  "origin": "Berlin Hauptbahnhof",
  "destination": "Potsdam Hauptbahnhof",
  "maxItems": 5
}
```

#### Example: live departure board by station ID

```json
{
  "mode": "departures",
  "stationId": "900000100003",
  "maxItems": 20
}
```

### Use cases

- **Travel planning tools** — resolve a Berlin-area stop name and preview upcoming journeys before booking.
- **Delay monitoring** — poll a stop's departure board to track live delays through the day.
- **Trip comparison** — compare transfer count and duration across journey options for the same route.
- **Transit app prototyping** — pull real stop IDs, coordinates and served lines to seed a dataset.
- **Commuter research** — check which transport modes serve a given stop before relying on it.

### FAQ

**Does this cover all of Germany, or just Berlin?**
Just the Berlin/Brandenburg (VBB) network. A query for a stop outside that area (e.g. a Munich or Hamburg address) won't error — it will fuzzy-match the closest-sounding Berlin/Brandenburg stop name instead, which can produce a misleading result. Stick to stops within Berlin and Brandenburg for reliable matches.

**Does this only cover Deutsche Bahn long-distance trains?**
No — it covers the local Berlin/Brandenburg network: S-Bahn, U-Bahn, trams, buses, ferries and regional trains, wherever that mode of transport serves the stop you searched. Long-distance ICE/IC services aren't indexed by this data source.

**How do I find a `stationId` for the departures mode?**
Run mode=`stations` first with a name query; each result includes `stationId`. You can then pass that ID directly, or just leave `stationId` empty and set `query` to the stop name.

**Why is `price` missing from some journeys?**
Not every route returns fare data; when a journey has no fare attached, the `price` and `currency` fields are left out of that record.

**Why is `delayMinutes` missing from some departures?**
It's only included when the network reports an active delay for that departure; on-time departures simply omit it.

**Is the data real-time?**
Station and journey data reflects the network's current schedule; departure boards reflect live timing including delays where reported.

**Is this affiliated with Deutsche Bahn, BVG or VBB?**
No. This is an independent, third-party actor built on publicly available Berlin/Brandenburg transit data.

# Actor input Schema

## `mode` (type: `string`):

What to fetch.

## `query` (type: `string`):

Station name to search for (mode=stations or mode=departures).

## `origin` (type: `string`):

Departure station name (mode=routes).

## `destination` (type: `string`):

Arrival station name (mode=routes).

## `stationId` (type: `string`):

Specific BVG stop ID for departures (optional, mode=departures).

## `maxItems` (type: `integer`):

Maximum number of records to return.

## Actor input object example

```json
{
  "mode": "stations",
  "query": "Berlin",
  "origin": "Berlin Hauptbahnhof",
  "destination": "Hamburg Hauptbahnhof",
  "maxItems": 20
}
```

# Actor output Schema

## `transit` (type: `string`):

Dataset containing all scraped station/route/departure records.

# 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 = {
    "mode": "stations",
    "query": "Berlin",
    "origin": "Berlin Hauptbahnhof",
    "destination": "Hamburg Hauptbahnhof",
    "maxItems": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("nimbryxo-studio/berlin-transit-station-route-and-departure-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 = {
    "mode": "stations",
    "query": "Berlin",
    "origin": "Berlin Hauptbahnhof",
    "destination": "Hamburg Hauptbahnhof",
    "maxItems": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("nimbryxo-studio/berlin-transit-station-route-and-departure-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 '{
  "mode": "stations",
  "query": "Berlin",
  "origin": "Berlin Hauptbahnhof",
  "destination": "Hamburg Hauptbahnhof",
  "maxItems": 20
}' |
apify call nimbryxo-studio/berlin-transit-station-route-and-departure-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nimbryxo-studio/berlin-transit-station-route-and-departure-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/6JUeeW4ixrL8pnSKO/builds/6Bu34zyeyJvaOAR79/openapi.json
