godatagovgr

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2021 License: MIT Imports: 6 Imported by: 0

README

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:

Documentation

Index

Constants

View Source
const (
	// Business.
	// See more: https://www.data.gov.gr/search/?topic=business
	URL_ACCOUNTANTS       = "oee_accountants"
	URL_AUDITORS          = "elte_auditors"
	URL_CASINO_TICKETS    = "eeep_casino_tickets"
	URL_ENERGY_INSPECTORS = "minenv_inspectors"
	URL_REALTORS          = "mindev_realtors"
	URL_TOURIST_AGENCIES  = "mintour_agencies"

	// Crime.
	// See more: https://www.data.gov.gr/search/?topic=crime
	URL_TRAFFIC_ACCIDENTS  = "mcp_traffic_accidents"
	URL_TRAFFIC_VIOLATIONS = "mcp_traffic_violations"
	URL_HCG_INCIDENTS      = "hcg_incidents"
	URL_CRIMES             = "mcp_crime"
	URL_FINANCIAL_CRIMES   = "mcp_financial_crimes"
	URL_LAW_FIRMS          = "minjust_law_firms"
	URL_LAWYERS            = "minjust_lawyers"

	// Education.
	// See more: https://www.data.gov.gr/search/?topic=education
	URL_ACADEMIC_PROFESSORS  = "minedu_dep"
	URL_STUDENT_SCHOOLS      = "minedu_students_school"
	URL_INTERNSHIPS          = "grnet_atlas"
	URL_EUDOXUS_APPLICATIONS = "grnet_eudoxus"

	// Environment.
	// See more: https://data.gov.gr/search/?topic=environment
	URL_HORIZONTAL_PLOTS_PER_MUNICIPALITY      = "ktm_hplots"
	URL_CONFISCATION_PER_MUNICIPALITY          = "ktm_confs"
	URL_HORIZONTAL_AREA_PER_MUNICIPALITY       = "ktm_harea"
	URL_MORTGAGES_PER_MUNICIPALITY             = "ktm_liens"
	URL_TRANSACTIONS_PER_MUNICIPALITY          = "ktm_transactions"
	URL_OWNERS_PER_MUNICIPALITY                = "ktm_owners"
	URL_CADASTRE_STATUS_PER_MUNICIPALITY       = "ktm_status"
	URL_CADASTRE_NATURA_PLOTS_PER_MUNICIPALITY = "cadastre_natura_plot"
	URL_CADASTRE_PLOTS_PER_MUNICIPALITY        = "cadastre_plot"
	URL_PLOTS_PER_MUNICIPALITY                 = "ktm_plots"
	URL_RES_POWER_PRODUCTION                   = "admie_realtimescadares"
	URL_POWER_SYSTEM_LOAD                      = "admie_realtimescadasystemload"
	URL_ENERGY_BALANCE                         = "admie_dailyenergybalanceanalysis"
	URL_ELECTRICITY_CONSUMPTION                = "electricity_consumption"
	URL_CIVIL_PROTECTION_URBAN_INCIDENTS       = "mcp_urban_incidents"
	URL_CIVIL_PROTECTION_FOREST_FIRES          = "mcp_forest_fires"

	// Health.
	// See more: https://data.gov.gr/search/?topic=health
	URL_COVID_VACCINATION = "mdg_emvolio"
	URL_EFET_INSPECTIONS  = "efet_inspections"
	URL_PHARMACISTS       = "minhealth_pharmacists"
	URL_PHARMACIES        = "minhealth_pharmacies"
	URL_DENDISTS          = "minhealth_dentists"
	URL_DOCTORS           = "minhealth_doctors"

	// Society.
	// See more: https://data.gov.gr/search/?topic=society
	URL_UNEMPLOYMENT    = "oaed_unemployment"
	URL_VOTERS_PER_AGE  = "minint_election_age"
	URL_VOTERS_PER_AREA = "minint_election_distribution"

	// Technology.
	// See more: https://data.gov.gr/search/?topic=technology
	URL_INTERNET_TRAFFIC = "internet_traffic"

	// Telecommunications.
	// See more: https://data.gov.gr/search/?topic=telecom
	URL_TELECOM_INDICATORS = "eett_telecom_indicators"

	// Transport.
	// See more: https://data.gov.gr/search/?topic=transport
	URL_OASA_RIDERSHIP  = "oasa_ridership"
	URL_ROAD_TRAFFIC    = "road_traffic_attica"
	URL_SAILING_TRAFFIC = "sailing_traffic"
)

