# DSB Scraper - Danish Train Fares & Schedules (`studio-amba/dsb-scraper`) Actor

Scrape DSB Danish Railways train connections, fares, and timetables. Search by station, date, and time for routes across Denmark. Returns departure times, arrival times, duration, train types, prices in DKK, and transfer details. No login or cookies required.

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

## Pricing

from $1.20 / 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.
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?

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

## DSB Scraper

Scrape DSB (Danske Statsbaner) train connections, fares, and timetables across Denmark. Search by station name, date, and time to get departure information, prices in DKK, train types, and transfer details for any route on the Danish rail network.

This actor uses Playwright to interact with the DSB booking interface and extract structured journey data. No login, cookies, or API keys required.

### How to scrape DSB data

1. Go to the [DSB Scraper](https://apify.com/studio-amba/dsb-scraper) page on Apify Store.
2. Click **Try for free** to open the actor in Apify Console.
3. Enter your departure station (e.g. "Kobenhavn H") and arrival station (e.g. "Aarhus H").
4. Optionally set a travel date and departure 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 |
|-----------|------|---------|-------------|
| `origin` | string | `Kobenhavn H` | Departure station name |
| `destination` | string | `Aarhus H` | Arrival station name |
| `departureDate` | string | tomorrow | Travel date in YYYY-MM-DD format |
| `departureTime` | string | `08:00` | Departure time in HH:MM format |
| `passengers` | integer | `1` | Number of adult passengers (1-9) |
| `maxResults` | integer | `20` | Maximum connections to return (1-100) |
| `proxyConfiguration` | object | Apify Residential DK | Proxy settings |

### Input example

```json
{
    "origin": "Kobenhavn H",
    "destination": "Aarhus H",
    "departureDate": "2026-06-15",
    "departureTime": "08:00",
    "passengers": 1,
    "maxResults": 20
}
```

### Output example

Each connection in the dataset contains the following fields:

```json
{
    "trainNumber": "IC 123",
    "trainType": "IC",
    "departureStation": "Kobenhavn H",
    "arrivalStation": "Aarhus H",
    "departureTime": "2026-06-15T08:25:00",
    "arrivalTime": "2026-06-15T11:40:00",
    "duration": "3h 15min",
    "durationMinutes": 195,
    "price": 399,
    "currency": "DKK",
    "travelClass": "Standard",
    "transfers": 0,
    "carrier": "DSB",
    "url": "https://www.dsb.dk/",
    "scrapedAt": "2026-06-09T10:00:00.000Z"
}
```

### Output fields

| Field | Type | Description |
|-------|------|-------------|
| `trainNumber` | string | Train service identifier (e.g. IC 123, Lyn 45) |
| `trainType` | string | Train category (Lyntog, IC, RE, S-tog, etc.) |
| `departureStation` | string | Departure station name |
| `arrivalStation` | string | Arrival station name |
| `departureTime` | string | Departure date and time |
| `arrivalTime` | string | Arrival date and time |
| `duration` | string | Human-readable duration (e.g. "3h 15min") |
| `durationMinutes` | integer | Duration in minutes |
| `price` | number | Ticket price in DKK (null if unavailable) |
| `currency` | string | Currency code (DKK) |
| `travelClass` | string | Travel class (Standard, DSB 1, Orange, etc.) |
| `transfers` | integer | Number of required transfers |
| `carrier` | string | Operating carrier (DSB, Arriva, etc.) |
| `url` | string | Link to the journey on dsb.dk |
| `scrapedAt` | string | ISO 8601 timestamp of data collection |

### Popular Danish train routes

Here are commonly searched routes you can use:

- Kobenhavn H to Aarhus H (approx. 3h, IC direct)
- Kobenhavn H to Odense (approx. 1h 30min, IC direct)
- Kobenhavn H to Aalborg (approx. 4h 30min)
- Aarhus H to Aalborg (approx. 1h 20min)
- Odense to Aarhus H (approx. 1h 30min)
- Kobenhavn H to Esbjerg (approx. 3h)
- Kobenhavn H to Fredericia (approx. 2h 15min)
- Aarhus H to Odense (approx. 1h 30min)
- Kobenhavn H to Roskilde (approx. 25min, RE/S-tog)
- Kobenhavn H to Helsingor (approx. 45min)

### Supported station names

The actor accepts DSB station names as they appear on timetables. Major stations include:

- **Copenhagen area**: Kobenhavn H (Central), Norreport, Kobenhavns Lufthavn (Airport), Osterport, Valby
- **Zealand**: Roskilde, Hoje Taastrup, Ringsted, Naestved, Korsor, Helsingor, Hillerod
- **Funen**: Odense, Nyborg, Svendborg, Middelfart
- **Jutland**: Aarhus H, Aalborg, Fredericia, Vejle, Kolding, Esbjerg, Herning, Silkeborg, Randers, Horsens, Viborg
- **Cross-border**: Hamburg Hbf, Flensburg, Malmo C (via Oresund)

Station names should match DSB's naming convention. The search is flexible and will match partial names.

### DSB ticket types

DSB offers several ticket categories that may appear in results:

- **Standard**: Regular second-class fare, fully flexible
- **DSB Orange**: Discounted off-peak tickets, non-refundable
- **DSB Orange Fri**: Discounted with more flexibility than Orange
- **DSB 1**: First-class tickets with extra comfort and services

Prices vary significantly between peak and off-peak hours. Orange tickets offer the best value when available.

### Train types on DSB

- **Lyntog (Lyn)**: Express trains, fastest service between major cities
- **IC (InterCity)**: Standard long-distance trains connecting major cities
- **RE (Regional)**: Regional trains serving medium-distance routes
- **S-tog**: Copenhagen suburban rail network (S-train)
- **ICE**: German ICE trains on cross-border routes to Hamburg

### Use cases

- **Travel planning**: Find the cheapest and fastest connections for your Denmark trip
- **Price monitoring**: Track fare changes on popular routes over time
- **Commuter analysis**: Monitor train schedules for daily commutes
- **Research**: Analyze Danish public transport patterns and connectivity
- **Travel apps**: Feed timetable and fare data into booking platforms or dashboards
- **Academic research**: Study rail network utilization and pricing patterns

### Cost estimate

This actor is billed $0.02 per run plus $0.002 per result — **1,000 results cost about $2.02**. Usage cost only settles once a run reports **SUCCEEDED** — reading a dataset mid-run will show a cost far below the real total.

### Tips

- Use station names as they appear on DSB (e.g. "Kobenhavn H" not "Copenhagen")
- Leave date and time empty to search from tomorrow at 08:00
- DSB Orange tickets are cheapest but sell out fast on popular routes
- Residential proxies with DK country code give the best results
- The actor includes a Rejseplanen fallback if the main DSB site blocks requests
- For cross-border journeys to Germany or Sweden, the same search works

# Actor input Schema

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

Departure station name (e.g. 'Kobenhavn H', 'Aarhus H', 'Odense', 'Aalborg').

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

Arrival station name (e.g. 'Aarhus H', 'Odense', 'Aalborg', 'Kobenhavn H').

## `departureDate` (type: `string`):

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

## `departureTime` (type: `string`):

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

## `passengers` (type: `integer`):

Number of adult passengers (default: 1).

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

Maximum number of train connections to return.

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

Proxy settings for accessing DSB. Residential proxies with DK country recommended.

## Actor input object example

```json
{
  "origin": "Kobenhavn H",
  "destination": "Aarhus H",
  "passengers": 1,
  "maxResults": 20,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "DK"
  }
}
```

# 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 = {
    "origin": "Kobenhavn H",
    "destination": "Aarhus H",
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "DK"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("studio-amba/dsb-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 = {
    "origin": "Kobenhavn H",
    "destination": "Aarhus H",
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "DK",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("studio-amba/dsb-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 '{
  "origin": "Kobenhavn H",
  "destination": "Aarhus H",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "DK"
  }
}' |
apify call studio-amba/dsb-scraper --silent --output-dataset

```

## MCP server setup

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