Socket
Socket
Sign inDemoInstall

cts-client

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cts-client

Javascript client for CTS API (Compagnie des transports strasbourgeois)


Version published
Maintainers
1
Install size
42.6 kB
Created

Readme

Source

CTS Client

Javascript client for CTS API (Compagnie des transports strasbourgeois). For more informations go to CTS Portail Open Data and API service

Installation

npm install cts-client

or

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

Usage

import CTSClient from 'cts-client';

const cts_client = new CTSClient('my_api_key:');

API key information

The API key generated by the CTS portal looks something like this: my-api-key. But to use the Javascript client you need to add a colon at the end of the string, which makes my-api-key:

Request timeout

const cts_client = new CTSClient('my_api_key:', 10000); // default: 10000ms

Methods

Siri (tram and bus)

CTS

Velhop

Estimated Timetable

Estimated Timetable service is used to inform interested schedule information systems of the current status of all known VEHICLE JOURNEYs. All VEHICLE JOURNEYs currently running and all those that start in the hour are returned.

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

cts_client.estimatedTimetable(vehicle_mode, line_ref, direction_ref);

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

  console.log(estimated_timetables);
});

cts_client.estimatedTimetable(function() {}, vehicle_mode, line_ref, direction_ref);

Properties:

PropertyTypeRequire
vehicle_modestringfalse
line_refstringfalse
direction_refstringfalse

Lines Discovery

Returns a list of all lines.

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

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

  console.log(lines);
});

Stop Monitoring

Stop Monitoring service provides a stop-centric view of VEHICLE departures (in realtime) at a list of designated stops.

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

cts_client.stopMonitoring(monitoring_ref, vehicule_mode, preview_interval, start_time, line_ref, direction_ref, maximum_stop_visits, minimum_stop_visits_per_line);

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

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

cts_client.stopMonitoring(function() {}, monitoring_ref, vehicule_mode, preview_interval, start_time, line_ref, direction_ref, maximum_stop_visits, minimum_stop_visits_per_line);

Properties:

PropertyTypeRequire
monitoring_refstringtrue
vehicule_modestringfalse
preview_intervalstringfalse
start_timestringfalse
line_refstringfalse
direction_refnumberfalse
maximum_stop_visitsnumberfalse
minimum_stop_visits_per_linenumberfalse

Stop Points Discovery

Returns a list of stop points.

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

cts_client.stopPointsDiscovery(latitude, longitude, distance);

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

  console.log(stop_points);
});

cts_client.stopPointsDiscovery(function() {}, latitude, longitude, distance);

Properties:

PropertyTypeRequire
latitudenumberfalse
longitudenumberfalse
distancenumberfalse

Park and Ride

Returns a list of park and ride with available spots

// ES6
cts_client.parkAndRide()
.then(parks => {
  console.log(parks);
})
.catch(error => {
  console.error(error);
});

// ES5
cts_client.parkAndRide(function(parks, error) {
  if (error) {
    console.error(error);
    return false;
  }

  console.log(parks);
});

Retail Outlet

Returns a list of retail outlet

// ES6
cts_client.retailOutlet()
.then(retails => {
  console.log(retails);
})
.catch(error => {
  console.error(error);
});

cts_client.retailOutlet(ticket_sales, badgeo_top_up, types, latitude, longitude, distance);

// ES5
cts_client.retailOutlet(function(retails, error) {
  if (error) {
    console.error(error);
    return false;
  }

  console.log(retails);
});

cts_client.retailOutlet(function() {}, ticket_sales, badgeo_top_up, types, latitude, longitude, distance);

Properties:

PropertyTypeRequire
ticket_salesbooleanfalse
badgeo_top_upbooleanfalse
typesstringfalse
latitudenumberfalse
longitudenumberfalse
distancenumberfalse

Retail Outlet Types

Returns a list of retail outlet types.

// ES6
cts_client.retailOutletTypes()
.then(retails_types => {
  console.log(retails_types);
})
.catch(error => {
  console.error(error);
});

// ES5
cts_client.retailOutletTypes(function(retails_types, error) {
  if (error) {
    console.error(error);
    return false;
  }

  console.log(retails_types);
});

Veloparc

Returns a list of veloparc.

// ES6
cts_client.veloparc()
.then(velo_parcs => {
  console.log(velo_parcs);
})
.catch(error => {
  console.error(error);
});

// ES5
cts_client.veloparc(function(velo_parcs, error) {
  if (error) {
    console.error(error);
    return false;
  }

  console.log(velo_parcs);
});

Velhop

Returns a list of velhop automatic stations and stores.

// ES6
cts_client.velhop()
.then(velhops => {
  console.log(velhops);
})
.catch(error => {
  console.error(error);
});

// ES5
cts_client.velhop(function(velhops, error) {
  if (error) {
    console.error(error);
    return false;
  }

  console.log(velhops);
});

Version update

CTS ClientREST API
2.01.0
1.01.0

License

MIT, see LICENSE for details.

Keywords

FAQs

Last updated on 31 Jul 2019

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