Variables

This section is empty.

Functions

func FormatQueryParams added in v0.2.0

func FormatQueryParams(queryParams interface{}) (map[string]string, error)

FormatQuery params formats incoming query parameters according to the given type and returns a map of query parameters to use with the request.

Types

type AcademicProfessorData

type AcademicProfessorData struct {
	Year                int    `json:"year,omitempty"`
	Institution         string `json:"institution,omitempty"`
	FullProfessors      int    `json:"full_professors,omitempty"`
	AssociateProfessors int    `json:"associate_professors,omitempty"`
	AssistantProfessors int    `json:"assistant_professors,omitempty"`
	Lecturers           int    `json:"lecturers,omitempty"`
	PracticeProfessors  int    `json:"practice_professors,omitempty"`
	PracticeLecturers   int    `json:"practice_lecturers,omitempty"`
}

Academic Professor (DEP) data. See more: https://www.data.gov.gr/datasets/minedu_dep/

func (*AcademicProfessorData) String added in v0.2.0

func (i *AcademicProfessorData) String() string

type AuditorData

type AuditorData struct {
	NumberData
	Firms int `json:"firms,omitempty"`
}

Auditors. See more: https://www.data.gov.gr/datasets/elte_auditors/

func (*AuditorData) String added in v0.2.0

func (i *AuditorData) String() string

type CasinoTicketData

type CasinoTicketData struct {
	Year    int `json:"year,omitempty"`
	Tickets int `json:"tickets,omitempty"`
}

Casino Tickets. See more: https://www.data.gov.gr/datasets/eeep_casino_tickets/

func (*CasinoTicketData) String added in v0.2.0

func (i *CasinoTicketData) String() string

type CrimeStatData

type CrimeStatData struct {
	Year              int    `json:"year,omitempty"`
	Crime             string `json:"crime,omitempty"`
	Committed         int    `json:"committed,omitempty"`
	Attempted         int    `json:"attempted,omitempty"`
	Solved            int    `json:"solved,omitempty"`
	DomesticCriminals int    `json:"domestic_criminals,omitempty"`
	ForeignCriminals  int    `json:"foreign_criminals,omitempty"`
}

Crime Statistics. See more: https://data.gov.gr/datasets/mcp_crime

func (*CrimeStatData) String added in v0.2.0

func (i *CrimeStatData) String() string

type DataGovGrClient

type DataGovGrClient struct {
	// contains filtered or unexported fields
}

DataGovGr Client struct definition.

func NewClient

func NewClient(config *DataGovGrConfig) *DataGovGrClient

NewClient creates and returns an new DataGovGr client.

func (*DataGovGrClient) GetAcademicProfessors added in v0.2.0

func (d *DataGovGrClient) GetAcademicProfessors() (*[]AcademicProfessorData, error)

GetAcademicProfessors retrieves the Academic Professor data from data.gov.gr.

func (*DataGovGrClient) GetAccountants added in v0.2.0

func (d *DataGovGrClient) GetAccountants() (*[]NumberData, error)

GetAccountants retrieves the accountant numbers from data.gov.gr.

func (*DataGovGrClient) GetAuditors added in v0.2.0

func (d *DataGovGrClient) GetAuditors() (*[]AuditorData, error)

GetAuditors retrieves the Auditor data from data.gov.gr.

func (*DataGovGrClient) GetCasinoTickets added in v0.2.0

func (d *DataGovGrClient) GetCasinoTickets() (*[]CasinoTicketData, error)

GetCasinoTickets retrieves the Casino Ticket data from data.gov.gr.

func (*DataGovGrClient) GetCrimes added in v0.2.0

func (d *DataGovGrClient) GetCrimes() (*[]CrimeStatData, error)

GetCrimes retrieves the Crime Statistic data from data.gov.gr.

func (*DataGovGrClient) GetData added in v0.2.0

func (d *DataGovGrClient) GetData(queryParams, data interface{}, url string) error

GetData retrieves the data for most of the available datasets. It accepts the query parameters (if any), a pointer to an array of appropriate structs (according to the requested dataset) and the URL. It returns an error.

func (*DataGovGrClient) GetDendists added in v0.2.0

func (d *DataGovGrClient) GetDendists() (*[]NumberData, error)

