krailis / godatagovgr

A Go client for data provided by the Greek Government via data.gov.gr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CI Go Report Card GoDoc LICENSE

GoDataGovGr

GoDataGovGr is a Go client for the API offered by the Greek Government, served at https://data.gov.gr. It utilizes the resty client library.

API Token

Anyone may get a token for the data.gov.gr API here.

Usage Example

A usage example of the GoDataGovGr client for fetching the COVID-19 vaccination data is presented in the following.

import (
	"log"
	"os"

	"github.com/krailis/godatagovgr"
)

func main() {
	// Retrieve API token from the environment.
	apiToken, ok := os.LookupEnv("DATAGOVGR_API_TOKEN")
	if !ok || len(apiToken) == 0 {
		log.Panic("The API token for data.gov.gr has not been properly set.")
	}

	// Create client.
	client := godatagovgr.NewClient(godatagovgr.NewDefaultConfig(apiToken))

	// Perform request.
	vaccinationData, err := client.GetVaccinations(
		&godatagovgr.VaccinationQueryParams{
			DateFrom: "2021-01-01",
			DateTo:   "2021-11-30",
			Area:     "ΡΕΘΥΜΝΟΥ",
		},
	)
	if err != nil {
		log.Panicf("An error occurred while fetching vaccination data: %s", err)
	}

	// Print vaccination data.
	for _, vaccinationDay := range *vaccinationData {
		log.Printf("On %s, %d vaccinations were conducted in regional unit %q.",
			vaccinationDay.ReferenceDate, vaccinationDay.DayTotal, vaccinationDay.Area)
	}
}

Supported (& Potentially Supported) Data Categories.

The current version of the GoDataGovGr clients supports data set of the data.gov.gr API that fall under the following categories & sub-categories:

About

A Go client for data provided by the Greek Government via data.gov.gr

License:MIT License


Languages

Language:Go 100.0%