Socket
Socket
Sign inDemoInstall

insa-hafas

Package Overview
Dependencies
61
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    insa-hafas

JavaScript client for the NASA/INSA HAFAS API.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
14.8 MB
Created
Weekly downloads
 

Readme

Source

insa-hafas

A client for the public transport authority Nahverkehr Sachsen-Anhalt (NASA)/INSA. It acts as a consistent and straightforward interface on top of a verbose API.

This project is actually a thin wrapper around hafas-client@5. Its docs document the API in general.

npm version build status ISC-licensed minimum Node.js version chat on gitter support Jannis via GitHub Sponsors

Installing

npm install insa-hafas

API

Check the docs for hafas-client@5 as well as its INSA-specific customisations.

Usage

const hafas = require('insa-hafas')

As an example, we will search for a route from Berlin Jungfernheide to München Hbf. To get the station IDs, use locations(query, [opt]).

client.journeys('8011167', '8000261', {results: 1})
.then(({journeys}) => console.log(journeys[0]))
.catch(console.error)

The output will be an array of journey objects in the Friendly Public Transport Format 1.2.1 format:

{
	type: 'journey',
	legs: [{
		mode: 'walking',
		public: true

		origin: {
			type: 'station',
			id: '8010226',
			name: 'Magdeburg-Neustadt',
			location: {
				type: 'location',
				latitude: 52.148842,
				longitude: 11.641705
			},
			products: {
				nationalExp: true,
				national: true,
				regional: true,
				suburban: true,
				bus: true,
				tram: true,
				tourismTrain: true
			}
		},
		departure: '2018-03-14T03:01:00.000+01:00',
		plannedDeparture: '2018-03-14T03:01:00.000+01:00',
		departureDelay: null,

		destination: {
			type: 'station',
			id: '7368',
			name: 'Magdeburg, S-Bahnhof Neustadt (Tram)',
			location: { /* … */ },
			products: { /* … */ }
		},
		arrival: '2018-03-14T03:06:00.000+01:00',
		plannedArrival: '2018-03-14T03:06:00.000+01:00',
		arrivalDelay: null,
	}, {
		tripId: '1|86821|1|80|14032018',
		direction: 'Alter Markt',
		line: {
			type: 'line',
			id: 'n8',
			name: 'N8',
			public: true,
			product: 'tram',
			mode: 'train',
			operator: {
				type: 'operator',
				id: 'magdeburger-verkehrsbetriebe',
				name: 'Magdeburger Verkehrsbetriebe'
			}
		},

		origin: {
			type: 'station',
			id: '7368',
			name: 'Magdeburg, S-Bahnhof Neustadt (Tram)',
			location: { /* … */ },
			products: { /* … */ }
		},
		departure: '2018-03-14T03:06:00.000+01:00',
		plannedDeparture: '2018-03-14T03:05:00.000+01:00',
		departureDelay: 60,
		departurePlatform: null,
		plannedDeparturePlatform: null,

		destination: {
			type: 'station',
			id: '7333',
			name: 'Magdeburg, Alter Markt',
			location: { /* … */ },
			products: { /* … */ }
		},
		arrival: '2018-03-14T03:12:00.000+01:00',
		plannedArrival: '2018-03-14T03:12:00.000+01:00',
		arrivalDelay: 0,
		arrivalPlatform: '2a',
		plannedArrivalPlatform: '1',

		alternatives: [{
			line: {
				type: 'line',
				id: 'str-n8',
				name: 'Str N8',
				public: true,
				product: 'tram',
				mode: 'train'
			},
			when: '2018-03-14T04:06:00.000+01:00'
		}]
	} /* … */ ]
}

Check hafas-client's related libs.

Contributing

If you have a question, found a bug or want to propose a feature, have a look at the issues page.

Keywords

FAQs

Last updated on 13 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc