Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
vasttrafik-api
Advanced tools
Mirror of the official Västtrafik Travel Planner API client for javascript
This is a mirror of the official Västtrafik Travel Planner API Client for Javascript. For more information, see the official api website.
NodeJS (see ./example.js)
const Api = require('vasttrafik-api');
const key = '<key>';
const secret = '<secret>';
Api.authorize(key, secret).then(function() {
let api = new Api.LocationApi();
return api.getLocationByName({input: 'Lindholmen'});
}).then(function(res) {
console.log(res.text);
});
Browsers (see ./example.html)
<script src="./dist/vasttrafik.js"></script>
<script>
(function() {
// Fetch access token on server (see example.js)
// Västtrafik have blocked token generation from browsers
var token = '<access-token-placeholder>';
vasttrafik.setAccessToken(token);
// Find other api features in `./mirror/docs` or in the developer portal
var api = new vasttrafik.LocationApi();
api.getLocationByName({input: 'Lindholmen'}, function() {
console.log(res.text);
});
})();
</script>
Method | Description |
---|---|
ArrivalBoardApi.getArrivalBoard | Return the next 20 arrivals (or less if not existing) from a given point in time or the next arrivals in a given timespan. |
DepartureBoardApi.getDepartureBoard | Return the next 20 departures (or less if not existing) from a given point in time or the next departures in a given timespan. |
GeometryApi.getGeometry | Returns the polyline for a leg. |
JourneyDetailApi.getJourneyDetail | Returns information about the complete route of a trip. |
LivemapApi.livemap | Returns the positions of all vehicles in a given bounding box |
LocationApi.getAllStops | Returns a list of all stops available in the journey planner. |
LocationApi.getLocationByName | Returns a list of possible matches in the journey planner database |
LocationApi.getNearbyAddress | Returns the address nearest a given coordinate. |
LocationApi.getNearbyStops | Returns a list of stops around a given center coordinate. |
SysteminfoApi.getSystemInfo | Provides information about the journey planner and the underlying data |
TripApi.getTrip | Calculates a trip from a specified origin to a specified destination. |
If you just want to test things out you can use these sample credentials:
key
'8aOzt2RmMIG0OXSyIgjM2IkHvAoa'
secret
'OMxjxjaXblXdpn8E1gYFehHyx3Ea'
Don't forget to create your own credentials in the developer portal before going into production however since the sample ones might become invalid at any time.
This repository is mostly a simple mirror of the official api client, but a few changes were made to make it easier to work with.
Helper methods added:
client.authorize(key, secret, deviceId)
Fetches an access token with the specified key and secret and then authorizes the client with the it (cannot be used in the browser)client.setAccessToken(token)
Authorizes upcoming api calls with the specified access tokenMonkey patches:
mirror/src/ApiClient.js#448
)mirror/src/ApiClient.js#453
)You can post questions about Västtrafik's API in the developer forum. Also feel free posting issues or questions regarding this mirror here on github.
FAQs
Mirror of the official Västtrafik Travel Planner API client for javascript
We found that vasttrafik-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.