GetDendists retrieves the dendist numbers from data.gov.gr.

func (*DataGovGrClient) GetDoctors added in v0.2.0

func (d *DataGovGrClient) GetDoctors() (*[]NumberData, error)

GetDoctors retrieves the doctor numbers from data.gov.gr.

func (*DataGovGrClient) GetEnergyInspectors added in v0.2.0

func (d *DataGovGrClient) GetEnergyInspectors() (*[]NumberData, error)

GetEnergyInspectors retrieves the energy inspector numbers from data.gov.gr.

func (*DataGovGrClient) GetEudoxusApplications added in v0.2.0

func (d *DataGovGrClient) GetEudoxusApplications() (*[]EudoxusApplicationData, error)

GetEudoxusApplications retrieves the Eudoxus Application data from data.gov.gr.

func (*DataGovGrClient) GetFinancialCrimes added in v0.2.0

func (d *DataGovGrClient) GetFinancialCrimes() (*[]FinancialCrimeData, error)

GetFinancialCrimes retrieves the Financial Crime Statistics from data.gov.gr.

func (*DataGovGrClient) GetHCGIncidents added in v0.2.0

func (d *DataGovGrClient) GetHCGIncidents() (*[]HellenicCoastGuardIncidentData, error)

GetHCGIncidents retrieves the Hellenic Coast Guard Incident data from data.gov.gr.

func (*DataGovGrClient) GetInternetTraffic

func (d *DataGovGrClient) GetInternetTraffic(
	queryParams *InternetTrafficQueryParams) (*[]InternetTrafficData, error)

GetInternetTraffic retrieves the Internet Traffic data from data.gov.gr. The supported query parameters include the start and end dates. The query parameters must be given in an InternetTrafficQueryParams struct, as defined in the client's models.

func (*DataGovGrClient) GetInternships added in v0.2.0

func (d *DataGovGrClient) GetInternships() (*[]InternshipData, error)

GetInternships retrieves the Internship data from data.gov.gr.

func (*DataGovGrClient) GetLawFirms added in v0.2.0

func (d *DataGovGrClient) GetLawFirms() (*[]NumberData, error)

GetLawFirms retrieves the law firm numbers from data.gov.gr.

func (*DataGovGrClient) GetLawyers added in v0.2.0

func (d *DataGovGrClient) GetLawyers() (*[]NumberData, error)

GetLawyers retrieves the lawyer numbers from data.gov.gr.

func (*DataGovGrClient) GetNumbers

func (d *DataGovGrClient) GetNumbers(url string) (*[]NumberData, error)

GetNumbers performs a request to one of the endpoints that retrieve concern data in the form of numbers (entrants, exits etc.) per year.

func (*DataGovGrClient) GetPharmacies added in v0.2.0

func (d *DataGovGrClient) GetPharmacies() (*[]NumberData, error)

GetPharmacies retrieves the pharmacy numbers from data.gov.gr.

func (*DataGovGrClient) GetPharmacists added in v0.2.0

func (d *DataGovGrClient) GetPharmacists() (*[]NumberData, error)

GetPharmacists retrieves the pharmacist numbers from data.gov.gr.

func (*DataGovGrClient) GetRealtors added in v0.2.0

func (d *DataGovGrClient) GetRealtors() (*[]NumberData, error)

GetRealtors retrieves the realtor numbers from data.gov.gr.

func (*DataGovGrClient) GetStudentSchools added in v0.2.0

func (d *DataGovGrClient) GetStudentSchools() (*[]StudentSchoolData, error)

GetStudentSchools retrieves the Student School data from data.gov.gr.

func (*DataGovGrClient) GetTouristAgencies added in v0.2.0

func (d *DataGovGrClient) GetTouristAgencies() (*[]NumberData, error)

GetTouristAgencies retrieves the tourist agency numbers from data.gov.gr.

func (*DataGovGrClient) GetTrafficAccidents added in v0.2.0

func (d *DataGovGrClient) GetTrafficAccidents() (*[]TrafficAccidentData, error)

GetTrafficAccidents retrieves the Traffic Accident data from data.gov.gr.

func (*DataGovGrClient) GetTrafficViolations added in v0.2.0

func (d *DataGovGrClient) GetTrafficViolations() (*[]TrafficViolationData, error)

GetTrafficViolations retrieves the Traffic Violation data from data.gov.gr.

