npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cts-client

v2.0.0

Published

Javascript client for CTS API (Compagnie des transports strasbourgeois)

Downloads

14

Readme

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:

| Property | Type | Require | | :-------------- | :------- | :------ | | vehicle_mode | string | false | | line_ref | string | false | | direction_ref | string | false |

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:

| Property | Type | Require | | :----------------------------- | :------- | :------ | | monitoring_ref | string | true | | vehicule_mode | string | false | | preview_interval | string | false | | start_time | string | false | | line_ref | string | false | | direction_ref | number | false | | maximum_stop_visits | number | false | | minimum_stop_visits_per_line | number | false |

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:

| Property | Type | Require | | :---------- | :------- | :------ | | latitude | number | false | | longitude | number | false | | distance | number | false |

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:

| Property | Type | Require | | :-------------- | :------- | :------ | | ticket_sales | boolean | false | | badgeo_top_up | boolean | false | | types | string | false | | latitude | number | false | | longitude | number | false | | distance | number | false |

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 Client | REST API | | :--------- | :------- | | 2.0 | 1.0 | | 1.0 | 1.0 |

License

MIT, see LICENSE for details.