docs: make user agent instructions more specific & actionable 📝

related: #286
This commit is contained in:
Jannis R 2023-03-14 20:32:50 +01:00
parent 0f3d6ec858
commit 5910d62535
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
58 changed files with 179 additions and 68 deletions

View file

@ -46,7 +46,8 @@ If you pass an object `opt.products`, its fields will partially override the def
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const client = createClient(vbbProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(vbbProfile, userAgent)
// will query with these products: suburban, subway, bus, express, regional // will query with these products: suburban, subway, bus, express, regional
await client.departures('900000024101', {products: {tram: false, ferry: false}}) await client.departures('900000024101', {products: {tram: false, ferry: false}})
@ -64,7 +65,8 @@ As an example, we're going to use the [VBB profile](../p/vbb):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const client = createClient(vbbProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(vbbProfile, userAgent)
// S Charlottenburg // S Charlottenburg
const { const {

View file

@ -25,12 +25,13 @@ As an example, we're going to use the [*Deutsche Bahn* profile](../p/db):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as dbProfile} from 'hafas-client/p/db/index.js' import {profile as dbProfile} from 'hafas-client/p/db/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(dbProfile, userAgent)
const berlinSüdkreuz = '8011113' const berlinSüdkreuz = '8011113'
const münchenHbf = '8000261' const münchenHbf = '8000261'
const kölnHbf = '8000207' const kölnHbf = '8000207'
const client = createClient(dbProfile, 'my-awesome-program')
// find any journey from Berlin Südkreuz to München Hbf // find any journey from Berlin Südkreuz to München Hbf
const [journey] = await client.journeys(berlinSüdkreuz, münchenHbf, {results: 1, stopovers: true}) const [journey] = await client.journeys(berlinSüdkreuz, münchenHbf, {results: 1, stopovers: true})
// find the ICE leg // find the ICE leg

View file

@ -88,7 +88,8 @@ As an example, we're going to use the [VBB profile](../p/vbb):
import {createClient} 'hafas-client' import {createClient} 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const client = createClient(vbbProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(vbbProfile, userAgent)
// Hauptbahnhof to Heinrich-Heine-Str. // Hauptbahnhof to Heinrich-Heine-Str.
await client.journeys('900000003201', '900000100008', { await client.journeys('900000003201', '900000100008', {

View file

@ -10,7 +10,8 @@ As an example, we're going to use the [SVV profile](../p/svv):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as svvProfile} from 'hafas-client/p/svv/index.js' import {profile as svvProfile} from 'hafas-client/p/svv/index.js'
const client = createClient(svvProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(svvProfile, userAgent)
const { const {
lines, lines,

View file

@ -26,7 +26,8 @@ As an example, we're going to use the [VBB profile](../p/vbb):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const client = createClient(vbbProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(vbbProfile, userAgent)
await client.locations('Alexanderplatz', {results: 3}) await client.locations('Alexanderplatz', {results: 3})
``` ```

View file

@ -27,7 +27,8 @@ As an example, we're going to use the [VBB profile](../p/vbb):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const client = createClient(vbbProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(vbbProfile, userAgent)
await client.nearby({ await client.nearby({
type: 'location', type: 'location',

View file

@ -28,7 +28,8 @@ As an example, we're going to use the [VBB profile](../p/vbb):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const client = createClient(vbbProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(vbbProfile, userAgent)
const { const {
movements, movements,

View file

@ -34,7 +34,8 @@ As an example, we're going to use the [VBB profile](../p/vbb):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const client = createClient(vbbProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(vbbProfile, userAgent)
const { const {
reachable, reachable,

View file

@ -15,19 +15,21 @@ import {createClient} from 'hafas-client'
import {withThrottling} from 'hafas-client/throttle.js' import {withThrottling} from 'hafas-client/throttle.js'
import {profile as dbProfile} from 'hafas-client/p/db/index.js' import {profile as dbProfile} from 'hafas-client/p/db/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a throttled HAFAS client with Deutsche Bahn profile // create a throttled HAFAS client with Deutsche Bahn profile
const client = createClient(withThrottling(dbProfile), 'my-awesome-program') const client = createClient(withThrottling(dbProfile), userAgent)
// Berlin Jungfernheide to München Hbf // Berlin Jungfernheide to München Hbf
await client.journeys('8011167', '8000261', {results: 1}) await client.journeys('8011167', '8000261', {results: 1})
``` ```
You can pass custom values for the nr of requests (`limit`) per interval into `withThrottling`: You can also pass custom values for the nr of requests (`limit`) per interval into `withThrottling`:
```js ```js
// 2 requests per second // 2 requests per second
const throttledDbProfile = withThrottling(dbProfile, 2, 1000) const throttledDbProfile = withThrottling(dbProfile, 2, 1000)
const client = createClient(throttledDbProfile, 'my-awesome-program') const client = createClient(throttledDbProfile, userAgent)
``` ```
## Retrying failed requests ## Retrying failed requests
@ -39,8 +41,10 @@ import {createClient} from 'hafas-client'
import {withRetrying} from 'hafas-client/retry.js' import {withRetrying} from 'hafas-client/retry.js'
import {profile as dbProfile} from 'hafas-client/p/db/index.js' import {profile as dbProfile} from 'hafas-client/p/db/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with Deutsche Bahn profile that will retry on HAFAS errors // create a client with Deutsche Bahn profile that will retry on HAFAS errors
const client = createClient(withRetrying(dbProfile), 'my-awesome-program') const client = createClient(withRetrying(dbProfile), userAgent)
``` ```
You can pass custom options into `withRetrying`. They will be passed into [`retry`](https://github.com/tim-kos/node-retry#tutorial). You can pass custom options into `withRetrying`. They will be passed into [`retry`](https://github.com/tim-kos/node-retry#tutorial).
@ -52,7 +56,7 @@ const retryingDbProfile = withRetrying(dbProfile, {
minTimeout: 10 * 1000, minTimeout: 10 * 1000,
factor: 3 factor: 3
}) })
const client = createClient(retryingDbProfile, 'my-awesome-program') const client = createClient(retryingDbProfile, userAgent)
``` ```
## User agent randomization ## User agent randomization
@ -62,7 +66,9 @@ By default, `hafas-client` randomizes the client name that you pass into `create
```js ```js
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
// … // …
const client = createClient(someProfile, 'my-awesome-program')
const userAgent = 'my-awesome-program'
const client = createClient(someProfile, userAgent)
await client.journeys(/* … */) await client.journeys(/* … */)
// User-Agent: my-awee70429some-pre70429ogram // User-Agent: my-awee70429some-pre70429ogram
@ -76,7 +82,7 @@ You can turn this off by setting `profile.randomizeUserAgent` to `false`:
const client = createClient({ const client = createClient({
...someProfile, ...someProfile,
randomizeUserAgent: false, randomizeUserAgent: false,
}, 'my-awesome-program') }, userAgent)
``` ```
## Logging requests ## Logging requests
@ -89,6 +95,8 @@ As an example, we can implement a custom logger:
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as dbProfile} from 'hafas-client/p/db/index.js' import {profile as dbProfile} from 'hafas-client/p/db/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const logRequest = (ctx, fetchRequest, requestId) => { const logRequest = (ctx, fetchRequest, requestId) => {
// ctx looks just like with the other profile.* hooks: // ctx looks just like with the other profile.* hooks:
const {dbProfile, opt} = ctx const {dbProfile, opt} = ctx
@ -105,7 +113,7 @@ const client = createClient({
...dbProfile, ...dbProfile,
logRequest, logRequest,
logResponse, logResponse,
}, 'my-awesome-program') }, userAgent)
``` ```
```js ```js

View file

@ -24,7 +24,8 @@ As an example, we're going to use the [VBB profile](../p/vbb):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const client = createClient(vbbProfile) const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(vbbProfile, userAgent)
// Hauptbahnhof to Heinrich-Heine-Str. // Hauptbahnhof to Heinrich-Heine-Str.
const {journeys} = await client.journeys('900000003201', '900000100008', {results: 1}) const {journeys} = await client.journeys('900000003201', '900000100008', {results: 1})

View file

@ -23,7 +23,8 @@ As an example, we're going to use the [SVV profile](../p/svv):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as svvProfile} from 'hafas-client/p/svv/index.js' import {profile as svvProfile} from 'hafas-client/p/svv/index.js'
const client = createClient(svvProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(svvProfile, userAgent)
const { const {
remarks, remarks,

View file

@ -19,7 +19,8 @@ As an example, we're going to use the [SVV profile](../p/svv):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as svvProfile} from 'hafas-client/p/svv/index.js' import {profile as svvProfile} from 'hafas-client/p/svv/index.js'
const client = createClient(svvProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(svvProfile, userAgent)
await client.serverInfo() await client.serverInfo()
``` ```

View file

@ -38,7 +38,8 @@ As an example, we're going to use the [VBB profile](../p/vbb):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const client = createClient(vbbProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(vbbProfile, userAgent)
await client.stop('900000042101') // U Spichernstr. await client.stop('900000042101') // U Spichernstr.
``` ```

View file

@ -10,7 +10,8 @@ Let's say you used [`journeys`](journeys.md) and now want to get more up-to-date
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const client = createClient(vbbProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(vbbProfile, userAgent)
// Hauptbahnhof to Heinrich-Heine-Str. // Hauptbahnhof to Heinrich-Heine-Str.
const {journeys} = client.journeys('900000003201', '900000100008', {results: 1}) const {journeys} = client.journeys('900000003201', '900000100008', {results: 1})

View file

@ -10,7 +10,8 @@ As an example, we're going to use the [VBB profile](../p/vbb):
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const client = createClient(vbbProfile, 'my-awesome-program') const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
const client = createClient(vbbProfile, userAgent)
const { const {
trips, trips,

View file

@ -8,6 +8,8 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as avvProfile} from 'hafas-client/p/avv/index.js' import {profile as avvProfile} from 'hafas-client/p/avv/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with AVV profile // create a client with AVV profile
const client = createClient(avvProfile, 'my-awesome-program') const client = createClient(avvProfile, userAgent)
``` ```

View file

@ -8,6 +8,8 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as bartProfile} from 'hafas-client/p/bart/index.js' import {profile as bartProfile} from 'hafas-client/p/bart/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with BART profile // create a client with BART profile
const client = createClient(bartProfile, 'my-awesome-program') const client = createClient(bartProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as blsProfile} from 'hafas-client/p/bls/index.js' import {profile as blsProfile} from 'hafas-client/p/bls/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with BLS profile // create a client with BLS profile
const client = createClient(blsProfile, 'my-awesome-program') const client = createClient(blsProfile, userAgent)
``` ```
Check out the [code examples](example.js). Check out the [code examples](example.js).

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as bvgProfile} from 'hafas-client/p/bvg/index.js' import {profile as bvgProfile} from 'hafas-client/p/bvg/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with BVG profile // create a client with BVG profile
const client = createClient(bvgProfile, 'my-awesome-program') const client = createClient(bvgProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@ The [*Société Nationale des Chemins de Fer Luxembourgeois (CFL)*](https://en.w
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as cflProfile} from 'hafas-client/p/cfl/index.js' import {profile as cflProfile} from 'hafas-client/p/cfl/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with CFL profile // create a client with CFL profile
const client = createClient(cflProfile, 'my-awesome-program') const client = createClient(cflProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as cmtaProfile} from 'hafas-client/p/cmta/index.js' import {profile as cmtaProfile} from 'hafas-client/p/cmta/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with CMTA profile // create a client with CMTA profile
const client = createClient(cmtaProfile, 'my-awesome-program') const client = createClient(cmtaProfile, userAgent)
``` ```

View file

@ -10,8 +10,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as dartProfile} from 'hafas-client/p/dart/index.js' import {profile as dartProfile} from 'hafas-client/p/dart/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with DART profile // create a client with DART profile
const client = createClient(dartProfile, 'my-awesome-program') const client = createClient(dartProfile, userAgent)
``` ```
Check out the [code examples](example.js). Check out the [code examples](example.js).

View file

@ -14,6 +14,8 @@ This profile adapts `hafas-client` to the HAFAS endpoint used by the application
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as dbbusradarnrwProfile} from 'hafas-client/p/db-busradar-nrw/index.js' import {profile as dbbusradarnrwProfile} from 'hafas-client/p/db-busradar-nrw/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with DB Busradar NRW profile // create a client with DB Busradar NRW profile
const client = createClient(dbbusradarnrwProfile, 'my-awesome-program') const client = createClient(dbbusradarnrwProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as dbProfile} from 'hafas-client/p/db/index.js' import {profile as dbProfile} from 'hafas-client/p/db/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with DB profile // create a client with DB profile
const client = createClient(dbProfile, 'my-awesome-program') const client = createClient(dbProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@ The [Nahverkehr Sachsen-Anhalt (NASA)](https://de.wikipedia.org/wiki/Nahverkehrs
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as insaProfile} from 'hafas-client/p/insa/index.js' import {profile as insaProfile} from 'hafas-client/p/insa/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with INSA profile // create a client with INSA profile
const client = createClient(insaProfile, 'my-awesome-program') const client = createClient(insaProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as invgProfile} from 'hafas-client/p/invg/index.js' import {profile as invgProfile} from 'hafas-client/p/invg/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with INVG profile // create a client with INVG profile
const client = createClient(invgProfile, 'my-awesome-program') const client = createClient(invgProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@ The [*Iarnród Éireann* (Irish Rail)](https://en.wikipedia.org/wiki/Iarnród_É
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as irishProfile} from 'hafas-client/p/irish-rail/index.js' import {profile as irishProfile} from 'hafas-client/p/irish-rail/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with Irish Rail profile // create a client with Irish Rail profile
const client = createClient(irishProfile, 'my-awesome-program') const client = createClient(irishProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as ivbProfile} from 'hafas-client/p/ivb/index.js' import {profile as ivbProfile} from 'hafas-client/p/ivb/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with IVB profile // create a client with IVB profile
const client = createClient(ivbProfile, 'my-awesome-program') const client = createClient(ivbProfile, userAgent)
``` ```
Check out the [code examples](example.js). Check out the [code examples](example.js).

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as kvbProfile} from 'hafas-client/p/kvb/index.js' import {profile as kvbProfile} from 'hafas-client/p/kvb/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with KVB profile // create a client with KVB profile
const client = createClient(kvbProfile, 'my-awesome-program') const client = createClient(kvbProfile, userAgent)
``` ```
Check out the [code examples](example.js). Check out the [code examples](example.js).

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as mobilNrwProfile} from 'hafas-client/p/mobil-nrw/index.js' import {profile as mobilNrwProfile} from 'hafas-client/p/mobil-nrw/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with mobil.nrw profile // create a client with mobil.nrw profile
const client = createClient(mobilNrwProfile) const client = createClient(mobilNrwProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as mobiliteitProfile} from 'hafas-client/p/mobiliteit-lu/index.js' import {profile as mobiliteitProfile} from 'hafas-client/p/mobiliteit-lu/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with mobiliteit.lu profile // create a client with mobiliteit.lu profile
const client = createClient(mobiliteitProfile, 'my-awesome-program') const client = createClient(mobiliteitProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as nahshProfile} from 'hafas-client/p/nahsh/index.js' import {profile as nahshProfile} from 'hafas-client/p/nahsh/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with NAH.SH profile // create a client with NAH.SH profile
const client = createClient(nahshProfile, 'my-awesome-program') const client = createClient(nahshProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as nvvProfile} from 'hafas-client/p/nvv/index.js' import {profile as nvvProfile} from 'hafas-client/p/nvv/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with NVV profile // create a client with NVV profile
const client = createClient(nvvProfile, 'my-awesome-program') const client = createClient(nvvProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as oebbProfile} from 'hafas-client/p/oebb/index.js' import {profile as oebbProfile} from 'hafas-client/p/oebb/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with ÖBB profile // create a client with ÖBB profile
const client = createClient(oebbProfile, 'my-awesome-program') const client = createClient(oebbProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as ooevvProfile} from 'hafas-client/p/ooevv/index.js' import {profile as ooevvProfile} from 'hafas-client/p/ooevv/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with OÖVV profile // create a client with OÖVV profile
const client = createClient(ooevvProfile, 'my-awesome-program') const client = createClient(ooevvProfile, userAgent)
``` ```
Check out the [code examples](example.js). Check out the [code examples](example.js).

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as pkpProfile} from 'hafas-client/p/pkp/index.js' import {profile as pkpProfile} from 'hafas-client/p/pkp/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with PKP profile // create a client with PKP profile
const client = createClient(pkpProfile, 'my-awesome-program') const client = createClient(pkpProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as rejseplanenProfile} from 'hafas-client/p/rejseplanen/index.js' import {profile as rejseplanenProfile} from 'hafas-client/p/rejseplanen/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with Rejseplanen profile // create a client with Rejseplanen profile
const client = createClient(rejseplanenProfile) const client = createClient(rejseplanenProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as rmvProfile} from 'hafas-client/p/rmv/index.js' import {profile as rmvProfile} from 'hafas-client/p/rmv/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with RMV profile // create a client with RMV profile
const client = createClient(rmvProfile, 'my-awesome-program') const client = createClient(rmvProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as rsagProfile} from 'hafas-client/p/rsag/index.js' import {profile as rsagProfile} from 'hafas-client/p/rsag/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with RSAG profile // create a client with RSAG profile
const client = createClient(rsagProfile, 'my-awesome-program') const client = createClient(rsagProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as saarfahrplanProfile} from 'hafas-client/p/saarfahrplan/index.js' import {profile as saarfahrplanProfile} from 'hafas-client/p/saarfahrplan/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with Saarfahrplan profile // create a client with Saarfahrplan profile
const client = createClient(saarfahrplanProfile, 'my-awesome-program') const client = createClient(saarfahrplanProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@ The government of [Salzburg](https://en.wikipedia.org/wiki/Salzburg) operates a
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as salzburgProfile} from 'hafas-client/p/salzburg/index.js' import {profile as salzburgProfile} from 'hafas-client/p/salzburg/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with Salzburg profile // create a client with Salzburg profile
const client = createClient(salzburgProfile, 'my-awesome-program') const client = createClient(salzburgProfile, userAgent)
``` ```
Check out the [code examples](example.js). Check out the [code examples](example.js).

View file

@ -8,6 +8,8 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as sMuenchenProfile} from 'hafas-client/p/sbahn-muenchen/index.js' import {profile as sMuenchenProfile} from 'hafas-client/p/sbahn-muenchen/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with S-Bahn München profile // create a client with S-Bahn München profile
const client = createClient(sMuenchenProfile, 'my-awesome-program') const client = createClient(sMuenchenProfile, userAgent)
``` ```

View file

@ -10,8 +10,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as sncbProfile} from 'hafas-client/p/sncb/index.js' import {profile as sncbProfile} from 'hafas-client/p/sncb/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with SNCB profile // create a client with SNCB profile
const client = createClient(sncbProfile, 'my-awesome-program') const client = createClient(sncbProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as stvProfile} from 'hafas-client/p/stv/index.js' import {profile as stvProfile} from 'hafas-client/p/stv/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with STV profile // create a client with STV profile
const client = createClient(stvProfile, 'my-awesome-program') const client = createClient(stvProfile, userAgent)
``` ```
Check out the [code examples](example.js). Check out the [code examples](example.js).

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as svvProfile} from 'hafas-client/p/svv/index.js' import {profile as svvProfile} from 'hafas-client/p/svv/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with SVV profile // create a client with SVV profile
const client = createClient(svvProfile, 'my-awesome-program') const client = createClient(svvProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as tpgProfile} from 'hafas-client/p/tpg/index.js' import {profile as tpgProfile} from 'hafas-client/p/tpg/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with TPG profile // create a client with TPG profile
const client = createClient(tpgProfile, 'my-awesome-program') const client = createClient(tpgProfile, userAgent)
``` ```
Check out the [code examples](example.js). Check out the [code examples](example.js).

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js' import {profile as vbbProfile} from 'hafas-client/p/vbb/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with VBB profile // create a client with VBB profile
const client = createClient(vbbProfile, 'my-awesome-program') const client = createClient(vbbProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@ The [*Verkehrsverbund Bremen/Niedersachsen (VBN)*](https://de.wikipedia.org/wiki
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vbnProfile} from 'hafas-client/p/vbn/index.js' import {profile as vbnProfile} from 'hafas-client/p/vbn/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with VBN profile // create a client with VBN profile
const client = createClient(vbnProfile, 'my-awesome-program') const client = createClient(vbnProfile, userAgent)
``` ```

View file

@ -8,6 +8,8 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vkgProfile} from 'hafas-client/p/vkg/index.js' import {profile as vkgProfile} from 'hafas-client/p/vkg/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with VKG profile // create a client with VKG profile
const client = createClient(vkgProfile, 'my-awesome-program') const client = createClient(vkgProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vmtProfile} from 'hafas-client/p/vmt/index.js' import {profile as vmtProfile} from 'hafas-client/p/vmt/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with VMT profile // create a client with VMT profile
const client = createClient(vmtProfile, 'my-awesome-program') const client = createClient(vmtProfile, userAgent)
``` ```
## Customisations ## Customisations

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vorProfile} from 'hafas-client/p/vor/index.js' import {profile as vorProfile} from 'hafas-client/p/vor/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with VOR profile // create a client with VOR profile
const client = createClient(vorProfile, 'my-awesome-program') const client = createClient(vorProfile, userAgent)
``` ```
Check out the [code examples](example.js). Check out the [code examples](example.js).

View file

@ -8,6 +8,8 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vosProfile} from 'hafas-client/p/vos/index.js' import {profile as vosProfile} from 'hafas-client/p/vos/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with VOS profile // create a client with VOS profile
const client = createClient(vosProfile, 'my-awesome-program') const client = createClient(vosProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vrnProfile} from 'hafas-client/p/vrn/index.js' import {profile as vrnProfile} from 'hafas-client/p/vrn/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with VRN profile // create a client with VRN profile
const client = createClient(vrnProfile, 'my-awesome-program') const client = createClient(vrnProfile, userAgent)
``` ```

View file

@ -6,8 +6,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vsnProfile} from 'hafas-client/p/vsn/index.js' import {profile as vsnProfile} from 'hafas-client/p/vsn/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with VSN profile // create a client with VSN profile
const client = createClient(vsnProfile, 'my-awesome-program') const client = createClient(vsnProfile, userAgent)
``` ```
## Customisations ## Customisations

View file

@ -8,6 +8,8 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vvtProfile} from 'hafas-client/p/vvt/index.js' import {profile as vvtProfile} from 'hafas-client/p/vvt/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with VVT profile // create a client with VVT profile
const client = createClient(vvtProfile, 'my-awesome-program') const client = createClient(vvtProfile, userAgent)
``` ```

View file

@ -8,8 +8,10 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as vvvProfile} from 'hafas-client/p/vvv/index.js' import {profile as vvvProfile} from 'hafas-client/p/vvv/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with VVV profile // create a client with VVV profile
const client = createClient(vvvProfile, 'my-awesome-program') const client = createClient(vvvProfile, userAgent)
``` ```
Check out the [code examples](example.js). Check out the [code examples](example.js).

View file

@ -8,6 +8,8 @@
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as zvvProfile} from 'hafas-client/p/zvv/index.js' import {profile as zvvProfile} from 'hafas-client/p/zvv/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with ZVV profile // create a client with ZVV profile
const client = createClient(zvvProfile, 'my-awesome-program') const client = createClient(zvvProfile, userAgent)
``` ```

View file

@ -45,14 +45,18 @@ npm install hafas-client
## Usage ## Usage
Pick the [profile](p/readme.md) for the HAFAS endpoint covering the area you want to get data for. Pass the profile and a descriptive name for your program into the `createClient` function: Pick the [profile](p/readme.md) for the HAFAS endpoint covering the area you want to get data for.
Because the operatores of the HAFAS endpoint should be able to contact you about excessive traffic, please pass a link to your project/program (or an email address) into `createClient()`:
```js ```js
import {createClient} from 'hafas-client' import {createClient} from 'hafas-client'
import {profile as dbProfile} from 'hafas-client/p/db/index.js' import {profile as dbProfile} from 'hafas-client/p/db/index.js'
const userAgent = 'link-to-your-project-or-email' // adapt this to your project!
// create a client with the Deutsche Bahn profile // create a client with the Deutsche Bahn profile
const client = createClient(dbProfile, 'my-awesome-program') const client = createClient(dbProfile, userAgent)
``` ```
You can now use `client` to query the HAFAS endpoint configured in the [`db` profile](p/db): You can now use `client` to query the HAFAS endpoint configured in the [`db` profile](p/db):