1.10.1 • Published 6 years ago

reseplaneraren v1.10.1

Weekly downloads
1
License
Unlicense
Repository
-
Last release
6 years ago

reseplaneraren

Reseplaneraren - JavaScript client for reseplaneraren Provides access to Västtrafik journey planner This SDK is automatically generated by the Swagger Codegen project:

  • API version: 1.10.1
  • Package version: 1.10.1
  • Build package: io.swagger.codegen.languages.JavascriptClientCodegen For more information, please visit api@vasttrafik.se

Installation

For Node.js

npm

To publish the library as a npm, please follow the procedure in "Publishing npm packages".

Then install it via:

npm install reseplaneraren --save
Local development

To use the library locally without publishing to a remote npm registry, first install the dependencies by changing into the directory containing package.json (and this README). Let's call this JAVASCRIPT_CLIENT_DIR. Then run:

npm install

Next, link it globally in npm with the following, also from JAVASCRIPT_CLIENT_DIR:

npm link

Finally, switch to the directory you want to use your reseplaneraren from, and run:

npm link /path/to/<JAVASCRIPT_CLIENT_DIR>

You should now be able to require('reseplaneraren') in javascript files from the directory you ran the last command above from.

git

If the library is hosted at a git repository, e.g. https://github.com/YOUR_USERNAME/reseplaneraren then install it via:

    npm install YOUR_USERNAME/reseplaneraren --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file, that's to say your javascript file where you actually use this library):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Webpack Configuration

Using Webpack you may encounter the following error: "Module not found: Error: Cannot resolve module", most certainly you should disable AMD loader. Add/merge the following section to your webpack config:

module: {
  rules: [
    {
      parser: {
        amd: false
      }
    }
  ]
}

Getting Started

Please follow the installation instruction and execute the following JS code:

var Reseplaneraren = require('reseplaneraren');

var api = new Reseplaneraren.ArrivalBoardApi()

var id = 789; // {Number} stop id

var _date = new Date("2013-10-20"); // {Date} the date

var time = "time_example"; // {String} the time in format HH:MM

var direction = 789; // {Number} stop id in order to get only departures of vehicles with a specified direction

var opts = { 
  'useVas': "useVas_example", // {String} to exclude trips with Västtågen, set this parameter to 0.
  'useLDTrain': "useLDTrain_example", // {String} to exclude trips with long distance trains, set this parameter to 0.
  'useRegTrain': "useRegTrain_example", // {String} to exclude trips with regional trains, set this parameter to 0.
  'useBus': "useBus_example", // {String} to exclude trips with buses, set this parameter to 0.
  'useBoat': "useBoat_example", // {String} to exclude trips with boats, set this parameter to 0.
  'useTram': "useTram_example", // {String} to exclude trips with trams, set this parameter to 0.
  'excludeDR': "excludeDR_example", // {String} to exclude journeys which require tel. registration, set this parameter to 0.
  'timeSpan': 56, // {Number} to get the next departures in a specified timespan of up to 24 hours (unit: minutes). If this parameter is not set, the result will contain the next 20 departures.
  'maxDeparturesPerLine': 56, // {Number} if timeSpan is set you can further reduce the number of returned journeys by adding this parameter, which will cause only the given number of journeys for every combination of line and direction.
  'needJourneyDetail': "needJourneyDetail_example", // {String} if the reference URL for the journey detail service is not needed in the result, set this parameter to 0
  'format': "format_example", // {String} the required response format
  'jsonpCallback': "jsonpCallback_example" // {String} If JSONP response format is needed, you can append an additional parameter to specify the name of a callback function, and the JSON object will be wrapped by a function call with this name.
};

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.getArrivalBoard(id, _date, time, direction, opts, callback);

Documentation for API Endpoints

All URIs are relative to https://api.vasttrafik.se/bin/rest.exe/v2

ClassMethodHTTP requestDescription
Reseplaneraren.ArrivalBoardApigetArrivalBoardGET /arrivalBoardReturn the next 20 arrivals (or less if not existing) from a given point in time or the next arrivals in a given timespan.
Reseplaneraren.DepartureBoardApigetDepartureBoardGET /departureBoardReturn the next 20 departures (or less if not existing) from a given point in time or the next departures in a given timespan.
Reseplaneraren.GeometryApigetGeometryGET /geometryReturns the polyline for a leg.
Reseplaneraren.JourneyDetailApigetJourneyDetailGET /journeyDetailReturns information about the complete route of a trip.
Reseplaneraren.LivemapApilivemapGET /livemapReturns the positions of all vehicles in a given bounding box
Reseplaneraren.LocationApigetAllStopsGET /location.allstopsReturns a list of all stops available in the journey planner.
Reseplaneraren.LocationApigetLocationByNameGET /location.nameReturns a list of possible matches in the journey planner database
Reseplaneraren.LocationApigetNearbyAddressGET /location.nearbyaddressReturns the address nearest a given coordinate.
Reseplaneraren.LocationApigetNearbyStopsGET /location.nearbystopsReturns a list of stops around a given center coordinate.
Reseplaneraren.SysteminfoApigetSystemInfoGET /systeminfoProvides information about the journey planner and the underlying data
Reseplaneraren.TripApigetTripGET /tripCalculates a trip from a specified origin to a specified destination.

Documentation for Models

Documentation for Authorization

All endpoints do not require authorization.

1.10.1

6 years ago