Skip to content

waqi-dev-community/go-waqi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go WAQI Client

Go client library for the World Air Quality Index (WAQI) APIs. See documentation here. API modules supported - City feed.

Installation

You can include this package in your Go project using npm or yarn:

go get github.com/waqi-dev-community/go-waqi

Get API key

Sign up for an API key here

Making Requests

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)

Releases

No releases published

Packages

No packages published