Weatherbit.io provides an API that allows access to forecasts, current and historical data for locations across the world.
Weatherbit API documentation can be found here.
The API endpoints currently supported by the Go API wrapper matches the endpoints supported by the Python API wrapper.
The program has two requirements:
- Go 1.10 or later
- a Weatherbit API key
API key | Save in api_key.txt. Requirements section provides more details |
Query | modify wb.Parameters - see ./examples/main.go |
With a Golang installation and an API key saved in the examples folder, open a terminal from the examples directory and run:
go run main.go
The Weatherbit wrapper uses strings.Builder(), provided in Go 1.10 onwards.
In accordance with Mat Ryer - Writing Beautiful Packages in Go, the weatherbit-go package is not asynchronous but can be used asynchronously should the user wish to do so using Golang primitives. A slice of type Parameter is recommended over a map, unless you really know what you're doing.
Available at GoDoc
go get -u -v github.com/alljames/weatherbit-go/
To uninstall, delete the directory in your $GOPATH/src.
Weatherbit API key - free tier option available.
Place your API Key into a file named api_key.txt (inside the same directory as the .go file where the weatherbit package is invoked). Don't forget to add api_key.txt to your .gitignore file if using a public repository. An example .gitignore file is provided in this repository.
Get involved! This package has a lot of room for improvement. Below are a list of Go features which could be used in this package to good effect.
- Tests! Testing has significant room for improvement.
Read the docs, write and try out some improvements and then make a pull request 😄 !
Coming soon.