wsdot

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2025 License: MIT Imports: 2 Imported by: 0

README

WSDOT Go Client

A Go client library for accessing Washington State Department of Transportation (WSDOT) APIs. This library provides convenient access to traffic, vessel, and camera data from WSDOT's public APIs.

Installation

go get alpineworks.io/wsdot

Quick Start

package main

import (
    "fmt"
    "os"

    "alpineworks.io/wsdot"
    "alpineworks.io/wsdot/vessels"
    "alpineworks.io/wsdot/traffic"
)

func main() {
    // Create client with API key
    client, err := wsdot.NewWSDOTClient(
        wsdot.WithAPIKey(os.Getenv("WSDOT_API_KEY")),
    )
    if err != nil {
        panic(err)
    }

    // Use vessels API
    vesselsClient, _ := vessels.NewVesselsClient(client)
    stats, err := vesselsClient.GetVesselStats()
    if err != nil {
        panic(err)
    }
    fmt.Printf("Found %d vessels\n", len(stats))

    // Use traffic API
    trafficClient, _ := traffic.NewTrafficClient(client)
    alerts, err := trafficClient.GetHighwayAlerts()
    if err != nil {
        panic(err)
    }
    fmt.Printf("Found %d highway alerts\n", len(alerts))
}

API Modules

Vessels

Ferry system data including schedules, vessel information, and real-time locations:

  • Vessel statistics and accommodations
  • Terminal locations and information
  • Route schedules and sailing times
  • Historical vessel positions
  • Wait times and fares
Traffic

Road and highway information:

  • Highway alerts and incidents
  • Travel times between points
  • Traffic Cameras
  • Traffic flow data
  • Weather stations and conditions
  • Mountain pass conditions
  • Bridge clearances
  • Border crossing wait times
  • Commercial vehicle restrictions
  • Toll rates

Configuration

The client requires a WSDOT API key, which can be obtained from the WSDOT website.

client, err := wsdot.NewWSDOTClient(
    wsdot.WithAPIKey("your-api-key"),
    wsdot.WithHTTPClient(customHTTPClient), // optional
)

Examples

See the example/ directory for complete working examples:

  • example/vessels/ - Ferry and vessel data examples
  • example/traffic/ - Traffic and road condition examples
  • example/fares/ - Ferry fare information examples

Run examples with:

export WSDOT_API_KEY="your-api-key"
go run example/vessels/main.go
go run example/traffic/main.go -verbose

Requirements

  • Go 1.22 or higher
  • Valid WSDOT API key

Documentation

Index

Constants

View Source
const (
	ParamCamerasAccessCodeKey = "AccessCode"
	ParamFerriesAccessCodeKey = "apiaccesscode"
	ParamTrafficAccessCodeKey = "AccessCode"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type WSDOTClient

type WSDOTClient struct {
	Client *http.Client
	ApiKey string
}

func NewWSDOTClient

func NewWSDOTClient(options ...WSDOTClientOption) (*WSDOTClient, error)

type WSDOTClientError

type WSDOTClientError error
var (
	ErrInvalidAPIKey WSDOTClientError = errors.New("invalid api key")
	ErrNoClient      WSDOTClientError = errors.New("no client")
)

type WSDOTClientOption

type WSDOTClientOption func(*WSDOTClient)

func WithAPIKey

func WithAPIKey(apiKey string) WSDOTClientOption

func WithHTTPClient

func WithHTTPClient(client *http.Client) WSDOTClientOption

Directories

Path Synopsis
example
cameras command
fares command
traffic command
vessels command

Jump to

Keyboard shortcuts

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