You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+110-95
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,6 @@
1
1
# hafas-client
2
2
3
-
**A client for HAFAS public transport APIs**. Sort of like [public-transport-enabler](https://github.com/schildbach/public-transport-enabler), but with a smaller scope. It [contains customisations](p) for the following transport networks:
[Société Nationale des Chemins de Fer Luxembourgeois (CFL)](https://en.wikipedia.org/wiki/Société_Nationale_des_Chemins_de_Fer_Luxembourgeois) | - | [docs](p/cfl/readme.md) | [example code](p/cfl/example.js) | [src](p/cfl/index.js)
17
-
[Hamburg public transport (HVV)](https://en.wikipedia.org/wiki/Hamburger_Verkehrsverbund) | - | [docs](p/hvv/readme.md) | [example code](p/hvv/example.js) | [src](p/hvv/index.js)
There are also client libraries that use the library, but contain their own customisations:
21
-
22
-
HAFAS endpoint | library
23
-
---------------|--------
24
-
[Betriebsstellen & disturbances in the German rail network](https://strecken.info/) | [`db-netz-hafas`](https://github.com/derhuerst/db-netz-hafas)
3
+
**A client for HAFAS public transport APIs**. Sort of like [public-transport-enabler](https://github.com/schildbach/public-transport-enabler), but with a smaller scope. It [contains customisations](p) for [several public transportation networks](#supported-networksendpoints)
`hafas-client` as well its dependencies use [Node-builtin modules](https://nodejs.org/dist/latest/docs/api/) and [Node globals](https://nodejs.org/api/globals.html). To be able to use it within react-native, follow [the instructions at `node-libs-react-native`](https://github.com/parshap/node-libs-react-native/blob/3/README.md#usage).
The returned [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) will resolve with an object with an array `journeys` that contains one [*FPTF*`journey`](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.0/spec/readme.md#journey).
44
+
`journeys()` returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) that will resolve with an object with an array `journeys` that contains one [*FPTF*`journey`](https://github.com/public-transport/friendly-public-transport-format/blob/1.2.0/spec/readme.md#journey).
72
45
73
46
```js
74
47
{
75
48
journeys: [ {
49
+
origin: {
50
+
type:'station',
51
+
id:'8089100',
52
+
name:'Berlin Jungfernheide (S)',
53
+
location: { /* … */ },
54
+
products: { /* … */ }
55
+
},
56
+
departure:'2019-12-17T17:05:30+01:00',
57
+
departureDelay:30,
58
+
departurePlatform:'5',
59
+
60
+
destination: {
61
+
type:'station',
62
+
id:'8000261',
63
+
name:'München Hbf',
64
+
location: { /* … */ },
65
+
products: { /* … */ }
66
+
},
67
+
arrival:'2019-12-17T22:44:00+01:00',
68
+
arrivalDelay:-60,
69
+
arrivalPlatform:'11A',
70
+
76
71
legs: [ {
77
72
id:'1|100067|48|81|17122017',
78
-
origin: {
79
-
type:'station',
80
-
id:'8089100',
81
-
name:'Berlin Jungfernheide (S)',
82
-
location: {
83
-
type:'location',
84
-
latitude:52.530291,
85
-
longitude:13.299451
86
-
},
87
-
products: { /* … */ }
88
-
},
89
-
departure:'2017-12-17T17:05:00+01:00',
90
-
departurePlatform:'5',
91
-
destination: {
92
-
type:'station',
93
-
id:'8089118',
94
-
name:'Berlin Beusselstraße',
95
-
location: { /* … */ },
96
-
products: { /* … */ }
97
-
},
98
-
arrival:'2017-12-17T17:08:00+01:00',
99
-
arrivalPlatform:'1',
100
73
line: {
101
74
type:'line',
102
75
id:'41172',
@@ -110,80 +83,122 @@ The returned [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript
110
83
name:'S-Bahn Berlin GmbH'
111
84
}
112
85
},
113
-
direction:'Ringbahn ->'
114
-
}, /* … */ {
86
+
direction:'Ringbahn ->',
87
+
115
88
origin: {
116
89
type:'station',
117
-
id:'730749',
118
-
name:'Berlin Hauptbahnhof (S+U), Berlin',
90
+
id:'8089100',
91
+
name:'Berlin Jungfernheide (S)',
119
92
location: {
120
93
type:'location',
121
-
latitude:52.526461,
122
-
longitude:13.369378
94
+
latitude:52.530291,
95
+
longitude:13.299451
123
96
},
124
97
products: { /* … */ }
125
98
},
126
-
departure:'2017-12-17T17:25:00+01:00',
99
+
departure:'2019-12-17T17:05:30+01:00',
100
+
departureDelay:30,
101
+
departurePlatform:'5',
102
+
127
103
destination: {
128
104
type:'station',
129
-
id:'8098160',
130
-
name:'Berlin Hbf (tief)',
131
-
location: { /* … */ },
132
-
products: { /* … */ }
105
+
id:'8089118',
106
+
name:'Berlin Beusselstraße'
107
+
/* … */
133
108
},
134
-
arrival:'2017-12-17T17:33:00+01:00',
109
+
arrival:'2019-12-17T17:08:00+01:00',
110
+
arrivalDelay:null,
111
+
arrivalPlatform:'2a-b'
112
+
},
113
+
/* more legs… */
114
+
{
115
+
walking:true,
135
116
public:true,
136
-
walking:true
117
+
118
+
origin: {
119
+
type:'station',
120
+
id:'730749',
121
+
name:'Berlin Hauptbahnhof (S+U), Berlin'
122
+
/* … */
123
+
},
124
+
departure:'2019-12-17T17:25:00+01:00',
125
+
departureDelay:null,
126
+
127
+
destination: {
128
+
type:'station',
129
+
id:'8098160',
130
+
name:'Berlin Hbf (tief)'
131
+
/* … */
132
+
},
133
+
arrival:'2019-12-17T17:33:00+01:00',
134
+
arrivalDelay:null
137
135
}, {
138
136
id:'1|70906|0|81|17122017',
137
+
line: { /* … */ },
138
+
direction:'München Hbf',
139
+
139
140
origin: {
140
141
type:'station',
141
142
id:'8098160',
142
-
name:'Berlin Hbf (tief)',
143
-
location: { /* … */ },
144
-
products: { /* … */ }
143
+
name:'Berlin Hbf (tief)'
144
+
/* … */
145
145
},
146
-
departure:'2017-12-17T17:37:00+01:00',
146
+
departure:'2019-12-17T17:35:00+01:00',
147
+
departureDelay:-120,
147
148
departurePlatform:'1',
149
+
148
150
destination: {
149
151
type:'station',
150
152
id:'8000261',
151
153
name:'München Hbf',
152
-
location: { /* … */ },
153
-
products: { /* … */ }
154
+
/* … */
154
155
},
155
-
arrival:'2017-12-17T22:45:00+01:00',
156
-
arrivalPlatform:'13',
157
-
line: { /* … */ },
158
-
direction:'München Hbf'
156
+
arrival:'2019-12-17T22:44:00+01:00',
157
+
arrivalDelay:-60,
158
+
arrivalPlatform:'11A'
159
159
} ],
160
-
origin: {
161
-
type:'station',
162
-
id:'8089100',
163
-
name:'Berlin Jungfernheide (S)',
164
-
location: { /* … */ },
165
-
products: { /* … */ }
166
-
},
167
-
departure:'2017-12-17T17:05:00+01:00',
168
-
destination: {
169
-
type:'station',
170
-
id:'8000261',
171
-
name:'München Hbf',
172
-
location: { /* … */ },
173
-
products: { /* … */ }
174
-
},
175
-
arrival:'2017-12-17T22:45:00+01:00',
176
160
price: {
177
161
amount:null,
178
162
hint:'No pricing information available.'
179
163
}
180
-
} ],
181
-
earlierRef:/* … */,
182
-
laterRef:/* … */
164
+
/* … */
165
+
} ]
166
+
/* … */
183
167
}
184
168
```
185
169
186
170
171
+
## API
172
+
173
+
[API documentation](docs/readme.md)
174
+
175
+
176
+
## supported networks/endpoints
177
+
178
+
`hafas-client` has built-in customisations (called "profiles") for these public transportation networks:
[Société Nationale des Chemins de Fer Luxembourgeois (CFL)](https://en.wikipedia.org/wiki/Société_Nationale_des_Chemins_de_Fer_Luxembourgeois) | - | [docs](p/cfl/readme.md) | [example code](p/cfl/example.js) | [src](p/cfl/index.js)
192
+
[Hamburg public transport (HVV)](https://en.wikipedia.org/wiki/Hamburger_Verkehrsverbund) | - | [docs](p/hvv/readme.md) | [example code](p/hvv/example.js) | [src](p/hvv/index.js)
0 commit comments