1
0
Fork 0
This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
helium-blockchain-exporter/heliumapi/oracleprices.go

27 lines
580 B
Go

package heliumapi
import (
"encoding/json"
"fmt"
)
// query https://docs.helium.com/api/blockchain/oracle-prices#current-oracle-price
func GetCurrentOraclePrice() (*CurrentOraclePrice, error) {
path := "/v1/oracle/prices/current"
// query the api
respBody, err := getHeliumApi(path, nil)
if err != nil {
return nil, err
}
// unmarshal the response
respobject := CurrentOraclePriceResp{}
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
}