func (*DataGovGrClient) GetVaccinations added in v0.2.0

func (d *DataGovGrClient) GetVaccinations(
	queryParams *VaccinationQueryParams) (*[]VaccinationData, error)

GetVaccinations retrieves the Vaccination data from data.gov.gr. The supported query parameters include the start and end dates, as well as the area. Shall query parameters be set, the must be given in an VaccinationQueryParams struct, as defined in the models.

type DataGovGrConfig

type DataGovGrConfig struct {
	// contains filtered or unexported fields
}

DataGovGr Config struct definition.

func NewDefaultConfig

func NewDefaultConfig(apiToken string) *DataGovGrConfig

NewDefaultConfig creates and returns a new default DataGovGr config. It accepts the API token and uses predefined values for parameters such as retry count, retry wait and max wait time, and timeout. The default values are a retry count of three (3), a retry wait time and retry max wait time of five (5) secs, and a timeout of ten (10) secs.

type EudoxusApplicationData

type EudoxusApplicationData struct {
	Year                  int    `json:"year,omitempty"`
	Period                string `json:"period,omitempty"`
	Institution           string `json:"institution,omitempty"`
	Department            string `json:"department,omitempty"`
	StudentWithStatements int    `json:"studentwithstatements,omitempty"`
	StudentWithDeliveries int    `json:"studentwithdeliveries,omitempty"`
}

Eudoxus Applications & Deliveries. See more: https://www.data.gov.gr/datasets/grnet_eudoxus/

func (*EudoxusApplicationData) String added in v0.2.0

func (i *EudoxusApplicationData) String() string

type FinancialCrimeData

type FinancialCrimeData struct {
	Year  int    `json:"year,omitempty"`
	Crime string `json:"crime,omitempty"`
	Count int    `json:"count,omitempty"`
}

Financial Crime Data. See more: https://www.data.gov.gr/datasets/mcp_financial_crimes/

func (*FinancialCrimeData) String added in v0.2.0

func (i *FinancialCrimeData) String() string

type HellenicCoastGuardIncidentData added in v0.2.0

type HellenicCoastGuardIncidentData struct {
	Year          int    `json:"year,omitempty"`
	Incident      string `json:"incident,omitempty"`
	Domestic      int    `json:"domestic,omitempty"`
	International int    `json:"international,omitempty"`
}

Hellenic Coast Guard Incidents. See more: https://www.data.gov.gr/datasets/hcg_incidents/

func (*HellenicCoastGuardIncidentData) String added in v0.2.0

type InternetTrafficData added in v0.2.0

type InternetTrafficData struct {
	Date       string `json:"date,omitempty"`
	AverageIn  int    `json:"avg_in,omitempty"`
	AverageOut int    `json:"avg_out,omitempty"`
	MaxIn      int    `json:"max_in,omitempty"`
	MaxOut     int    `json:"max_out,omitempty"`
}

Internet Traffic. See more: https://data.gov.gr/datasets/internet_traffic/

func (*InternetTrafficData) String added in v0.2.0

func (i *InternetTrafficData) String() string

type InternetTrafficQueryParams

type InternetTrafficQueryParams struct {
	DateFrom string `json:"date_from,omitempty"`
	DateTo   string `json:"date_to,omitempty"`
}

Internet Traffic Query Params.

type InternshipData

type InternshipData struct {
	Year                int    `json:"year,omitempty"`
	Institution         string `json:"institution,omitempty"`
	PrivateSector       int    `json:"private_sector,omitempty"`
	PublicSector        int    `json:"public_sector,omitempty"`
	NonGovOrganizations int    `json:"ngo,omitempty"`
}

Internship Data. See more: https://www.data.gov.gr/datasets/grnet_atlas/

func (*InternshipData) String added in v0.2.0

func (i *InternshipData) String() string

type NumberData

type NumberData struct {
	Year     int    `json:"year,omitempty"`
	Quarter  string `json:"quarter,omitempty"`
	Active   int    `json:"active,omitempty"`
	Entrants int    `json:"entrants,omitempty"`
	Exits    int    `json:"exits,omitempty"`
}

Number Data struct definition. This struct applies to multiple series of data:

- Accountants. See more: https://www.data.gov.gr/datasets/oee_accountants/

- Doctors. See more: https://www.data.gov.gr/datasets/minhealth_doctors/

