summary refs log tree commit diff
path: root/Transit departure display/index.md
blob: 2eac0b86fb75a2afd8d74ca8e311d65d621c363d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
---
description: Public transit time table
created: 2025-03-30
---

![POC](POC.webp)

[TOC]

## Data POC

### mittog.dk

- https://mittog.dk/da/departures/KH/stog
- https://github.com/vi/websocat

```console
websocat 'wss://api.mittog.dk/api/ws/stog/departure/KH/dinstation/' -B 500000 | jq
```

It's easily scrapable, but doesn't provide bus depature times.

### rejseplanen API

Journey planner however can be used for both trains and busses

- You can find the API at: [labs.rejseplanen.dk](https://labs.rejseplanen.dk/)
- [Rejseplanen api departure board endpoint documentation](https://www.rejseplanen.dk/api/departureBoard?wadl)
- The list of stop IDs can be aquired from the [GTFS.zip](https://www.rejseplanen.info/labs/GTFS.zip) file

```bash
curl 'https://www.rejseplanen.dk/api/departureBoard?accessId=XXX&format=json&id=000008600646' > nørreport_st.json
cat nørreport_st.json | jq '.Departure | .[] | {name: .name, planned_time: .time, direction: .direction, actual_time: .rtTime}' | jq --slurp
```

```JSON
  {
    "name": "Re 1070",
    "direction": "Helsingborg C",
    "planned_time": "12:53:00",
    "actual_time": null
  },
  {
    "name": "C",
    "direction": "Frederikssund St.",
    "planned_time": "12:53:00",
    "actual_time": null
  },
  {
    "name": "Metro M2",
    "direction": "Vanløse",
    "planned_time": "12:54:37",
    "actual_time": null
  },
  {
    "name": "Bus 5C",
    "direction": "Sundbyvester Plads",
    "planned_time": "12:55:00",
    "actual_time": "12:58:00"
  },
  {
    "name": "Bus 5C",
    "direction": "Husum Torv",
    "planned_time": "12:55:00",
    "actual_time": "12:53:00"
  },
```

Here we get trains, s-trains, busses and the metro.<br>
With name, direction planned time, and delay / ahead times.<br>
nice!