Giter Site home page Giter Site logo

transdevclient's Introduction

Transdev Client

An API client for the Transdev API, written in Go.

What is this?

Transdev is the organization that owns the following Dutch bus carriers:

  • Connexxion
  • Breng
  • Hermes
  • Bravo

On the websites of these carriers you can look up bus departures. This package implements a client that uses the same API as these websites, and thus allows you to retrieve bus departure information from your Go project.

As far as I can tell, all websites make use of the same underlying API and dataset, e.g. you can look up stops served by Connexxion from the Breng website. This client uses Breng's domain name for the API calls, but any of the others should work as well.

Usage

First, install the package in your project:

go get github.com/jasperbok/transdev-client

Then you can instantiate a new client and call methods on it:

package main

import (
	"fmt"
	"strings"
	transdev "github.com/jasperbok/transdevclient"
)

func main() {
	c := transdev.NewClient()

	// Find information for a stop.
	// At the time of writing 'swartbroek' will yield a single stop.
	results, err := c.Search("swartbroek")
	if err != nil {
		panic(err)
    }

	stopID := results.Stops[0].ID
	// As far as my emperical research can tell, stop and quay IDs can
	// be translated into each other by replacing the letter in their ID.
	quayID := strings.Replace(stopID, ":S:", ":Q:", 1)
	name := results.Stops[0].Name
	town := results.Stops[0].Town

	// With the information retrieved above, we can retrieve upcoming
	// departures for the stop.
	departures, err := c.Departures(quayID, name, town)
	if err != nil {
		panic(err)
    }

	fmt.Printf("%v\n", departures)
}

Known shortcomings

  • The /timetable endpoint is not implemented.
  • The /getavailablecaptions endpoint is not implemented.
  • The Search method only supports looking for stops and routes, but you can do other search queries via the same endpoint. These are not implemented.

transdevclient's People

Contributors

jasperbok avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.