github.com/theovidal/goweather
Package goweather lets anybody easily fetch weather information using the OpenWeatherMap API Before playing around with the library, get an API key at https://openweathermap.org. Create an API structure : Get the current weather using this API : Get the forecast using this API :
Readme
🌦 Easily fetch weather information using Go and the OpenWeatherMap API.
First of all, make sure you have Go 1.12 installed on your system.
Install the library using go get
...
go get github.com/exybore/goweather
... or use whatever dependency manager you like! Then, you can start writing your code !
Before continuing, head over to openweathermap.org and grab an API key. It's free up to 60 requests per minute, which is pretty comfortable.
After this step, you're ready to initialize the API using the goweather.NewAPI
function :
package main
import "github.com/exybore/goweather"
func main() {
api, err := goweather.NewAPI("ez5e4fz44e84fg89ze8", "en", "metric")
if err != nil {
panic(err)
}
}
This function takes three parameters :
ar
, Bulgarian - bg
, Catalan - ca
, Czech - cz
, German - de
, Greek - el
, English - en
, Persian (Farsi) - fa
, Finnish - fi
, French - fr
, Galician - gl
, Croatian - hr
, Hungarian - hu
, Italian - it
, Japanese - ja
, Korean - kr
, Latvian - la
, Lithuanian - lt
, Macedonian - mk
, Dutch - nl
, Polish - pl
, Portuguese - pt
, Romanian - ro
, Russian - ru
, Swedish - se
, Slovak - sk
, Slovenian - sl
, Spanish - es
, Turkish - tr
, Ukrainian - ua
, Vietnamese - vi
, Chinese Simplified - zh_cn
, Chinese Traditional - zh_tw
default
(temperatures in Kelvin)metric
(temperatures in Celsius)imperial
(temperatures in Fahrenheit)To get the current weather, use the Current
method of the API :
weather, err := api.Current("Lyon,FR")
if err != nil {
panic(err)
}
You can use any existing location in the parameter, but it's recommended to use the City,Country code
format so the result is 100% accurate.
The method returns a types.Current
structure that you can explore on GoDoc
To get the forecast, use the Forecast
method of the API :
weather, err := api.Forecast("Lyon,FR")
if err != nil {
panic(err)
}
You can use any existing location in the parameter, but it's recommended to use the City,Country code
format so the result is 100% accurate.
The method returns a types.Forecast
structure that you can explore on GoDoc
MIT License
Copyright (c) 2019 Exybore
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Package goweather lets anybody easily fetch weather information using the OpenWeatherMap API Before playing around with the library, get an API key at https://openweathermap.org. Create an API structure : Get the current weather using this API : Get the forecast using this API :
We found that github.com/theovidal/goweather demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.