- Dendists. See more: https://www.data.gov.gr/datasets/minhealth_dentists/

- Energy Inspector numbers. See more: https://www.data.gov.gr/datasets/minenv_inspectors/

- Lawyer numbers. See more: https://www.data.gov.gr/datasets/minjust_lawyers/

- Law firm numbers. See more: https://www.data.gov.gr/datasets/minjust_law_firms/

- Pharmacy numbers. See more: https://data.gov.gr/datasets/minhealth_pharmacies/

- Pharmacist numbers. See more: https://data.gov.gr/datasets/minhealth_pharmacists/

- Realtors. See more: https://www.data.gov.gr/datasets/mindev_realtors/

- Tourist Agencies. See more: https://www.data.gov.gr/datasets/mintour_agencies/

func (*NumberData) String added in v0.2.0

func (i *NumberData) String() string

fmt.GoStringer interface implementations.

type Stringable added in v0.2.0

type Stringable interface {
	String() string
}

Stringable interface definition.

type StudentSchoolData

type StudentSchoolData struct {
	Year                    int    `json:"year,omitempty"`
	Jurisdiction            string `json:"jurisdiction,omitempty"`
	District                string `json:"district,omitempty"`
	SchoolClass             string `json:"school_class,omitempty"`
	SchoolType              string `json:"school_type,omitempty"`
	SchoolName              string `json:"school_name,omitempty"`
	RegisteredStudentsBoys  int    `json:"registered_students_boys,omitempty"`
	RegisteredStudentsGirls int    `json:"registered_students_girls,omitempty"`
}

Student School Data. See more: https://www.data.gov.gr/datasets/minedu_students_school/

func (*StudentSchoolData) String added in v0.2.0

func (i *StudentSchoolData) String() string

type TrafficAccidentData

type TrafficAccidentData struct {
	Year             int    `json:"year,omitempty"`
	Jurisdiction     string `json:"jurisdiction,omitempty"`
	DeadlyAccidents  int    `json:"deadly_accidents,omitempty"`
	SeriousAccidents int    `json:"serious_accidents,omitempty"`
	OtherAccidents   int    `json:"other_accidents,omitempty"`
	Deaths           int    `json:"deaths,omitempty"`
	SeriouslyInjured int    `json:"seriously_injured,omitempty"`
	OtherInjured     int    `json:"other_injured,omitempty"`
}

Traffic Accidents. See more: https://data.gov.gr/datasets/mcp_traffic_accidents

func (*TrafficAccidentData) String added in v0.2.0

func (i *TrafficAccidentData) String() string

type TrafficViolationData

type TrafficViolationData struct {
	Year      int    `json:"year,omitempty"`
	Violation string `json:"violation,omitempty"`
	Count     int    `json:"count,omitempty"`
}

Traffic Violations. See more: https://www.data.gov.gr/datasets/mcp_traffic_violations/

func (*TrafficViolationData) String added in v0.2.0

func (i *TrafficViolationData) String() string

type VaccinationData

type VaccinationData struct {
	Area                 string `json:"area,omitempty"`
	AreaID               int    `json:"areaid,omitempty"`
	DailyDoseFirst       int    `json:"dailydose1,omitempty"`
	DailyDoseSecond      int    `json:"dailydose2,omitempty"`
	DailyDoseThird       int    `json:"dailydose3,omitempty"`
	DayDiff              int    `json:"daydiff,omitempty"`
	DayTotal             int    `json:"daytotal,omitempty"`
	ReferenceDate        string `json:"referencedate,omitempty"`
	TotalDistinctPersons int    `json:"totaldistinctpersons,omitempty"`
	TotalDoseFirst       int    `json:"totaldose1,omitempty"`
	TotalDoseSecond      int    `json:"totaldose2,omitempty"`
	TotalDoseThird       int    `json:"totaldose3,omitempty"`
	TotalVaccinations    int    `json:"totalvaccinations,omitempty"`
}

Vaccinations. See more: https://data.gov.gr/datasets/mdg_emvolio/

func (*VaccinationData) String added in v0.2.0

func (i *VaccinationData) String() string

type VaccinationQueryParams

type VaccinationQueryParams struct {
	DateFrom string `json:"date_from,omitempty"`
	DateTo   string `json:"date_to,omitempty"`
	Area     string `json:"area,omitempty"`
}

Vaccination Query Parameters struct definition.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL