mirror of
https://github.com/kevin-DL/m3o-go.git
synced 2026-01-11 10:34:27 +00:00
1.1 KiB
Executable File
1.1 KiB
Executable File
Weather
An m3o.com API. For example usage see m3o.com/weather/api.
Endpoints:
Now
Get the current weather report for a location by postcode, city, zip code, ip address
https://m3o.com/weather/api#Now
package example
import(
"fmt"
"os"
"go.m3o.com/weather"
)
// Get the current weather report for a location by postcode, city, zip code, ip address
func GetCurrentWeather() {
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
rsp, err := weatherService.Now(&weather.NowRequest{
Location: "london",
})
fmt.Println(rsp, err)
}
Forecast
Get the weather forecast for the next 1-10 days
https://m3o.com/weather/api#Forecast
package example
import(
"fmt"
"os"
"go.m3o.com/weather"
)
// Get the weather forecast for the next 1-10 days
func ForecastWeather() {
weatherService := weather.NewWeatherService(os.Getenv("M3O_API_TOKEN"))
rsp, err := weatherService.Forecast(&weather.ForecastRequest{
Days: 2,
Location: "London",
})
fmt.Println(rsp, err)
}