@happycoderse/js-sl-api
Version:
Javscript client for SL API
64 lines (41 loc) • 1.43 kB
Markdown
# js-sl-api
The `@happycoderse/js-sl-api` library provides a client for communication with some of the SL API published by [TrafikLab.se][]
## Installation
This module is distributed via [npm][npm] which is bundled with [node][node] and
should be installed as one of your project's `dependencies`:
```
npm install @happycoderse/js-sl-api
```
or
for installation with [yarn](https://yarnpkg.com/) package manager.
```
yarn add @happycoderse/js-sl-api
```
## Usage
Import `@happycoderse/js-sl-api` and you're good to go:
```javascript
import SlApiClient from "@happycoderse/js-sl-api";
```
Instantiate the client and supply API keys obtained from [TrafikLab.se][].
### Example
```javascript
const client = new SlApiClient({apiKey_realtimeInfo: <key>, apiKey_nearMe: <key>, apiKey_location: <key>});
```
### `UpdateStopInfo`
```typescript
UpdateStopInfo({latitude: string, longitude: string)
```
This fetches nearby stops. Max 900 metres from given lat/long.
### `LookupPlaces`
```typescript
LookupPlaces(address: string)
```
This fetches address and place information by giving part of address name.
### `GetNextDeparture`
```typescript
GetNextDeparture(SiteId: string)
```
This fetches departures for the next 60 minuts for the given siteId.
[trafiklab.se]: https://www.trafiklab.se/api
[npm]: https://www.npmjs.com/
[node]: https://nodejs.org