1.0.0 • Published 5 years ago

cts-tram-api v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

CTS Tram API

API from "Compagnie des transports strasbourgeois". For more informations go to CTS Portail Open Data and API service

Installation

npm install --save cts-tram-api

or

<script src="https://cdn.jsdelivr.net/gh/w-jerome/cts-tram-api/dist/cts-tram-api.min.js"></script>

Usage

import CTSTramAPI from 'cts-tram-api';

const cts_tram_api = new CTSTramAPI('my_api_key');

Methods

Estimated Timetable

// ES6
cts_tram_api.estimatedTimetable()
  .then(estimated_timetables => {
    console.log(estimated_timetables);
  })
  .catch(error => {
    console.error(error);
  });

// ES5
cts_tram_api.estimatedTimetable(function(estimated_timetables, error) {
  if (error) {
    console.error(error);
    return false;
  }

  console.log(estimated_timetables);
});

Configuration properties:

PropertyTypeRequireDescription
vehicle_modestringfalsevehicle_mode
line_refstringfalseline_ref
direction_refstringfalsedirection_ref

Example:

// ES6
cts_tram_api.estimatedTimetable(vehicle_mode, line_ref, direction_ref)

// ES5
cts_tram_api.estimatedTimetable(function() {}, vehicle_mode, line_ref, direction_ref)

Stop Monitoring

// ES6
cts_tram_api.stopMonitoring('233A')
  .then(stop_monitoring => {
    console.log(stop_monitoring);
  })
  .catch(error => {
    console.error(error);
  });

// ES5
cts_tram_api.stopMonitoring(function(stop_monitoring, error) {
  if (error) {
    console.error(error);
    return false;
  }

  console.log(stop_monitoring);
}, '233A');

Configuration properties:

PropertyTypeRequireDescription
monitoring_refstringtruemonitoring_ref
vehicule_modestringfalsevehicule_mode
preview_intervalstringfalsepreview_interval
start_timestringfalsestart_time
line_refstringfalseline_ref
direction_refnumberfalsedirection_ref
maximum_stop_visitsnumberfalsemaximum_stop_visits
minimum_stop_visits_per_linenumberfalseminimum_stop_visits_per_line

Example:

// ES6
cts_tram_api.stopMonitoring(monitoring_ref, vehicule_mode, preview_interval, start_time, line_ref, direction_ref, maximum_stop_visits, minimum_stop_visits_per_line)

// ES5
cts_tram_api.stopMonitoring(function() {}, monitoring_ref, vehicule_mode, preview_interval, start_time, line_ref, direction_ref, maximum_stop_visits, minimum_stop_visits_per_line)

Stop Points Discovery

// ES6
cts_tram_api.stopPointsDiscovery()
  .then(stop_points => {
    console.log(stop_points);
  })
  .catch(error => {
    console.error(error);
  });

// ES5
cts_tram_api.stopPointsDiscovery(function(stop_points, error) {
  if (error) {
    console.error(error);
    return false;
  }

  console.log(stop_points);
});

Configuration properties:

PropertyTypeRequireDescription
latitudenumberfalselatitude
longitudenumberfalselongitude
distancenumberfalsedistance

Example:

// ES6
cts_tram_api.stopPointsDiscovery(latitude, longitude, distance)

// ES5
cts_tram_api.stopPointsDiscovery(function() {}, latitude, longitude, distance)

Lines Discovery

// ES6
cts_tram_api.linesDiscovery()
  .then(lines => {
    console.log(lines);
  })
  .catch(error => {
    console.error(error);
  });

// ES5
cts_tram_api.linesDiscovery(function(lines, error) {
  if (error) {
    console.error(error);
    return false;
  }

  console.log(lines);
});

Version update

CTS Tram APIREST API
v1v1

License

MIT, see LICENSE for details.