1.0.0 • Published 5 years ago
cts-tram-api v1.0.0
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:
Property | Type | Require | Description |
---|---|---|---|
vehicle_mode | string | false | vehicle_mode |
line_ref | string | false | line_ref |
direction_ref | string | false | direction_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:
Property | Type | Require | Description |
---|---|---|---|
monitoring_ref | string | true | monitoring_ref |
vehicule_mode | string | false | vehicule_mode |
preview_interval | string | false | preview_interval |
start_time | string | false | start_time |
line_ref | string | false | line_ref |
direction_ref | number | false | direction_ref |
maximum_stop_visits | number | false | maximum_stop_visits |
minimum_stop_visits_per_line | number | false | minimum_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:
Property | Type | Require | Description |
---|---|---|---|
latitude | number | false | latitude |
longitude | number | false | longitude |
distance | number | false | distance |
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 API | REST API |
---|---|
v1 | v1 |
License
MIT, see LICENSE for details.
1.0.0
5 years ago