Go client library for the World Air Quality Index (WAQI) APIs. See documentation here. API modules supported - City feed.
You can include this package in your Go project using npm or yarn:
go get github.com/waqi-dev-community/go-waqi
Sign up for an API key here
Making Requests
import (
waqi "github.com/waqi-dev-community/go-waqi/lib"
)
apiKey := "<REPLACE_WITH_YOUR_API_KEY>"
waqiClient := waqi.NewAPIClient(apiKey, &waqi.Config{})
For City Feed:
city := "shanghai"
cityFeed, err := waqiClient.FeedApi.GetCityFeed(ctx, city)
if err != nil {
log.Fatal("city feed error: ", err.Error())
return
}
fmt.Println(cityFeed)
For Lat/Lng based Geolocalized Feed:
lat := 32.455
lng := 10.322
geoFeed, err := waqiClient.FeedApi.GeoFeed(ctx, lng, lat)
if err != nil {
log.Fatal("geo feed error: ", err.Error())
return
}
fmt.Println(geoFeed)
For IP based Geolocalized Feed:
geoFeed, err := waqiClient.FeedApi.GeoFeed(ctx)
if err != nil {
log.Fatal("ip feed error: ", err.Error())
return
}
fmt.Println(geoFeed)