package heliumapi import ( "encoding/json" "fmt" ) type BlockchainStats struct { Data struct { BlockTime struct { LastDay struct { Avg float64 `json:"avg"` Stddev float64 `json:"stddev"` } `json:"last_day"` LastHour struct { Avg float64 `json:"avg"` Stddev float64 `json:"stddev"` } `json:"last_hour"` LastMonth struct { Avg float64 `json:"avg"` Stddev float64 `json:"stddev"` } `json:"last_month"` LastWeek struct { Avg float64 `json:"avg"` Stddev float64 `json:"stddev"` } `json:"last_week"` } `json:"block_times"` ChallengeCount struct { Active int `json:"active"` LastDay int `json:"last_day"` } `json:"challenge_counts"` Counts struct { Validators int `json:"validators"` Ouis int `json:"ouis"` HotspotsDataonly int `json:"hotspots_dataonly"` Blocks int `json:"blocks"` Challenges int `json:"challenges"` Cities int `json:"cities"` ConsensusGroups int `json:"consensus_groups"` Countries int `json:"countries"` Hotspots int `json:"hotspots"` Transactions int `json:"transactions"` } `json:"counts"` ElectionTimes struct { LastDay struct { Avg float64 `json:"avg"` Stddev float64 `json:"stddev"` } `json:"last_day"` LastHour struct { Avg float64 `json:"avg"` Stddev float64 `json:"stddev"` } `json:"last_hour"` LastMonth struct { Avg float64 `json:"avg"` Stddev float64 `json:"stddev"` } `json:"last_month"` LastWeek struct { Avg float64 `json:"avg"` Stddev float64 `json:"stddev"` } `json:"last_week"` } `json:"election_times"` TokenSupply float64 `json:"token_supply"` } `json:"data"` } func GetBlockchainStats() (*BlockchainStats, error) { const path = "/v1/stats" // query the api respBody, err := getHeliumApi(path, nil) if err != nil { return nil, err } // unmarshal the response respobject := BlockchainStats{} err = json.Unmarshal(respBody, &respobject) if err != nil { return nil, fmt.Errorf("failed to unmarshal response from path %v: %v", path, err) } return &respobject, nil }