mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
tweak & restructure docs 📝, explicit defaults
This commit is contained in:
parent
c88179777d
commit
5ff8527b60
5 changed files with 30 additions and 24 deletions
17
docs/api.md
Normal file
17
docs/api.md
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# `hafas-client` API
|
||||||
|
|
||||||
|
- [`journeys(from, to, [opt])`](journeys.md) – get journeys between locations
|
||||||
|
- [`refreshJourney(refreshToken, [opt])`](refresh-journey.md) – fetch up-to-date/more details of a `journey`
|
||||||
|
- [`journeysFromTrip(tripId, previousStopover, to, [opt])`](journeys-from-trip.md) – get journeys from a trip to a location
|
||||||
|
- [`trip(id, lineName, [opt])`](trip.md) – get details for a trip
|
||||||
|
- [`tripsByName(lineNameOrFahrtNr, [opt])`](trips-by-name.md) – get all trips matching a name
|
||||||
|
- [`departures(station, [opt])`](departures.md) – query the next departures at a station
|
||||||
|
- [`arrivals(station, [opt])`](arrivals.md) – query the next arrivals at a station
|
||||||
|
- [`locations(query, [opt])`](locations.md) – find stations, POIs and addresses
|
||||||
|
- [`stop(id, [opt])`](stop.md) – get details about a stop/station
|
||||||
|
- [`nearby(location, [opt])`](nearby.md) – show stations & POIs around
|
||||||
|
- [`radar(north, west, south, east, [opt])`](radar.md) – find all vehicles currently in a certain area
|
||||||
|
- [`reachableFrom(address, [opt])`](reachable-from.md) – get all stations reachable from an address within `n` minutes
|
||||||
|
- [`remarks([opt])`](remarks.md) – get all remarks
|
||||||
|
- [`lines(query, [opt])`](lines.md) – get all lines matching a name
|
||||||
|
- [`serverInfo([opt])`](server-info.md) – fetch meta information from HAFAS
|
|
@ -16,8 +16,8 @@
|
||||||
|
|
||||||
## `5.25.0`
|
## `5.25.0`
|
||||||
|
|
||||||
- 0a636981 parse `CHKI` (check-in, check-out) legs ✅
|
- 0a636981 parse `CHKI` (check-in, check-out) legs ✅ – Thanks @yu-re-ka!
|
||||||
- 7c68f962 `parse{Stopover,JourneyLeg, Trip}`: expose `{arrival,departure}PrognosisType` ✅
|
- 7c68f962 `parse{Stopover,JourneyLeg, Trip}`: expose `{arrival,departure}PrognosisType` ✅ – Thanks @HybridFox!
|
||||||
- 95af0a01 `parseArrival` & `parseDeparture`: expose `prognosisType` ✅
|
- 95af0a01 `parseArrival` & `parseDeparture`: expose `prognosisType` ✅
|
||||||
|
|
||||||
[🏷 `5.25.0`](https://github.com/public-transport/hafas-client/releases/tag/5.25.0), 2022-07-30
|
[🏷 `5.25.0`](https://github.com/public-transport/hafas-client/releases/tag/5.25.0), 2022-07-30
|
||||||
|
|
|
@ -1,20 +1,6 @@
|
||||||
# API documentation
|
# `hafas-client` documentation
|
||||||
|
|
||||||
- [`journeys(from, to, [opt])`](journeys.md) – get journeys between locations
|
**[API documentation](api.md)**
|
||||||
- [`refreshJourney(refreshToken, [opt])`](refresh-journey.md) – fetch up-to-date/more details of a `journey`
|
|
||||||
- [`journeysFromTrip(tripId, previousStopover, to, [opt])`](journeys-from-trip.md) – get journeys from a trip to a location
|
|
||||||
- [`trip(id, lineName, [opt])`](trip.md) – get details for a trip
|
|
||||||
- [`tripsByName(lineNameOrFahrtNr, [opt])`](trips-by-name.md) – get all trips matching a name
|
|
||||||
- [`departures(station, [opt])`](departures.md) – query the next departures at a station
|
|
||||||
- [`arrivals(station, [opt])`](arrivals.md) – query the next arrivals at a station
|
|
||||||
- [`locations(query, [opt])`](locations.md) – find stations, POIs and addresses
|
|
||||||
- [`stop(id, [opt])`](stop.md) – get details about a stop/station
|
|
||||||
- [`nearby(location, [opt])`](nearby.md) – show stations & POIs around
|
|
||||||
- [`radar(north, west, south, east, [opt])`](radar.md) – find all vehicles currently in a certain area
|
|
||||||
- [`reachableFrom(address, [opt])`](reachable-from.md) – get all stations reachable from an address within `n` minutes
|
|
||||||
- [`remarks([opt])`](remarks.md) – get all remarks
|
|
||||||
- [`lines(query, [opt])`](lines.md) – get all lines matching a name
|
|
||||||
- [`serverInfo([opt])`](server-info.md) – fetch meta information from HAFAS
|
|
||||||
|
|
||||||
## Migrating from an old `hafas-client` version
|
## Migrating from an old `hafas-client` version
|
||||||
|
|
||||||
|
|
5
index.js
5
index.js
|
@ -139,7 +139,7 @@ const createClient = (profile, userAgent, opt = {}) => {
|
||||||
subStops: true, // parse & expose sub-stops of stations?
|
subStops: true, // parse & expose sub-stops of stations?
|
||||||
entrances: true, // parse & expose entrances of stops/stations?
|
entrances: true, // parse & expose entrances of stops/stations?
|
||||||
remarks: true, // parse & expose hints & warnings?
|
remarks: true, // parse & expose hints & warnings?
|
||||||
scheduledDays: false
|
scheduledDays: false, // parse & expose dates each journey is valid on?
|
||||||
}, opt)
|
}, opt)
|
||||||
if (opt.via) opt.via = profile.formatLocation(profile, opt.via, 'opt.via')
|
if (opt.via) opt.via = profile.formatLocation(profile, opt.via, 'opt.via')
|
||||||
|
|
||||||
|
@ -245,7 +245,8 @@ const createClient = (profile, userAgent, opt = {}) => {
|
||||||
polylines: false, // return leg shapes? (not supported by all endpoints)
|
polylines: false, // return leg shapes? (not supported by all endpoints)
|
||||||
subStops: true, // parse & expose sub-stops of stations?
|
subStops: true, // parse & expose sub-stops of stations?
|
||||||
entrances: true, // parse & expose entrances of stops/stations?
|
entrances: true, // parse & expose entrances of stops/stations?
|
||||||
remarks: true // parse & expose hints & warnings?
|
remarks: true, // parse & expose hints & warnings?
|
||||||
|
scheduledDays: false, // parse & expose dates the journey is valid on?
|
||||||
}, opt)
|
}, opt)
|
||||||
|
|
||||||
const req = profile.formatRefreshJourneyReq({profile, opt}, refreshToken)
|
const req = profile.formatRefreshJourneyReq({profile, opt}, refreshToken)
|
||||||
|
|
10
readme.md
10
readme.md
|
@ -8,6 +8,8 @@
|
||||||
[](https://github.com/sponsors/derhuerst)
|
[](https://github.com/sponsors/derhuerst)
|
||||||
[](https://twitter.com/derhuerst)
|
[](https://twitter.com/derhuerst)
|
||||||
|
|
||||||
|
**[documentation](docs/readme.md)**
|
||||||
|
|
||||||
|
|
||||||
## Background
|
## Background
|
||||||
|
|
||||||
|
@ -206,11 +208,11 @@ Each [profile](p/readme.md) has more detailed example code.
|
||||||
|
|
||||||
### in the browser
|
### in the browser
|
||||||
|
|
||||||
While `hafas-client` itself should work in the browser via a bundler like [Webpack](https://webpack.js.org), most HAFAS API endpoints don't enable [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing), so you won't be able query them directly.
|
While `hafas-client` itself should work in the browser via a bundler like [Webpack](https://webpack.js.org), most HAFAS API endpoints don't allow [cross-origin resource sharing (CORS)](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing), so you won't be able query them (without a proxy server).
|
||||||
|
|
||||||
## TypeScript
|
### TypeScript
|
||||||
|
|
||||||
There are [community-maintained TypeScript typings](https://www.npmjs.com/package/@types/hafas-client).
|
There are [community-maintained TypeScript typings available as `@types/hafas-client`](https://www.npmjs.com/package/@types/hafas-client).
|
||||||
|
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
@ -248,7 +250,7 @@ There are [community-maintained TypeScript typings](https://www.npmjs.com/packag
|
||||||
- [`hafas-monitor-journeys`](https://github.com/derhuerst/hafas-monitor-journeys) – Use `hafas-client` to monitor journeys from A to B.
|
- [`hafas-monitor-journeys`](https://github.com/derhuerst/hafas-monitor-journeys) – Use `hafas-client` to monitor journeys from A to B.
|
||||||
- [`hafas-discover-stations`](https://github.com/derhuerst/hafas-discover-stations#hafas-discover-stations) – Pass in a HAFAS client, discover stations by querying departures.
|
- [`hafas-discover-stations`](https://github.com/derhuerst/hafas-discover-stations#hafas-discover-stations) – Pass in a HAFAS client, discover stations by querying departures.
|
||||||
- [`hafas-estimate-station-weight`](https://github.com/derhuerst/hafas-estimate-station-weight#hafas-estimate-station-weight) – Pass in a HAFAS client, estimate the importance of a station.
|
- [`hafas-estimate-station-weight`](https://github.com/derhuerst/hafas-estimate-station-weight#hafas-estimate-station-weight) – Pass in a HAFAS client, estimate the importance of a station.
|
||||||
- [`db-ticket`](https://github.com/envake/db-tickets) – A library to retrieve ticket information from Deutsche Bahn.
|
- [`db-tickets`](https://github.com/envake/db-tickets) – A library to retrieve ticket information from Deutsche Bahn.
|
||||||
|
|
||||||
More related libraries can be found [via the npm package index](https://www.npmjs.com/search?q=hafas).
|
More related libraries can be found [via the npm package index](https://www.npmjs.com/search?q=hafas).
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue