All Projects → simonbengtsson → vasttrafik-api

simonbengtsson / vasttrafik-api

Licence: Unlicense license
Mirror of the official Västtrafik API (reseplaneraren) for JavaScript

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to vasttrafik-api

jill.py
A cross-platform installer for the Julia programming language
Stars: ✭ 202 (+1246.67%)
Mutual labels:  mirror
quantum-space-buddies
Outer Wilds online multiplayer mod, using Mirror and OWML.
Stars: ✭ 56 (+273.33%)
Mutual labels:  mirror
foundation
This is a mirror from https://github.com/laravel/framework/tree/9.x/src/Illuminate/Foundation
Stars: ✭ 26 (+73.33%)
Mutual labels:  mirror
copybara-action
Transform and move code between repositories. Start with ZERO config and 100% customizable.
Stars: ✭ 69 (+360%)
Mutual labels:  mirror
mirror-cache
A customizable reverse proxy with cache
Stars: ✭ 23 (+53.33%)
Mutual labels:  mirror
kuebikobot
A telegram bot that deploys to heroku/aws and downloads links and torrents and uploads to google drive and returns public share link
Stars: ✭ 127 (+746.67%)
Mutual labels:  mirror
lyx
Unofficial mirror of git://git.lyx.org/lyx.git (updates daily. not affiliated with lyx.org.)
Stars: ✭ 34 (+126.67%)
Mutual labels:  mirror
pkg ping
Prints or writes the fastest OpenBSD mirror(s); or easily replace the mirror in /etc/installurl which went down.
Stars: ✭ 18 (+20%)
Mutual labels:  mirror
libfixmath
Cross Platform Fixed Point Maths Library - mirror of https://code.google.com/p/libfixmath/
Stars: ✭ 16 (+6.67%)
Mutual labels:  mirror
mirrors.shuosc.org
SHU Open Source Mirror,有镜像需求请在Issues中提交
Stars: ✭ 50 (+233.33%)
Mutual labels:  mirror
doppelganger
A tool to mirror GitHub repositories.
Stars: ✭ 14 (-6.67%)
Mutual labels:  mirror
zfs-auto-mirror
Automatic ZFS dataset mirroring
Stars: ✭ 15 (+0%)
Mutual labels:  mirror
booto
😍A light framework for React Application. Easy for life!
Stars: ✭ 18 (+20%)
Mutual labels:  mirror
2049bbs.github.io
2049BBS 镜像站,每20分钟更新 https://2049bbs.github.io ,免翻墙 CDN https://cdn.staticaly.com/gh/2049bbs/2049bbs.github.io/gh-pages/index.html?env=dev ,Atom (类RSS) Feed 订阅地址 https://2049bbs.github.io/feed.xml ,节点订阅 https://2049bbs.github.io/feed/节点id.xml ,打包下载离线浏览 https://github.com/2049bbs/2049bbs.github.io/archive/gh-pages.zip
Stars: ✭ 39 (+160%)
Mutual labels:  mirror
Stringfication
🔨 Make all objects to String!
Stars: ✭ 33 (+120%)
Mutual labels:  mirror
Reflector
Example of type safe properties reflection in Swift.
Stars: ✭ 14 (-6.67%)
Mutual labels:  mirror
automake
Mirror of git://git.savannah.gnu.org/automake.git
Stars: ✭ 36 (+140%)
Mutual labels:  mirror
Pandownload-Copy
Pandownload作者被捕,此项目仅作软件保存用
Stars: ✭ 95 (+533.33%)
Mutual labels:  mirror
Fog
Pharo Ethereum Driver
Stars: ✭ 19 (+26.67%)
Mutual labels:  mirror
crates-io-cn
Source code of crates-io.cn, also tools sets for sync crates.io
Stars: ✭ 20 (+33.33%)
Mutual labels:  mirror

Västtrafik API (reseplaneraren) 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.

Usage

NodeJS (see ./example.js)

const Api = require('vasttrafik-api');

// Sample credentials. Be sure to get your own before going into production.
(async () => {
    const key = '8aOzt2RmMIG0OXSyIgjM2IkHvAoa';
    const secret = 'OMxjxjaXblXdpn8E1gYFehHyx3Ea';
    await vasttrafik.authorize(key, secret);
    
    const api = new vasttrafik.LocationApi();
    const res = await api.getLocationByName({input: 'Lindholmen'});
    console.log(res.text);
})();

Browsers (see ./example.html)

<script src="./dist/vasttrafik.js"></script>
<script>
    (function() {
        // Sample token. Generate access token on server (see example.js)
        var token = 'b94ad16c-715c-3820-a321-503b0267346e';
        vasttrafik.setAccessToken(token);

        var api = new vasttrafik.LocationApi();
        api.getLocationByName({input: 'Lindholmen'}, function (error, data, res) {
            console.log(res.text);
        });
    })();
</script>

Docs

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.

Authentication

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.

Changes

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 token

Monkey patches:

  • JSON instead of XML is returned by default (see mirror/src/ApiClient.js#448)
  • Avoids duplicate api calls when using promises (see mirror/src/ApiClient.js#453)

Version

  • npm version patch|minor|major
  • npm run deploy

Questions?

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].