package heliumapi import ( "encoding/json" "fmt" "time" ) // query https://docs.helium.com/api/blockchain/hotspots#hotspots-activity-counts func GetHotspotActivityCounts(hotspot string) (*ActivityCounts, error) { path := "/v1/hotspots/" + hotspot + "/activity/count" // query the api respBody, err := getHeliumApi(path, nil) if err != nil { return nil, err } // unmarshal the response respobject := ActivityCountsResp{} err = json.Unmarshal(respBody, &respobject) if err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } return &respobject.Data, nil } // query https://docs.helium.com/api/blockchain/hotspots#reward-total-for-a-hotspot func GetRewardsTotalForHotspot(hotspot string, minTime *time.Time, maxTime *time.Time) (*RewardTotal, error) { path := "/v1/hotspots/" + hotspot + "/rewards/sum" params := map[string]string{} if minTime != nil { params["min_time"] = minTime.UTC().Format("2006-01-02T15:04:05Z") } if maxTime != nil { params["max_time"] = maxTime.UTC().Format("2006-01-02T15:04:05Z") } // query the api respBody, err := getHeliumApi(path, ¶ms) if err != nil { return nil, err } // unmarshal the response respobject := RewardTotalResp{} err = json.Unmarshal(respBody, &respobject) if err != nil { return nil, fmt.Errorf("failed to unmarshal response from %v: %v", path, err) } return &respobject.Data, nil }