Skip to content

shawntoffel/darksky

Repository files navigation

DarkSky

GoDoc Go Report Card CircleCI

Dark Sky API client in Go https://darksky.net/dev/docs

A note on Apple Weather

DarkSky's technology has been integrated into Apple Weather. I've started a separate project go-weatherkit for Go client development against Apple's new WeatherKit REST API.

Installing

This assumes you already have a working Go environment, if not please see this page first.

go get github.com/shawntoffel/darksky

Usage

Import the package into your project.

import "github.com/shawntoffel/darksky"

Construct a new DarkSky client

client := darksky.New("api key")

Build a request

request := darksky.ForecastRequest{
    Latitude:  40.7128,
    Longitude: -74.0059,
    Options: darksky.ForecastRequestOptions{
        Exclude: "hourly,minutely",
    },
}

Get the forecast

forecast, err := client.Forecast(request)

Configuration

A different API URL may be targeted using the BaseUrl package scoped variable

darksky.BaseUrl = "https://api.darksky.net/forecast"