Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/philippeweidmann/tpgapi
- Owner: PhilippeWeidmann
- License: gpl-3.0
- Created: 2018-11-05T10:51:51.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-12T08:33:34.000Z (about 6 years ago)
- Last Synced: 2024-09-22T13:31:31.139Z (3 months ago)
- Language: Swift
- Size: 72.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TPGApi
TPG API wrapper to fetch stops and next departures for Geneva's public transport.## Installation
### Using CocoapodsAdd 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})
```