# 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:** 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

## 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

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

# 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("💾 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 '{
  "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": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=studio-amba/dsb-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "DSB Scraper - Danish Train Fares & Schedules",
        "description": "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.",
        "version": "0.1",
        "x-build-id": "Zc3lfHdMLqhrBW656"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/studio-amba~dsb-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-studio-amba-dsb-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~dsb-scraper/runs": {
            "post": {
                "operationId": "runs-sync-studio-amba-dsb-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~dsb-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-studio-amba-dsb-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": {
                    "origin": {
                        "title": "Origin Station",
                        "type": "string",
                        "description": "Departure station name (e.g. 'Kobenhavn H', 'Aarhus H', 'Odense', 'Aalborg')."
                    },
                    "destination": {
                        "title": "Destination Station",
                        "type": "string",
                        "description": "Arrival station name (e.g. 'Aarhus H', 'Odense', 'Aalborg', 'Kobenhavn H')."
                    },
                    "departureDate": {
                        "title": "Departure Date",
                        "type": "string",
                        "description": "Travel date in YYYY-MM-DD format (e.g. '2026-06-15'). Defaults to 7 days from today."
                    },
                    "departureTime": {
                        "title": "Departure Time",
                        "type": "string",
                        "description": "Departure time in HH:MM format (e.g. '08:00'). Defaults to 08:00."
                    },
                    "passengers": {
                        "title": "Passengers",
                        "minimum": 1,
                        "maximum": 9,
                        "type": "integer",
                        "description": "Number of adult passengers (default: 1).",
                        "default": 1
                    },
                    "maxResults": {
                        "title": "Max Results",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Maximum number of train connections to return.",
                        "default": 20
                    },
                    "proxyConfiguration": {
                        "title": "Proxy Configuration",
                        "type": "object",
                        "description": "Proxy settings for accessing DSB. Residential proxies with DK country recommended."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
