Skip to content

Commit 8c319d9

Browse files
committed
improve readme readability 📝
1 parent 604beba commit 8c319d9

File tree

1 file changed

+110
-95
lines changed

1 file changed

+110
-95
lines changed

readme.md

+110-95
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,6 @@
11
# hafas-client
22

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:
4-
5-
HAFAS endpoint | wrapper library | docs | example code | source code
6-
---------------|------------------|------|---------|------------
7-
[Deutsche Bahn (DB)](https://en.wikipedia.org/wiki/Deutsche_Bahn) | [`db-hafas`](https://github.com/derhuerst/db-hafas) | [docs](p/db/readme.md) | [example code](p/db/example.js) | [src](p/db/index.js)
8-
[Berlin & Brandenburg public transport (VBB)](https://en.wikipedia.org/wiki/Verkehrsverbund_Berlin-Brandenburg) | [`vbb-hafas`](https://github.com/derhuerst/vbb-hafas) | [docs](p/vbb/readme.md) | [example code](p/vbb/example.js) | [src](p/vbb/index.js)
9-
[Berlin public transport (BVG)](https://en.wikipedia.org/wiki/Berliner_Verkehrsbetriebe) | [`bvg-hafas`](https://github.com/derhuerst/bvg-hafas) | [docs](p/bvg/readme.md) | [example code](p/bvg/example.js) | [src](p/bvg/index.js)
10-
[Österreichische Bundesbahnen (ÖBB)](https://en.wikipedia.org/wiki/Austrian_Federal_Railways) | [`oebb-hafas`](https://github.com/juliuste/oebb-hafas) | [docs](p/oebb/readme.md) | [example code](p/oebb/example.js) | [src](p/oebb/index.js)
11-
[Nahverkehr Sachsen-Anhalt (NASA)](https://de.wikipedia.org/wiki/Nahverkehrsservice_Sachsen-Anhalt)/[INSA](https://insa.de) | [`insa-hafas`](https://github.com/derhuerst/insa-hafas) | [docs](p/insa/readme.md) | [example code](p/insa/example.js) | [src](p/insa/index.js)
12-
[Nahverkehrsverbund Schleswig-Holstein (NAH.SH)](https://de.wikipedia.org/wiki/Nahverkehrsverbund_Schleswig-Holstein) | [`nahsh-hafas`](https://github.com/juliuste/nahsh-hafas) | [docs](p/nahsh/readme.md) | [example code](p/nahsh/example.js) | [src](p/nahsh/index.js)
13-
[Austin, Texas (CMTA/*CapMetro*)](https://en.wikipedia.org/wiki/Capital_Metropolitan_Transportation_Authority) | - | [docs](p/cmta/readme.md) | [example code](p/cmta/example.js) | [src](p/cmta/index.js)
14-
[*S-Bahn München*](https://en.wikipedia.org/wiki/Munich_S-Bahn) | - | [docs](p/sbahn-muenchen/readme.md) | [example code](p/sbahn-muenchen/example.js) | [src](p/sbahn-muenchen/index.js)
15-
*Saarfahrplan*/VGS ([Saarland](https://en.wikipedia.org/wiki/Saarland)) | - | [docs](p/saarfahrplan/readme.md) | [example code](p/saarfahrplan/example.js) | [src](p/saarfahrplan/index.js)
16-
[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)
18-
[*Nordhessischer Verkehrsverbund (NVV)*](https://en.wikipedia.org/wiki/Nordhessischer_Verkehrsverbund) ([Hesse](https://en.wikipedia.org/wiki/Hesse)) | - | [docs](p/nvv/readme.md) | [example code](p/nvv/example.js) | [src](p/nvv/index.js)
19-
20-
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)
254

265
[![npm version](https://img.shields.io/npm/v/hafas-client.svg)](https://www.npmjs.com/package/hafas-client)
276
[![build status](https://img.shields.io/travis/public-transport/hafas-client.svg?branch=3)](https://travis-ci.org/public-transport/hafas-client)
@@ -48,55 +27,49 @@ npm install hafas-client
4827
`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).
4928

5029

51-
## API
52-
53-
[API documentation](docs/readme.md)
54-
55-
5630
## Usage
5731

5832
```js
5933
const createClient = require('hafas-client')
6034
const dbProfile = require('hafas-client/p/db')
6135

62-
// create a client with Deutsche Bahn profile
36+
// create a client with the Deutsche Bahn profile
6337
const client = createClient(dbProfile, 'my-awesome-program')
6438

6539
// Berlin Jungfernheide to München Hbf
6640
client.journeys('8011167', '8000261', {results: 1})
67-
.then(console.log)
68-
.catch(console.error)
41+
.then(console.log).catch(console.error)
6942
```
7043

71-
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).
7245

7346
```js
7447
{
7548
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+
7671
legs: [ {
7772
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',
10073
line: {
10174
type: 'line',
10275
id: '41172',
@@ -110,80 +83,122 @@ The returned [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript
11083
name: 'S-Bahn Berlin GmbH'
11184
}
11285
},
113-
direction: 'Ringbahn ->'
114-
}, /**/ {
86+
direction: 'Ringbahn ->',
87+
11588
origin: {
11689
type: 'station',
117-
id: '730749',
118-
name: 'Berlin Hauptbahnhof (S+U), Berlin',
90+
id: '8089100',
91+
name: 'Berlin Jungfernheide (S)',
11992
location: {
12093
type: 'location',
121-
latitude: 52.526461,
122-
longitude: 13.369378
94+
latitude: 52.530291,
95+
longitude: 13.299451
12396
},
12497
products: { /**/ }
12598
},
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+
127103
destination: {
128104
type: 'station',
129-
id: '8098160',
130-
name: 'Berlin Hbf (tief)',
131-
location: { /**/ },
132-
products: { /**/ }
105+
id: '8089118',
106+
name: 'Berlin Beusselstraße'
107+
/**/
133108
},
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,
135116
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
137135
}, {
138136
id: '1|70906|0|81|17122017',
137+
line: { /**/ },
138+
direction: 'München Hbf',
139+
139140
origin: {
140141
type: 'station',
141142
id: '8098160',
142-
name: 'Berlin Hbf (tief)',
143-
location: { /**/ },
144-
products: { /**/ }
143+
name: 'Berlin Hbf (tief)'
144+
/**/
145145
},
146-
departure: '2017-12-17T17:37:00+01:00',
146+
departure: '2019-12-17T17:35:00+01:00',
147+
departureDelay: -120,
147148
departurePlatform: '1',
149+
148150
destination: {
149151
type: 'station',
150152
id: '8000261',
151153
name: 'München Hbf',
152-
location: { /**/ },
153-
products: { /**/ }
154+
/**/
154155
},
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'
159159
} ],
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',
176160
price: {
177161
amount: null,
178162
hint: 'No pricing information available.'
179163
}
180-
} ],
181-
earlierRef: /**/,
182-
laterRef: /**/
164+
/**/
165+
} ]
166+
/**/
183167
}
184168
```
185169

186170

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:
179+
180+
HAFAS endpoint | wrapper library | docs | example code | source code
181+
---------------|------------------|------|---------|------------
182+
[Deutsche Bahn (DB)](https://en.wikipedia.org/wiki/Deutsche_Bahn) | [`db-hafas`](https://github.com/derhuerst/db-hafas) | [docs](p/db/readme.md) | [example code](p/db/example.js) | [src](p/db/index.js)
183+
[Berlin & Brandenburg public transport (VBB)](https://en.wikipedia.org/wiki/Verkehrsverbund_Berlin-Brandenburg) | [`vbb-hafas`](https://github.com/derhuerst/vbb-hafas) | [docs](p/vbb/readme.md) | [example code](p/vbb/example.js) | [src](p/vbb/index.js)
184+
[Berlin public transport (BVG)](https://en.wikipedia.org/wiki/Berliner_Verkehrsbetriebe) | [`bvg-hafas`](https://github.com/derhuerst/bvg-hafas) | [docs](p/bvg/readme.md) | [example code](p/bvg/example.js) | [src](p/bvg/index.js)
185+
[Österreichische Bundesbahnen (ÖBB)](https://en.wikipedia.org/wiki/Austrian_Federal_Railways) | [`oebb-hafas`](https://github.com/juliuste/oebb-hafas) | [docs](p/oebb/readme.md) | [example code](p/oebb/example.js) | [src](p/oebb/index.js)
186+
[Nahverkehr Sachsen-Anhalt (NASA)](https://de.wikipedia.org/wiki/Nahverkehrsservice_Sachsen-Anhalt)/[INSA](https://insa.de) | [`insa-hafas`](https://github.com/derhuerst/insa-hafas) | [docs](p/insa/readme.md) | [example code](p/insa/example.js) | [src](p/insa/index.js)
187+
[Nahverkehrsverbund Schleswig-Holstein (NAH.SH)](https://de.wikipedia.org/wiki/Nahverkehrsverbund_Schleswig-Holstein) | [`nahsh-hafas`](https://github.com/juliuste/nahsh-hafas) | [docs](p/nahsh/readme.md) | [example code](p/nahsh/example.js) | [src](p/nahsh/index.js)
188+
[Austin, Texas (CMTA/*CapMetro*)](https://en.wikipedia.org/wiki/Capital_Metropolitan_Transportation_Authority) | - | [docs](p/cmta/readme.md) | [example code](p/cmta/example.js) | [src](p/cmta/index.js)
189+
[*S-Bahn München*](https://en.wikipedia.org/wiki/Munich_S-Bahn) | - | [docs](p/sbahn-muenchen/readme.md) | [example code](p/sbahn-muenchen/example.js) | [src](p/sbahn-muenchen/index.js)
190+
*Saarfahrplan*/VGS ([Saarland](https://en.wikipedia.org/wiki/Saarland)) | - | [docs](p/saarfahrplan/readme.md) | [example code](p/saarfahrplan/example.js) | [src](p/saarfahrplan/index.js)
191+
[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)
193+
[*Nordhessischer Verkehrsverbund (NVV)*](https://en.wikipedia.org/wiki/Nordhessischer_Verkehrsverbund) ([Hesse](https://en.wikipedia.org/wiki/Hesse)) | - | [docs](p/nvv/readme.md) | [example code](p/nvv/example.js) | [src](p/nvv/index.js)
194+
195+
There are also libraries that use `hafas-client` and pass their own profile in:
196+
197+
HAFAS endpoint | library
198+
---------------|--------
199+
[Betriebsstellen & disturbances in the German rail network](https://strecken.info/) | [`db-netz-hafas`](https://github.com/derhuerst/db-netz-hafas)
200+
201+
187202
## Related
188203

189204
- [`public-transport-enabler`](https://github.com/schildbach/public-transport-enabler) – Unleash public transport data in your Java project.

0 commit comments

Comments
 (0)