Skip to content

API documentation

Axel Niklasson edited this page Aug 26, 2017 · 1 revision

API documentation

Getting started

Just load the module and start using the functions!

var nodeSkanetrafiken = require('node-skanetrafiken');

Finding stops by name

Find stops matching a query.

Options parameters

  • name - query for stop name (string) - required

Example request

nodeSkanetrafiken.findStop({ name: 'Kristianstad' }, function(results, err) {
   // Do something with the results
}); 

Find starts and stops

Finds all starts and stops matching the query.

Options parameters

  • from - query for start stop (string) - required
  • to - query for end stop (string) - required

Example request

nodeSkanetrafiken.findStartAndStop({ from: 'Kristianstad', to: 'Malmö' }, function(results, err) {
   // Do something with the results
}); 

Find all stops near a specified location

Finds all stops within a circle of a (if specified) radius.

Options parameters

  • x - coordinate in RT90 system (int) - required
  • y - coordinate in RT90 system (int) - required
  • radius - radius in meters (int) - optional

Example request

nodeSkanetrafiken.findNearestStops({ x: 6167930, y: 1323215, radius: 500 }, function(results, err) {
   // Do something with the results
}); 

List all departures/arrivals at a stop

Lists all arrivals/departures at a given stop with a set of extra parameters. Note that neither date nor time can be present alone - both are needed.

Options parameters

  • stopID - id of the stop (int) - required
  • date - date for departures/arrivals in yymmdd (string) - optional
  • time - time for departures/arrivals in hhmm (string) - optional
  • arrivals - listing departures or arrivals (bool) - optional

Example request

nodeSkanetrafiken.getDepartures({ stopID: 80000, date: '170823', time: '1630', arrivals: true }, function(results, err) {
   // Do something with the results
}); 

List means of transportation

Find the different means of transportation.

No options object needed for this function.

### Example request
nodeSkanetrafiken.getTrafficMeans(function(results, err) {
   // So something with the results
});

Search for journeys between two points

Search for journeys between to points. Note that neither date nor time can be present alone - both are needed.

Options parameters

  • next - next/previous set of journeys (string) - required
  • from - object containing info of departure point name|id|type (obj) - required
  • to - object containing info of arrival point name|id|type (obj) - required
  • limit - number of journeys (int) - optional
  • date - date for departures/arrivals in yymmdd (string) - optional
  • time - time for departures/arrivals in hhmm (string) - optional
  • transportMode - sum of trafficmeans IDs (int) - optional

Example request

var from = { name: 'Malmö C', id: 80000, type: 0 };
var to = { name: 'Landskrona', id: 82000, type: 0 };
nodeSkanetrafiken.getJourneys({ from: from, to: to, action: 'next' }, function(results, err) {
   // Do something with the results
}); 

Get journey path

I can't get this one to work with Skånetrafiken's API, so any help is much appreciated!