glassnodeapi

package
v1.60.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: AGPL-3.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	Timestamp Timestamp          `json:"t"`
	Value     float64            `json:"v"`
	Options   map[string]float64 `json:"o"`
}

type DataSlice added in v1.36.0

type DataSlice []Data

In Glassnode API, there are two types of response, for example:

/v1/metrics/market/marketcap_usd

[
	{
		"t": 1614556800,
		"v": 927789865185.0476
	},
	...
]

and

/v1/metrics/market/price_usd_ohlc

[
	{
		"t": 1614556800,
		"o": {
			"c": 49768.16035012147,
			"h": 49773.18922304233,
			"l": 45159.50305252744,
			"o": 45159.50305252744
		}
	},
	...
]

both can be stored into the DataSlice structure.

Note: use `HasOptions` to verify the type of response.

func (DataSlice) First added in v1.36.0

func (s DataSlice) First() Data

func (DataSlice) FirstOptions added in v1.36.0

func (s DataSlice) FirstOptions() map[string]float64

func (DataSlice) FirstValue added in v1.36.0

func (s DataSlice) FirstValue() float64

func (DataSlice) HasOptions added in v1.36.0

func (s DataSlice) HasOptions() bool

func (DataSlice) IsEmpty added in v1.36.0

func (s DataSlice) IsEmpty() bool

func (DataSlice) Last added in v1.36.0

func (s DataSlice) Last() Data

func (DataSlice) LastOptions added in v1.36.0

func (s DataSlice) LastOptions() map[string]float64

func (DataSlice) LastValue added in v1.36.0

func (s DataSlice) LastValue() float64

type Format

type Format string
const (
	FormatJSON Format = "JSON"
	FormatCSV  Format = "CSV"
)

type Interval

type Interval string
const (
	Interval1h  Interval = "1h"
	Interval24h Interval = "24h"
	Interval10m Interval = "10m"
	Interval1w  Interval = "1w"
	Interval1m  Interval = "1month"
)

type Request added in v1.36.0

type Request struct {
	Client requestgen.AuthenticatedAPIClient

	Asset           string     `param:"a,required,query"`
	Since           *time.Time `param:"s,query,seconds"`
	Until           *time.Time `param:"u,query,seconds"`
	Interval        *Interval  `param:"i,query"`
	Format          *Format    `param:"f,query" default:"JSON"`
	Currency        *string    `param:"c,query"`
	TimestampFormat *string    `param:"timestamp_format,query"`

	Category string `param:"category,slug"`
	Metric   string `param:"metric,slug"`
}

func (*Request) Do added in v1.36.0

func (r *Request) Do(ctx context.Context) (DataSlice, error)

func (*Request) GetParameters added in v1.36.0

func (r *Request) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*Request) GetParametersJSON added in v1.36.0

func (r *Request) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*Request) GetParametersQuery added in v1.36.0

func (r *Request) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*Request) GetQueryParameters added in v1.36.0

func (r *Request) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*Request) GetSlugParameters added in v1.36.0

func (r *Request) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*Request) GetSlugsMap added in v1.36.0

func (r *Request) GetSlugsMap() (map[string]string, error)

func (*Request) SetAsset added in v1.36.0

func (r *Request) SetAsset(Asset string) *Request

func (*Request) SetCategory added in v1.36.0

func (r *Request) SetCategory(Category string) *Request

func (*Request) SetCurrency added in v1.36.0

func (r *Request) SetCurrency(Currency string) *Request

func (*Request) SetFormat added in v1.36.0

func (r *Request) SetFormat(Format Format) *Request

func (*Request) SetInterval added in v1.36.0

func (r *Request) SetInterval(Interval Interval) *Request

func (*Request) SetMetric added in v1.36.0

func (r *Request) SetMetric(Metric string) *Request

func (*Request) SetSince added in v1.36.0

func (r *Request) SetSince(Since time.Time) *Request

func (*Request) SetTimestampFormat added in v1.36.0

func (r *Request) SetTimestampFormat(TimestampFormat string) *Request

func (*Request) SetUntil added in v1.36.0

func (r *Request) SetUntil(Until time.Time) *Request

type RestClient

type RestClient struct {
	requestgen.BaseAPIClient
	// contains filtered or unexported fields
}

func NewRestClient

func NewRestClient() *RestClient

func (*RestClient) Auth

func (c *RestClient) Auth(apiKey string)

func (*RestClient) NewAuthenticatedRequest

func (c *RestClient) NewAuthenticatedRequest(ctx context.Context, method, refURL string, params url.Values, payload interface{}) (*http.Request, error)

type Timestamp

type Timestamp time.Time

func (Timestamp) String

func (t Timestamp) String() string

func (Timestamp) Unix

func (t Timestamp) Unix() float64

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(o []byte) error

Jump to

Keyboard shortcuts

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