Skip to content

awiede/wmata-go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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()

About

Go client for Washington DC Metro (WMATA) API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages