tweak & restructure docs 📝, explicit defaults

This commit is contained in:
Jannis R 2022-10-24 17:30:05 +02:00
parent c88179777d
commit 5ff8527b60
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
5 changed files with 30 additions and 24 deletions

17
docs/api.md Normal file
View 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

View file

@ -16,8 +16,8 @@
## `5.25.0`
- 0a636981 parse `CHKI` (check-in, check-out) legs ✅
- 7c68f962 `parse{Stopover,JourneyLeg, Trip}`: expose `{arrival,departure}PrognosisType`
- 0a636981 parse `CHKI` (check-in, check-out) legs ✅ Thanks @yu-re-ka!
- 7c68f962 `parse{Stopover,JourneyLeg, Trip}`: expose `{arrival,departure}PrognosisType` Thanks @HybridFox!
- 95af0a01 `parseArrival` & `parseDeparture`: expose `prognosisType`
[🏷 `5.25.0`](https://github.com/public-transport/hafas-client/releases/tag/5.25.0), 2022-07-30

View file

@ -1,20 +1,6 @@
# API documentation
# `hafas-client` documentation
- [`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
**[API documentation](api.md)**
## Migrating from an old `hafas-client` version

View file

@ -139,7 +139,7 @@ const createClient = (profile, userAgent, opt = {}) => {
subStops: true, // parse & expose sub-stops of stations?
entrances: true, // parse & expose entrances of stops/stations?
remarks: true, // parse & expose hints & warnings?
scheduledDays: false
scheduledDays: false, // parse & expose dates each journey is valid on?
}, opt)
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)
subStops: true, // parse & expose sub-stops of 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)
const req = profile.formatRefreshJourneyReq({profile, opt}, refreshToken)

View file

@ -8,6 +8,8 @@
[![support Jannis via GitHub Sponsors](https://img.shields.io/badge/support%20Jannis-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)
[![chat with Jannis on Twitter](https://img.shields.io/badge/chat%20with%20Jannis-on%20Twitter-1da1f2.svg)](https://twitter.com/derhuerst)
**[documentation](docs/readme.md)**
## Background
@ -206,11 +208,11 @@ Each [profile](p/readme.md) has more detailed example code.
### 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
@ -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-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.
- [`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).