An open API service indexing awesome lists of open source software.

https://github.com/mdb/seaweed

A thin, Go Magic Seaweed API client for fetching surf forecast data.
https://github.com/mdb/seaweed

go golang magic-seaweed

Last synced: 10 months ago
JSON representation

A thin, Go Magic Seaweed API client for fetching surf forecast data.

Awesome Lists containing this project

README

          

[![CI](https://github.com/mdb/seaweed/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/mdb/seaweed/actions/workflows/ci.yaml) [![PkgGoDev](https://pkg.go.dev/badge/github.com/mdb/seaweed)](https://pkg.go.dev/github.com/mdb/seaweed) [![Go Report Card](https://goreportcard.com/badge/github.com/mdb/seaweed)](https://goreportcard.com/report/github.com/mdb/seaweed)

# seaweed

A thin, Go [Magic Seaweed API](http://magicseaweed.com/developer/forecast-api) client for fetching marine forecast data.

## Usage

Basic usage:

```go
import (
"github.com/mdb/seaweed"
)

func main() {
forecasts, err := seaweed.Get("", "")
resp, err := client.Forecast("")
if err != nil {
panic(err)
}

fmt.Printf("%# v", resp)
}
```

Use a customized client:

```go
client := seaweed.NewClient(
"",
seaweed.WithBaseURL("https://foo.com"),
seaweed.WithHTTPClient(&http.Client{}), // *http.Client
seaweed.WithLogger(logrus.New()), // *logrus.Logger
seaweed.WithClock(seaweed.RealClock{}), // seaweed.Clock
)
```

To adjust the `*seaweed.Client`'s log level:

```go
client.Logger.SetLevel(logrus.DebugLevel)
```

Client methods:

```go
import (
"github.com/mdb/seaweed"
)

client := seaweed.NewClient("")

// Full forecast
resp, err := client.Forecast("")

// Today's forecast
resp, err := client.Today("")

// Tomorrow's forecast
resp, err := client.Tomorrow("")

// This weekend's forecast
resp, err := client.Weekend("")
```