Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/philippeweidmann/tpgapi

TPG API wrapper written in swift
https://github.com/philippeweidmann/tpgapi

Last synced: about 1 month ago
JSON representation

TPG API wrapper written in swift

Awesome Lists containing this project

README

        

# TPGApi
TPG API wrapper to fetch stops and next departures for Geneva's public transport.

## Installation
### Using Cocoapods

Add this line in your PodFile

```
pod 'TPGApi'
```

## Usage

To use the API you must have a valid API key, you can request one here http://www.tpg.ch/web/open-data/donnees-tpg

You have to provide wherever you want in the code like this:

```
TPGApiKey.key = "your key"
```

### List of all stops in Geneva

Stops have to be loaded at least once, this is done asychronously. Once downloaded the stops are cached on the device.
```
StopManager.instance.loadStops(completion: {(commercialStops, physicalStops) in

}, force: false)
```

### Next departures for a stop

Get next departures for stop code 'Gare Cornavin'
```
DeparturesManager.instance.loadNextDeparturesFor(stopCode: "CVIN", completion: {departures in

})
```

### Steps for a given departure

Get the steps for the line of the departure '43844'
```
DeparturesManager.instance.loadThermometerFor(departureCode: "43844", completion: {steps in

})

```