glassnodeapi

package
v0.0.0-...-c0411a1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

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

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

func (s DataSlice) First() Data

func (DataSlice) FirstOptions

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

func (DataSlice) FirstValue

func (s DataSlice) FirstValue() float64

func (DataSlice) HasOptions

func (s DataSlice) HasOptions() bool

func (DataSlice) IsEmpty

func (s DataSlice) IsEmpty() bool

func (DataSlice) Last

func (s DataSlice) Last() Data

func (DataSlice) LastOptions

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

func (DataSlice) LastValue

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

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

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

func (*Request) GetParameters

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

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

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*Request) GetParametersQuery

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

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

func (*Request) GetQueryParameters

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

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

func (*Request) GetSlugParameters

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

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

func (*Request) SetAsset

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

func (*Request) SetCategory

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

func (*Request) SetCurrency

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

func (*Request) SetFormat

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

func (*Request) SetInterval

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

func (*Request) SetMetric

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

func (*Request) SetSince

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

func (*Request) SetTimestampFormat

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

func (*Request) SetUntil

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