27 lines
543 B
Go
27 lines
543 B
Go
package heliumapi
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// query https://docs.helium.com/api/blockchain/stats#blockchain-stats
|
|
func GetBlockchainStats() (*BlockchainStats, error) {
|
|
path := "/v1/stats"
|
|
|
|
// query the api
|
|
respBody, err := getHeliumApi(path, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// unmarshal the response
|
|
respobject := BlockchainStatsResp{}
|
|
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
|
|
}
|