wmata-go-sdk

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2019 License: GPL-3.0

README

wmata-go-sdk

GoDoc Build Status Coverage Status

Go client for Washington DC Metro (WMATA) API

Install

To install this package run:

go get -u github.com/awiede/wmata-go-sdk

Register

In order to use the WMATA API, you will need to register with WMATA and get and API key. Information on how to get an API key can be found here.

Usage

This project is broken up into separate packages for each grouping of WMATA APIs (Please refer to these docs as the source of truth for all business rules)

The application is split up into the following services:

Creating a wmata.Client

All requests using this SDK are routed through a wmata.Client. To create a client you will need an API key, and can optionally specify an http.Client with all associated configurations.

Example
apiKey := "<your-api-key>"
client := http.Client{
    Timeout: time.Second * 60,
}
wmataClient := wmata.NewWMATAClient(apiKey, client)

// Defaults with a 30 second timeout
defaultClient := wmata.NewWMATADefaultClient(apiKey)

Creating and Using a Service

All services have a <package-name>.NewService function which will build a new service. To create a service a wmata.Client is required, as well as a choice of either communicating to WMATA via their JSON or XML endpoints.

Example
// Create rail info service using WMATA client in previous example
railInfoService := railinfo.NewService(wmataClient, wmata.JSON)

// Invoke the GetLines() method of the rail service to get active line info
activeRailLines, err := railInfoService.GetLines()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL