Skip to content

lsjurczak/go-airly

Repository files navigation

go-airly

Test go.dev reference Go Report Card

go-airly is a Go client library for the Airly API.

Installation

This package can be installed using:

go get github.com/lsjurczak/go-airly

Usage

Import the package using:

import "github.com/lsjurczak/go-airly"

To use this library you have to get key from https://developer.airly.eu/

Construct a new client and pass apiKey:

client, err := airly.NewClient(nil, "apiKey")
if err != nil {
    log.Fatalf("airly.NewClient: %v", err)
}

You can also pass custom HTTP client:

customClient := &http.Client{Timeout: 5 * time.Second}

Then use one of the client's services (Installation, Measurement, or Meta) to access the different Airly API methods.

For example, to get the nearest installation:

opt := airly.NewNearestInstallationOpts(52.2872, 21.1087).MaxResults(1).MaxDistance(10)
installations, err := client.Installation.Nearest(opt)
if err != nil {
    log.Fatal(err)
}

License

This library is distributed under the MIT license found in the LICENSE file.