Documentation
¶
Overview ¶
Package defillama provides an idiomatic Go client for the DefiLlama Free and Pro APIs (https://api-docs.defillama.com/).
All 132 GET operations of the pinned OpenAPI spec (spec/defillama-api.json) are exposed through 21 services on the Client. Free endpoints use the per-operation origin declared by the spec (api.llama.fi, coins.llama.fi, stablecoins.llama.fi, yields.llama.fi). Pro endpoints embed the API key as a single URL path segment: https://pro-api.llama.fi/{API_KEY}/<path>.
The client is safe for concurrent use and holds no request-level state.
Index ¶
- Constants
- Variables
- func Ptr[T any](v T) *T
- type APIError
- type APIUsage
- type AccountService
- type Block
- type BridgeTransactionsOptions
- type BridgeVolumeOptions
- type BridgesOptions
- type BridgesService
- func (s *BridgesService) GetBridge(ctx context.Context, id int64) (map[string]any, error)
- func (s *BridgesService) GetBridgeDayStats(ctx context.Context, timestamp int64, chain string, opts *BridgeVolumeOptions) (map[string]any, error)
- func (s *BridgesService) GetBridgeTransactions(ctx context.Context, id int64, opts *BridgeTransactionsOptions) (map[string]any, error)
- func (s *BridgesService) GetBridgeVolume(ctx context.Context, chain string, opts *BridgeVolumeOptions) ([]any, error)
- func (s *BridgesService) GetBridges(ctx context.Context, opts *BridgesOptions) (map[string]any, error)
- type Chain
- type ChartOptions
- type Client
- func (c *Client) Account() *AccountService
- func (c *Client) Bridges() *BridgesService
- func (c *Client) DAT() *DATService
- func (c *Client) Dimensions() *DimensionsService
- func (c *Client) ETFs() *ETFsService
- func (c *Client) Ecosystem() *EcosystemService
- func (c *Client) Emissions() *EmissionsService
- func (c *Client) Equities() *EquitiesService
- func (c *Client) Fees() *FeesService
- func (c *Client) FinancialStatements() *FinancialStatementsService
- func (c *Client) Forks() *ForksService
- func (c *Client) IsPro() bool
- func (c *Client) Narratives() *NarrativesService
- func (c *Client) Oracles() *OraclesService
- func (c *Client) PreIPO() *PreIPOService
- func (c *Client) Prices() *PricesService
- func (c *Client) RWA() *RWAService
- func (c *Client) Stablecoins() *StablecoinsService
- func (c *Client) TVL() *TVLService
- func (c *Client) Treasury() *TreasuryService
- func (c *Client) Volumes() *VolumesService
- func (c *Client) Yields() *YieldsService
- type CoinPrice
- type ConfigError
- type DATService
- type DecodeError
- type DimensionOptions
- type DimensionsService
- func (s *DimensionsService) GetCategoryChainChart(ctx context.Context, metric string, category string, chain string, ...) ([]any, error)
- func (s *DimensionsService) GetCategoryChainChartProtocolBreakdown(ctx context.Context, metric string, category string, chain string, ...) ([]any, error)
- func (s *DimensionsService) GetCategoryChainMetrics(ctx context.Context, metric string, category string, chain string, ...) (map[string]any, error)
- func (s *DimensionsService) GetCategoryChart(ctx context.Context, metric string, category string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetCategoryChartChainBreakdown(ctx context.Context, metric string, category string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetCategoryChartProtocolBreakdown(ctx context.Context, metric string, category string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetCategoryMetrics(ctx context.Context, metric string, category string, opts *DimensionOptions) (map[string]any, error)
- func (s *DimensionsService) GetChainChart(ctx context.Context, metric string, chain string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetChainChartProtocolBreakdown(ctx context.Context, metric string, chain string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetChainMetrics(ctx context.Context, metric string, chain string, opts *DimensionOptions) (map[string]any, error)
- func (s *DimensionsService) GetChart(ctx context.Context, metric string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetChartChainBreakdown(ctx context.Context, metric string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetChartProtocolBreakdown(ctx context.Context, metric string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetMetrics(ctx context.Context, metric string, opts *DimensionOptions) (map[string]any, error)
- func (s *DimensionsService) GetProtocolChart(ctx context.Context, metric string, protocol string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetProtocolChartChainBreakdown(ctx context.Context, metric string, protocol string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetProtocolChartLabelBreakdown(ctx context.Context, metric string, protocol string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetProtocolChartVersionBreakdown(ctx context.Context, metric string, protocol string, opts *DimensionOptions) ([]any, error)
- func (s *DimensionsService) GetProtocolMetrics(ctx context.Context, metric string, protocol string, opts *DimensionOptions) (map[string]any, error)
- type ETFsService
- type EarnPoolsQuery
- type EcosystemService
- func (s *EcosystemService) GetCategories(ctx context.Context) (map[string]any, error)
- func (s *EcosystemService) GetEntities(ctx context.Context) ([]any, error)
- func (s *EcosystemService) GetForks(ctx context.Context) (map[string]any, error)
- func (s *EcosystemService) GetHacks(ctx context.Context) ([]any, error)
- func (s *EcosystemService) GetOracles(ctx context.Context) (map[string]any, error)
- func (s *EcosystemService) GetRaises(ctx context.Context) (map[string]any, error)
- func (s *EcosystemService) GetTreasuries(ctx context.Context) ([]any, error)
- type EmissionsService
- type EquitiesQuery
- type EquitiesService
- func (s *EquitiesService) GetCompaniesList(ctx context.Context) ([]EquityCompany, error)
- func (s *EquitiesService) GetDimensions(ctx context.Context, opts EquitiesQuery) (map[string]any, error)
- func (s *EquitiesService) GetFilings(ctx context.Context, opts EquitiesQuery) ([]any, error)
- func (s *EquitiesService) GetOHLCV(ctx context.Context, opts EquitiesQuery) ([]any, error)
- func (s *EquitiesService) GetOnchainMarkets(ctx context.Context, opts EquitiesQuery) (map[string]any, error)
- func (s *EquitiesService) GetPriceHistory(ctx context.Context, opts EquitiesQuery) ([]any, error)
- func (s *EquitiesService) GetStatements(ctx context.Context, opts EquitiesQuery) (map[string]any, error)
- func (s *EquitiesService) GetSummary(ctx context.Context, opts EquitiesQuery) (map[string]any, error)
- type EquityCompany
- type FeesService
- func (s *FeesService) GetOverview(ctx context.Context, opts OverviewOptions) (map[string]any, error)
- func (s *FeesService) GetOverviewByChain(ctx context.Context, chain string, opts OverviewOptions) (map[string]any, error)
- func (s *FeesService) GetSummary(ctx context.Context, protocol string, opts *DimensionOptions) (map[string]any, error)
- type FinancialStatementsService
- type ForksService
- type HistoryRangeOptions
- type LosslessObject
- type LosslessProtocol
- type LosslessProtocolDetails
- func (d LosslessProtocolDetails) ChainTVLs() (LosslessObject, bool, error)
- func (d LosslessProtocolDetails) Fields() LosslessObject
- func (d LosslessProtocolDetails) ID() (string, bool, error)
- func (d LosslessProtocolDetails) Name() (string, bool, error)
- func (d LosslessProtocolDetails) TVLHistory() ([]LosslessObject, bool, error)
- func (d *LosslessProtocolDetails) UnmarshalJSON(data []byte) error
- type LosslessProtocols
- type LosslessValue
- type LosslessYieldChart
- type LosslessYieldChartPoint
- func (p LosslessYieldChartPoint) APY() (json.Number, bool, error)
- func (p LosslessYieldChartPoint) APYBase() (json.Number, bool, error)
- func (p LosslessYieldChartPoint) APYReward() (LosslessValue, bool)
- func (p LosslessYieldChartPoint) Fields() LosslessObject
- func (p LosslessYieldChartPoint) TVLUSD() (json.Number, bool, error)
- func (p LosslessYieldChartPoint) Timestamp() (string, bool, error)
- type LosslessYieldPool
- func (p LosslessYieldPool) APY() (json.Number, bool, error)
- func (p LosslessYieldPool) APYBase() (json.Number, bool, error)
- func (p LosslessYieldPool) APYReward() (LosslessValue, bool)
- func (p LosslessYieldPool) Fields() LosslessObject
- func (p LosslessYieldPool) PoolID() (string, bool, error)
- func (p LosslessYieldPool) RewardTokens() (LosslessValue, bool)
- type LosslessYieldPools
- type NarrativesService
- type NotFoundError
- type Option
- func WithAPIKey(key string) Option
- func WithBaseURLsForTesting(m map[string]string) Option
- func WithHTTPClient(hc *http.Client) Option
- func WithMaxResponseBodyBytes(limit int64) Option
- func WithPreferProForFree(v bool) Option
- func WithReceiptObserver(observer ReceiptObserver) Option
- func WithRetryPolicy(p RetryPolicy) Option
- func WithTimeout(d time.Duration) Option
- func WithUserAgent(ua string) Option
- type OraclesService
- func (s *OraclesService) GetOracleChainChart(ctx context.Context, chain string) ([]any, error)
- func (s *OraclesService) GetOracleChainChartProtocolBreakdown(ctx context.Context, chain string) ([]any, error)
- func (s *OraclesService) GetOracleChart(ctx context.Context) ([]any, error)
- func (s *OraclesService) GetOracleChartChainBreakdown(ctx context.Context) ([]any, error)
- func (s *OraclesService) GetOracleChartProtocolBreakdown(ctx context.Context) ([]any, error)
- func (s *OraclesService) GetOracleMetrics(ctx context.Context) (map[string]any, error)
- func (s *OraclesService) GetOracleProtocolChart(ctx context.Context, protocol string) ([]any, error)
- func (s *OraclesService) GetOracleProtocolChartChainBreakdown(ctx context.Context, protocol string) ([]any, error)
- type OverviewOptions
- type PercentageOptions
- type PreIPOCompany
- type PreIPOQuery
- type PreIPOService
- func (s *PreIPOService) GetCompaniesList(ctx context.Context) ([]PreIPOCompany, error)
- func (s *PreIPOService) GetIntegrations(ctx context.Context, opts PreIPOQuery) (map[string]any, error)
- func (s *PreIPOService) GetRaises(ctx context.Context, opts PreIPOQuery) (map[string]any, error)
- func (s *PreIPOService) GetSummary(ctx context.Context, opts PreIPOQuery) (map[string]any, error)
- func (s *PreIPOService) GetValuations(ctx context.Context, opts PreIPOQuery) (map[string]any, error)
- type PricesService
- func (s *PricesService) GetBatchHistoricalPrices(ctx context.Context, coins map[string][]int64) (map[string]any, error)
- func (s *PricesService) GetBlockAtTimestamp(ctx context.Context, chain string, timestamp int64) (*Block, error)
- func (s *PricesService) GetChart(ctx context.Context, coins []string, opts *ChartOptions) (map[string]any, error)
- func (s *PricesService) GetCurrentPrices(ctx context.Context, coins []string) (map[string]CoinPrice, error)
- func (s *PricesService) GetFirstPrices(ctx context.Context, coins []string) (map[string]CoinPrice, error)
- func (s *PricesService) GetHistoricalLiquidity(ctx context.Context, token string) (map[string]any, error)
- func (s *PricesService) GetHistoricalPrices(ctx context.Context, coins []string, timestamp int64) (map[string]CoinPrice, error)
- func (s *PricesService) GetPercentageChange(ctx context.Context, coins []string, opts *PercentageOptions) (map[string]any, error)
- type ProAPIKeyRequiredError
- type Protocol
- type ProtocolDetails
- type RWAAsset
- type RWAChartOptions
- type RWAService
- func (s *RWAService) GetAssetsByChain(ctx context.Context, chain string) (map[string]any, error)
- func (s *RWAService) GetChainChart(ctx context.Context, chain string) ([]any, error)
- func (s *RWAService) GetChartChainBreakdown(ctx context.Context, opts *RWAChartOptions) ([]any, error)
- func (s *RWAService) GetCurrentAssets(ctx context.Context) ([]RWAAsset, error)
- func (s *RWAService) GetList(ctx context.Context) (map[string]any, error)
- func (s *RWAService) GetStats(ctx context.Context) (map[string]any, error)
- type RateLimitError
- type ReceiptObserver
- type ResponseBodyTooLargeError
- type ResponseReceipt
- type RetryPolicy
- type Stablecoin
- type StablecoinChartOptions
- type StablecoinsListOptions
- type StablecoinsService
- func (s *StablecoinsService) GetStablecoin(ctx context.Context, asset int64) (map[string]any, error)
- func (s *StablecoinsService) GetStablecoinChains(ctx context.Context) ([]any, error)
- func (s *StablecoinsService) GetStablecoinCharts(ctx context.Context, opts *StablecoinChartOptions) ([]any, error)
- func (s *StablecoinsService) GetStablecoinChartsByChain(ctx context.Context, chain string, opts *StablecoinChartOptions) ([]any, error)
- func (s *StablecoinsService) GetStablecoinDominance(ctx context.Context, chain string, opts *StablecoinChartOptions) ([]any, error)
- func (s *StablecoinsService) GetStablecoinPrices(ctx context.Context) ([]any, error)
- func (s *StablecoinsService) GetStablecoins(ctx context.Context, opts *StablecoinsListOptions) ([]Stablecoin, error)
- type TVLChartOptions
- type TVLService
- func (s *TVLService) GetChainAssets(ctx context.Context) (map[string]any, error)
- func (s *TVLService) GetChains(ctx context.Context) ([]Chain, error)
- func (s *TVLService) GetHistoricalChainTVL(ctx context.Context) ([]any, error)
- func (s *TVLService) GetHistoricalChainTVLByChain(ctx context.Context, chain string) ([]any, error)
- func (s *TVLService) GetInflows(ctx context.Context, protocol string, timestamp int64) (map[string]any, error)
- func (s *TVLService) GetProtocol(ctx context.Context, protocol string) (*ProtocolDetails, error)
- func (s *TVLService) GetProtocolReceipt(ctx context.Context, protocol string) (*ResponseReceipt, error)
- func (s *TVLService) GetProtocolTVLChart(ctx context.Context, protocol string, opts *TVLChartOptions) ([]any, error)
- func (s *TVLService) GetProtocolTVLChartChainBreakdown(ctx context.Context, protocol string, opts *TVLChartOptions) ([]any, error)
- func (s *TVLService) GetProtocolTVLChartTokenBreakdown(ctx context.Context, protocol string, opts *TVLChartOptions) ([]any, error)
- func (s *TVLService) GetProtocolTVLMetrics(ctx context.Context, protocol string) (map[string]any, error)
- func (s *TVLService) GetProtocols(ctx context.Context) ([]Protocol, error)
- func (s *TVLService) GetProtocolsReceipt(ctx context.Context) (*ResponseReceipt, error)
- func (s *TVLService) GetTVL(ctx context.Context, protocol string) (float64, error)
- func (s *TVLService) GetTokenProtocols(ctx context.Context, symbol string) ([]any, error)
- type TransportError
- type TreasuryChartOptions
- type TreasuryService
- func (s *TreasuryService) GetTreasuryChart(ctx context.Context, protocol string, opts *TreasuryChartOptions) ([]any, error)
- func (s *TreasuryService) GetTreasuryChartChainBreakdown(ctx context.Context, protocol string, opts *TreasuryChartOptions) ([]any, error)
- func (s *TreasuryService) GetTreasuryChartTokenBreakdown(ctx context.Context, protocol string, opts *TreasuryChartOptions) ([]any, error)
- func (s *TreasuryService) GetTreasuryMetrics(ctx context.Context, protocol string) (map[string]any, error)
- type VolumesService
- func (s *VolumesService) GetDEXOverview(ctx context.Context, opts OverviewOptions) (map[string]any, error)
- func (s *VolumesService) GetDEXOverviewByChain(ctx context.Context, chain string, opts OverviewOptions) (map[string]any, error)
- func (s *VolumesService) GetDEXSummary(ctx context.Context, protocol string, opts OverviewOptions) (map[string]any, error)
- func (s *VolumesService) GetDerivativesOverview(ctx context.Context, opts OverviewOptions) (map[string]any, error)
- func (s *VolumesService) GetDerivativesSummary(ctx context.Context, protocol string, opts OverviewOptions) (map[string]any, error)
- func (s *VolumesService) GetOpenInterestOverview(ctx context.Context, opts OverviewOptions) (map[string]any, error)
- func (s *VolumesService) GetOptionsOverview(ctx context.Context, opts OverviewOptions) (map[string]any, error)
- func (s *VolumesService) GetOptionsOverviewByChain(ctx context.Context, chain string, opts OverviewOptions) (map[string]any, error)
- func (s *VolumesService) GetOptionsSummary(ctx context.Context, protocol string, opts *DimensionOptions) (map[string]any, error)
- type YieldPool
- type YieldsService
- func (s *YieldsService) GetBorrowMarketHistory(ctx context.Context, id string, opts *HistoryRangeOptions) (map[string]any, error)
- func (s *YieldsService) GetBorrowMarkets(ctx context.Context) (map[string]any, error)
- func (s *YieldsService) GetBorrowRoutes(ctx context.Context) (map[string]any, error)
- func (s *YieldsService) GetEarnPoolHistory(ctx context.Context, id string, opts *HistoryRangeOptions) (map[string]any, error)
- func (s *YieldsService) GetEarnPools(ctx context.Context) (map[string]any, error)
- func (s *YieldsService) GetLSTRates(ctx context.Context) ([]any, error)
- func (s *YieldsService) GetLegacyBorrowPools(ctx context.Context) (map[string]any, error)
- func (s *YieldsService) GetLegacyLendBorrowChart(ctx context.Context, pool string) (map[string]any, error)
- func (s *YieldsService) GetLegacyPoolChart(ctx context.Context, pool string) (map[string]any, error)
- func (s *YieldsService) GetLegacyPools(ctx context.Context) (map[string]any, error)
- func (s *YieldsService) GetLoopStrategies(ctx context.Context) (map[string]any, error)
- func (s *YieldsService) GetPerpFundingRates(ctx context.Context) (map[string]any, error)
- func (s *YieldsService) GetPoolChart(ctx context.Context, pool string) (map[string]any, error)
- func (s *YieldsService) GetPoolChartReceipt(ctx context.Context, pool string) (*ResponseReceipt, error)
- func (s *YieldsService) GetPools(ctx context.Context) ([]YieldPool, error)
- func (s *YieldsService) GetPoolsReceipt(ctx context.Context) (*ResponseReceipt, error)
- func (s *YieldsService) GetVerifiedEarnPool(ctx context.Context, id string) (map[string]any, error)
- func (s *YieldsService) GetVerifiedEarnPoolHistory(ctx context.Context, id string, opts *HistoryRangeOptions) (map[string]any, error)
- func (s *YieldsService) GetVerifiedEarnPools(ctx context.Context) (map[string]any, error)
- func (s *YieldsService) QueryEarnPools(ctx context.Context, opts EarnPoolsQuery) (map[string]any, error)
Constants ¶
const DefaultMaxResponseBodyBytes int64 = 32 << 20
DefaultMaxResponseBodyBytes is the 32 MiB ceiling applied to every HTTP response body. It is deliberately large enough for protocol and pool lists; use WithMaxResponseBodyBytes when an application has a different budget.
const Version = "1.2.1"
Version is the package version, used in the default User-Agent.
Variables ¶
var ErrResponseBodyTooLarge = errors.New("defillama: response body exceeds configured limit")
ErrResponseBodyTooLarge is matched by ResponseBodyTooLargeError when a response exceeds the configured WithMaxResponseBodyBytes limit.
Functions ¶
Types ¶
type APIError ¶
type APIError struct {
StatusCode int
// URL is the redacted request URL (API key replaced by {API_KEY}).
URL string
// Header is a copy of the response headers with API key values redacted.
Header http.Header
// Body is the response body truncated to 4096 bytes with API key values
// redacted. It is safe to include in application diagnostics.
Body []byte
}
APIError is a non-2xx HTTP response. URL is always the redacted form.
type APIUsage ¶
APIUsage is the response of GET /usage/APIKEY — the Pro key credit balance. The payload shape is not fully documented, so fields are accessed via Raw and the helpers below.
func (*APIUsage) CreditsLeft ¶
CreditsLeft extracts the remaining credit count when present.
type AccountService ¶
type AccountService struct {
// contains filtered or unexported fields
}
AccountService provides access to the Account endpoints.
func (*AccountService) GetUsage ¶
func (s *AccountService) GetUsage(ctx context.Context) (*APIUsage, error)
GetUsage Get amount of credits left in the api key, these reset on the 1st of each month See: https://api-docs.defillama.com/#tag/meta/get/usage/APIKEY
type Block ¶
type Block struct {
Height int64 `json:"height"`
Timestamp int64 `json:"timestamp"`
Raw map[string]any `json:"-"`
}
Block is the response of GET /block/{chain}/{timestamp}.
func (*Block) UnmarshalJSON ¶
UnmarshalJSON decodes the typed fields and retains the raw payload.
type BridgeTransactionsOptions ¶
type BridgeTransactionsOptions struct {
Starttimestamp *int64 // query: starttimestamp
Endtimestamp *int64 // query: endtimestamp
Sourcechain *string // query: sourcechain
Address *string // query: address
Limit *int64 // query: limit
}
BridgeTransactionsOptions holds optional/required query parameters. Nil pointer fields are omitted.
type BridgeVolumeOptions ¶
type BridgeVolumeOptions struct {
ID *int64 // query: id
}
BridgeVolumeOptions holds optional/required query parameters. Nil pointer fields are omitted.
type BridgesOptions ¶
type BridgesOptions struct {
IncludeChains *bool // query: includeChains
}
BridgesOptions holds optional/required query parameters. Nil pointer fields are omitted.
type BridgesService ¶
type BridgesService struct {
// contains filtered or unexported fields
}
BridgesService provides access to the Bridges endpoints.
func (*BridgesService) GetBridge ¶
GetBridge Get summary of bridge volume and volume breakdown by chain See: https://api-docs.defillama.com/#tag/bridges/get/bridges/bridge/%7Bid%7D
func (*BridgesService) GetBridgeDayStats ¶
func (s *BridgesService) GetBridgeDayStats(ctx context.Context, timestamp int64, chain string, opts *BridgeVolumeOptions) (map[string]any, error)
GetBridgeDayStats Get a 24hr token and address volume breakdown for a bridge See: https://api-docs.defillama.com/#tag/bridges/get/bridges/bridgedaystats/%7Btimestamp%7D/%7Bchain%7D
func (*BridgesService) GetBridgeTransactions ¶
func (s *BridgesService) GetBridgeTransactions(ctx context.Context, id int64, opts *BridgeTransactionsOptions) (map[string]any, error)
GetBridgeTransactions Get all transactions for a bridge within a date range See: https://api-docs.defillama.com/#tag/bridges/get/bridges/transactions/%7Bid%7D
func (*BridgesService) GetBridgeVolume ¶
func (s *BridgesService) GetBridgeVolume(ctx context.Context, chain string, opts *BridgeVolumeOptions) ([]any, error)
GetBridgeVolume Get historical volumes for a bridge, chain, or bridge on a particular chain See: https://api-docs.defillama.com/#tag/bridges/get/bridges/bridgevolume/%7Bchain%7D
func (*BridgesService) GetBridges ¶
func (s *BridgesService) GetBridges(ctx context.Context, opts *BridgesOptions) (map[string]any, error)
GetBridges List all bridges along with summaries of recent bridge volumes. See: https://api-docs.defillama.com/#tag/bridges/get/bridges/bridges
type Chain ¶
type Chain struct {
GeckoID string `json:"gecko_id"`
TVL float64 `json:"tvl"`
TokenSymbol string `json:"tokenSymbol"`
CmcID string `json:"cmcId"`
Name string `json:"name"`
ChainID float64 `json:"chainId"`
Raw map[string]any `json:"-"`
}
Chain is an entry of GET /v2/chains.
func (*Chain) UnmarshalJSON ¶
UnmarshalJSON decodes the typed fields and retains the raw payload.
type ChartOptions ¶
type ChartOptions struct {
Start *float64 // query: start
End *float64 // query: end
Span *float64 // query: span
Period *string // query: period
}
ChartOptions holds optional/required query parameters. Nil pointer fields are omitted.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the DefiLlama API client. Construct it with New.
func New ¶
New builds a Client. It performs no network I/O; invalid configuration is reported as *ConfigError.
func (*Client) Account ¶
func (c *Client) Account() *AccountService
Account returns the account/meta service (API key usage).
func (*Client) Bridges ¶
func (c *Client) Bridges() *BridgesService
Bridges returns the bridges service.
func (*Client) DAT ¶
func (c *Client) DAT() *DATService
DAT returns the Digital Asset Treasury service.
func (*Client) Dimensions ¶
func (c *Client) Dimensions() *DimensionsService
Dimensions returns the dimensions service (19 chart/metric endpoints).
func (*Client) Ecosystem ¶
func (c *Client) Ecosystem() *EcosystemService
Ecosystem returns the main-page service (categories, entities, forks, hacks, oracles, raises, treasuries).
func (*Client) Emissions ¶
func (c *Client) Emissions() *EmissionsService
Emissions returns the token unlocks/emissions service.
func (*Client) Equities ¶
func (c *Client) Equities() *EquitiesService
Equities returns the equities service.
func (*Client) FinancialStatements ¶
func (c *Client) FinancialStatements() *FinancialStatementsService
FinancialStatements returns the financial statements service.
func (*Client) IsPro ¶
IsPro reports whether an API key is configured, i.e. Pro endpoints are usable.
func (*Client) Narratives ¶
func (c *Client) Narratives() *NarrativesService
Narratives returns the narratives service.
func (*Client) Oracles ¶
func (c *Client) Oracles() *OraclesService
Oracles returns the oracles service.
func (*Client) PreIPO ¶
func (c *Client) PreIPO() *PreIPOService
PreIPO returns the pre-IPO companies service.
func (*Client) Prices ¶
func (c *Client) Prices() *PricesService
Prices returns the coins/token-liquidity service.
func (*Client) Stablecoins ¶
func (c *Client) Stablecoins() *StablecoinsService
Stablecoins returns the stablecoins service.
func (*Client) TVL ¶
func (c *Client) TVL() *TVLService
TVL returns the TVL service (Free TVL + Pro TVL charts/metrics).
func (*Client) Treasury ¶
func (c *Client) Treasury() *TreasuryService
Treasury returns the protocol treasury service.
func (*Client) Volumes ¶
func (c *Client) Volumes() *VolumesService
Volumes returns the volumes service (DEX/options volume, open interest, derivatives).
func (*Client) Yields ¶
func (c *Client) Yields() *YieldsService
Yields returns the yields service (pools, earn/borrow v2, LST rates, legacy v1).
type CoinPrice ¶
type CoinPrice struct {
Price float64 `json:"price"`
Symbol string `json:"symbol"`
Timestamp int64 `json:"timestamp"`
Decimals float64 `json:"decimals"`
Confidence float64 `json:"confidence"`
Raw map[string]any `json:"-"`
}
CoinPrice is a single record from the coins API.
func (*CoinPrice) UnmarshalJSON ¶
UnmarshalJSON decodes the typed fields and retains the raw payload.
type ConfigError ¶
type ConfigError struct {
Msg string
}
ConfigError reports invalid client configuration. Returned by New before any network I/O takes place.
type DATService ¶
type DATService struct {
// contains filtered or unexported fields
}
DATService provides access to the DAT endpoints.
func (*DATService) GetInstitution ¶
GetInstitution Get individual institution Digital Asset Treasury details See: https://api-docs.defillama.com/#tag/dat/get/dat/institutions/%7Bsymbol%7D
func (*DATService) GetInstitutions ¶
GetInstitutions Get list of all institutions with Digital Asset Treasury data See: https://api-docs.defillama.com/#tag/dat/get/dat/institutions
type DecodeError ¶
DecodeError reports a response body that is not valid JSON.
func (*DecodeError) Unwrap ¶
func (e *DecodeError) Unwrap() error
Unwrap returns the JSON decoding error.
type DimensionOptions ¶
type DimensionOptions struct {
DataType *string // query: dataType
}
DimensionOptions holds optional/required query parameters. Nil pointer fields are omitted.
type DimensionsService ¶
type DimensionsService struct {
// contains filtered or unexported fields
}
DimensionsService provides access to the Dimensions endpoints.
func (*DimensionsService) GetCategoryChainChart ¶
func (s *DimensionsService) GetCategoryChainChart(ctx context.Context, metric string, category string, chain string, opts *DimensionOptions) ([]any, error)
GetCategoryChainChart Get category chain historical timeseries chart data See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/category/%7Bcategory%7D/chain/%7Bchain%7D
func (*DimensionsService) GetCategoryChainChartProtocolBreakdown ¶
func (s *DimensionsService) GetCategoryChainChartProtocolBreakdown(ctx context.Context, metric string, category string, chain string, opts *DimensionOptions) ([]any, error)
GetCategoryChainChartProtocolBreakdown Get category chain timeseries chart data breakdown by protocol See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/category/%7Bcategory%7D/chain/%7Bchain%7D/protocol-breakdown
func (*DimensionsService) GetCategoryChainMetrics ¶
func (s *DimensionsService) GetCategoryChainMetrics(ctx context.Context, metric string, category string, chain string, opts *DimensionOptions) (map[string]any, error)
GetCategoryChainMetrics Get category chain dimension data overview See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/metrics/%7Bmetric%7D/category/%7Bcategory%7D/chain/%7Bchain%7D
func (*DimensionsService) GetCategoryChart ¶
func (s *DimensionsService) GetCategoryChart(ctx context.Context, metric string, category string, opts *DimensionOptions) ([]any, error)
GetCategoryChart Get category historical timeseries chart data See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/category/%7Bcategory%7D
func (*DimensionsService) GetCategoryChartChainBreakdown ¶
func (s *DimensionsService) GetCategoryChartChainBreakdown(ctx context.Context, metric string, category string, opts *DimensionOptions) ([]any, error)
GetCategoryChartChainBreakdown Get category timeseries chart data breakdown by chain See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/category/%7Bcategory%7D/chain-breakdown
func (*DimensionsService) GetCategoryChartProtocolBreakdown ¶
func (s *DimensionsService) GetCategoryChartProtocolBreakdown(ctx context.Context, metric string, category string, opts *DimensionOptions) ([]any, error)
GetCategoryChartProtocolBreakdown Get category timeseries chart data breakdown by protocol See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/category/%7Bcategory%7D/protocol-breakdown
func (*DimensionsService) GetCategoryMetrics ¶
func (s *DimensionsService) GetCategoryMetrics(ctx context.Context, metric string, category string, opts *DimensionOptions) (map[string]any, error)
GetCategoryMetrics Get category dimension data overview See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/metrics/%7Bmetric%7D/category/%7Bcategory%7D
func (*DimensionsService) GetChainChart ¶
func (s *DimensionsService) GetChainChart(ctx context.Context, metric string, chain string, opts *DimensionOptions) ([]any, error)
GetChainChart Get chain historical timeseries chart data See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/chain/%7Bchain%7D
func (*DimensionsService) GetChainChartProtocolBreakdown ¶
func (s *DimensionsService) GetChainChartProtocolBreakdown(ctx context.Context, metric string, chain string, opts *DimensionOptions) ([]any, error)
GetChainChartProtocolBreakdown Get chain timeseries chart data breakdown by protocol See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/chain/%7Bchain%7D/protocol-breakdown
func (*DimensionsService) GetChainMetrics ¶
func (s *DimensionsService) GetChainMetrics(ctx context.Context, metric string, chain string, opts *DimensionOptions) (map[string]any, error)
GetChainMetrics Get chain dimension data overview See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/metrics/%7Bmetric%7D/chain/%7Bchain%7D
func (*DimensionsService) GetChart ¶
func (s *DimensionsService) GetChart(ctx context.Context, metric string, opts *DimensionOptions) ([]any, error)
GetChart Get historical timeseries chart data See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D
func (*DimensionsService) GetChartChainBreakdown ¶
func (s *DimensionsService) GetChartChainBreakdown(ctx context.Context, metric string, opts *DimensionOptions) ([]any, error)
GetChartChainBreakdown Get historical timeseries chart data breakdown by chain See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/chain-breakdown
func (*DimensionsService) GetChartProtocolBreakdown ¶
func (s *DimensionsService) GetChartProtocolBreakdown(ctx context.Context, metric string, opts *DimensionOptions) ([]any, error)
GetChartProtocolBreakdown Get historical timeseries chart data breakdown by protocol See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/protocol-breakdown
func (*DimensionsService) GetMetrics ¶
func (s *DimensionsService) GetMetrics(ctx context.Context, metric string, opts *DimensionOptions) (map[string]any, error)
GetMetrics Get dimension data overview See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/metrics/%7Bmetric%7D
func (*DimensionsService) GetProtocolChart ¶
func (s *DimensionsService) GetProtocolChart(ctx context.Context, metric string, protocol string, opts *DimensionOptions) ([]any, error)
GetProtocolChart Get protocol historical timeseries chart data See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/protocol/%7Bprotocol%7D
func (*DimensionsService) GetProtocolChartChainBreakdown ¶
func (s *DimensionsService) GetProtocolChartChainBreakdown(ctx context.Context, metric string, protocol string, opts *DimensionOptions) ([]any, error)
GetProtocolChartChainBreakdown Get protocol timeseries chart data breakdown by chain See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/protocol/%7Bprotocol%7D/chain-breakdown
func (*DimensionsService) GetProtocolChartLabelBreakdown ¶
func (s *DimensionsService) GetProtocolChartLabelBreakdown(ctx context.Context, metric string, protocol string, opts *DimensionOptions) ([]any, error)
GetProtocolChartLabelBreakdown Get protocol timeseries chart data breakdown by label See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/protocol/%7Bprotocol%7D/label-breakdown
func (*DimensionsService) GetProtocolChartVersionBreakdown ¶
func (s *DimensionsService) GetProtocolChartVersionBreakdown(ctx context.Context, metric string, protocol string, opts *DimensionOptions) ([]any, error)
GetProtocolChartVersionBreakdown Get protocol timeseries chart data breakdown by version See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/chart/%7Bmetric%7D/protocol/%7Bprotocol%7D/version-breakdown
func (*DimensionsService) GetProtocolMetrics ¶
func (s *DimensionsService) GetProtocolMetrics(ctx context.Context, metric string, protocol string, opts *DimensionOptions) (map[string]any, error)
GetProtocolMetrics Get protocol dimension data overview See: https://api-docs.defillama.com/#tag/dimensions/get/api/v2/metrics/%7Bmetric%7D/protocol/%7Bprotocol%7D
type ETFsService ¶
type ETFsService struct {
// contains filtered or unexported fields
}
ETFsService provides access to the ETFs endpoints.
func (*ETFsService) GetFlows ¶
func (s *ETFsService) GetFlows(ctx context.Context) ([]any, error)
GetFlows Historical Flows at the Asset Level See: https://api-docs.defillama.com/#tag/etfs/get/etfs/flows
func (*ETFsService) GetSnapshot ¶
func (s *ETFsService) GetSnapshot(ctx context.Context) ([]any, error)
GetSnapshot Get ETFs and their metrics (aum, flows, fees...) See: https://api-docs.defillama.com/#tag/etfs/get/etfs/snapshot
type EarnPoolsQuery ¶
type EarnPoolsQuery struct {
Chain *string // query: chain
Protocol *string // query: protocol
Stablecoin *bool // query: stablecoin
SingleAssetExposure *bool // query: single_asset_exposure
ImpermanentLossRisk *bool // query: impermanent_loss_risk
MinTVL *float64 // query: min_tvl
Page *int64 // query: page
Limit *int64 // query: limit
}
EarnPoolsQuery holds optional/required query parameters. Nil pointer fields are omitted.
type EcosystemService ¶
type EcosystemService struct {
// contains filtered or unexported fields
}
EcosystemService provides access to the Ecosystem endpoints.
func (*EcosystemService) GetCategories ¶
GetCategories Overview of all categories across all protocols See: https://api-docs.defillama.com/#tag/main-page/get/api/categories
func (*EcosystemService) GetEntities ¶
func (s *EcosystemService) GetEntities(ctx context.Context) ([]any, error)
GetEntities List all entities See: https://api-docs.defillama.com/#tag/main-page/get/api/entities
func (*EcosystemService) GetForks ¶
GetForks Overview of all forks across all protocols See: https://api-docs.defillama.com/#tag/main-page/get/api/forks
func (*EcosystemService) GetHacks ¶
func (s *EcosystemService) GetHacks(ctx context.Context) ([]any, error)
GetHacks Overview of all hacks on our Hacks dashboard See: https://api-docs.defillama.com/#tag/main-page/get/api/hacks
func (*EcosystemService) GetOracles ¶
GetOracles Overview of all oracles across all protocols See: https://api-docs.defillama.com/#tag/main-page/get/api/oracles
func (*EcosystemService) GetRaises ¶
GetRaises Overview of all raises on our Raises dashboard See: https://api-docs.defillama.com/#tag/main-page/get/api/raises
func (*EcosystemService) GetTreasuries ¶
func (s *EcosystemService) GetTreasuries(ctx context.Context) ([]any, error)
GetTreasuries List all protocols on our Treasuries dashboard See: https://api-docs.defillama.com/#tag/main-page/get/api/treasuries
type EmissionsService ¶
type EmissionsService struct {
// contains filtered or unexported fields
}
EmissionsService provides access to the Emissions endpoints.
func (*EmissionsService) GetEmission ¶
func (s *EmissionsService) GetEmission(ctx context.Context, protocol string) (map[string]any, error)
GetEmission Unlocks data for a given token/protocol. You can find a list of available slugs to query by querying /emissions and then extracting the key `gecko_id` See: https://api-docs.defillama.com/#tag/unlocks/get/api/emission/%7Bprotocol%7D
func (*EmissionsService) GetEmissions ¶
func (s *EmissionsService) GetEmissions(ctx context.Context) ([]any, error)
GetEmissions List of all tokens along with basic info for each See: https://api-docs.defillama.com/#tag/unlocks/get/api/emissions
type EquitiesQuery ¶
type EquitiesQuery struct {
Ticker string // query: ticker
Country string // query: country
Timeframe *string // query: timeframe
}
EquitiesQuery holds optional/required query parameters. Nil pointer fields are omitted.
type EquitiesService ¶
type EquitiesService struct {
// contains filtered or unexported fields
}
EquitiesService provides access to the Equities endpoints.
func (*EquitiesService) GetCompaniesList ¶
func (s *EquitiesService) GetCompaniesList(ctx context.Context) ([]EquityCompany, error)
GetCompaniesList Get list of all tracked public companies See: https://api-docs.defillama.com/#tag/equities/get/equities/v1/companies-list
func (*EquitiesService) GetDimensions ¶
func (s *EquitiesService) GetDimensions(ctx context.Context, opts EquitiesQuery) (map[string]any, error)
GetDimensions Get financial dimensions for a company See: https://api-docs.defillama.com/#tag/equities/get/equities/v1/dimensions
func (*EquitiesService) GetFilings ¶
func (s *EquitiesService) GetFilings(ctx context.Context, opts EquitiesQuery) ([]any, error)
GetFilings Get filings for a company See: https://api-docs.defillama.com/#tag/equities/get/equities/v1/filings
func (*EquitiesService) GetOHLCV ¶
func (s *EquitiesService) GetOHLCV(ctx context.Context, opts EquitiesQuery) ([]any, error)
GetOHLCV Get OHLCV candle data for a company See: https://api-docs.defillama.com/#tag/equities/get/equities/v1/ohlcv
func (*EquitiesService) GetOnchainMarkets ¶
func (s *EquitiesService) GetOnchainMarkets(ctx context.Context, opts EquitiesQuery) (map[string]any, error)
GetOnchainMarkets Get on-chain tradeable markets for a company See: https://api-docs.defillama.com/#tag/equities/get/equities/v1/onchain
func (*EquitiesService) GetPriceHistory ¶
func (s *EquitiesService) GetPriceHistory(ctx context.Context, opts EquitiesQuery) ([]any, error)
GetPriceHistory Get historical price data for a company See: https://api-docs.defillama.com/#tag/equities/get/equities/v1/price-history
func (*EquitiesService) GetStatements ¶
func (s *EquitiesService) GetStatements(ctx context.Context, opts EquitiesQuery) (map[string]any, error)
GetStatements Get financial statements for a company See: https://api-docs.defillama.com/#tag/equities/get/equities/v1/statements
func (*EquitiesService) GetSummary ¶
func (s *EquitiesService) GetSummary(ctx context.Context, opts EquitiesQuery) (map[string]any, error)
GetSummary Get live market summary for a company See: https://api-docs.defillama.com/#tag/equities/get/equities/v1/summary
type EquityCompany ¶
type EquityCompany struct {
Ticker string `json:"ticker"`
CompanyName string `json:"companyName"`
Country string `json:"country"`
CountryName string `json:"countryName"`
Raw map[string]any `json:"-"`
}
EquityCompany is an entry of GET /equities/v1/companies-list.
func (*EquityCompany) UnmarshalJSON ¶
func (e *EquityCompany) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes the typed fields and retains the raw payload.
type FeesService ¶
type FeesService struct {
// contains filtered or unexported fields
}
FeesService provides access to the Fees endpoints.
func (*FeesService) GetOverview ¶
func (s *FeesService) GetOverview(ctx context.Context, opts OverviewOptions) (map[string]any, error)
GetOverview List all protocols along with summaries of their fees and revenue and dataType history data See: https://api-docs.defillama.com/#tag/fees-and-revenue/get/overview/fees
func (*FeesService) GetOverviewByChain ¶
func (s *FeesService) GetOverviewByChain(ctx context.Context, chain string, opts OverviewOptions) (map[string]any, error)
GetOverviewByChain List all protocols along with summaries of their fees and revenue and dataType history data by chain See: https://api-docs.defillama.com/#tag/fees-and-revenue/get/overview/fees/%7Bchain%7D
func (*FeesService) GetSummary ¶
func (s *FeesService) GetSummary(ctx context.Context, protocol string, opts *DimensionOptions) (map[string]any, error)
GetSummary Get summary of protocol fees and revenue with historical data See: https://api-docs.defillama.com/#tag/fees-and-revenue/get/summary/fees/%7Bprotocol%7D
type FinancialStatementsService ¶
type FinancialStatementsService struct {
// contains filtered or unexported fields
}
FinancialStatementsService provides access to the FinancialStatements endpoints.
func (*FinancialStatementsService) GetIncomeStatement ¶
func (s *FinancialStatementsService) GetIncomeStatement(ctx context.Context, protocol string) (map[string]any, error)
GetIncomeStatement Get protocol income statement report See: https://api-docs.defillama.com/#tag/financial-statements/get/api/v2/metrics/financial-statement/protocol/%7Bprotocol%7D
type ForksService ¶
type ForksService struct {
// contains filtered or unexported fields
}
ForksService provides access to the Forks endpoints.
func (*ForksService) GetForkChartProtocolBreakdown ¶
func (s *ForksService) GetForkChartProtocolBreakdown(ctx context.Context) ([]any, error)
GetForkChartProtocolBreakdown Get timeseries chart data breakdown by protocol See: https://api-docs.defillama.com/#tag/forks/get/api/v2/chart/fork/protocol-breakdown
func (*ForksService) GetForkMetrics ¶
GetForkMetrics Get fork data overview See: https://api-docs.defillama.com/#tag/forks/get/api/v2/metrics/fork
func (*ForksService) GetForkProtocolChart ¶
GetForkProtocolChart Get timeseries chart data by protocol See: https://api-docs.defillama.com/#tag/forks/get/api/v2/chart/fork/protocol/%7Bprotocol%7D
type HistoryRangeOptions ¶
type HistoryRangeOptions struct {
Range *string // query: range
}
HistoryRangeOptions holds optional/required query parameters. Nil pointer fields are omitted.
type LosslessObject ¶ added in v1.1.0
type LosslessObject struct {
// contains filtered or unexported fields
}
LosslessObject stores an open JSON object without converting number lexemes to float64. It intentionally exposes accessors rather than a mutable map so unknown provider fields remain inspectable without sharing SDK-owned bytes.
func (LosslessObject) Field ¶ added in v1.1.0
func (o LosslessObject) Field(name string) (LosslessValue, bool)
Field returns a lossless member value and whether it was present. A present null is returned with ok=true and Value.IsNull()==true.
func (LosslessObject) Has ¶ added in v1.1.0
func (o LosslessObject) Has(name string) bool
Has reports whether a member was present, including when its value was null.
func (LosslessObject) Keys ¶ added in v1.1.0
func (o LosslessObject) Keys() []string
Keys returns object member names in stable lexical order.
func (*LosslessObject) UnmarshalJSON ¶ added in v1.1.0
func (o *LosslessObject) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler while preserving every member's original JSON representation.
type LosslessProtocol ¶ added in v1.1.0
type LosslessProtocol struct {
// contains filtered or unexported fields
}
LosslessProtocol is one provider-native protocol record. Chain and token maps remain open through Fields rather than being constrained to an enum.
func (LosslessProtocol) Fields ¶ added in v1.1.0
func (p LosslessProtocol) Fields() LosslessObject
Fields returns the complete open object for this protocol record.
func (LosslessProtocol) ID ¶ added in v1.1.0
func (p LosslessProtocol) ID() (string, bool, error)
ID returns the provider-native protocol identifier when present.
type LosslessProtocolDetails ¶ added in v1.1.0
type LosslessProtocolDetails struct {
// contains filtered or unexported fields
}
LosslessProtocolDetails is a provider-native response from GET /protocol/{protocol}. It intentionally models only selected stable fields; Fields retains the full response, including open chain/token maps.
func (LosslessProtocolDetails) ChainTVLs ¶ added in v1.1.0
func (d LosslessProtocolDetails) ChainTVLs() (LosslessObject, bool, error)
ChainTVLs returns the open per-chain TVL map when present.
func (LosslessProtocolDetails) Fields ¶ added in v1.1.0
func (d LosslessProtocolDetails) Fields() LosslessObject
Fields returns the complete open provider object.
func (LosslessProtocolDetails) ID ¶ added in v1.1.0
func (d LosslessProtocolDetails) ID() (string, bool, error)
ID returns the provider-native protocol identifier when present.
func (LosslessProtocolDetails) Name ¶ added in v1.1.0
func (d LosslessProtocolDetails) Name() (string, bool, error)
Name returns the provider-native protocol name when present.
func (LosslessProtocolDetails) TVLHistory ¶ added in v1.1.0
func (d LosslessProtocolDetails) TVLHistory() ([]LosslessObject, bool, error)
TVLHistory returns provider history records exactly as open objects. Provider date values are provider timestamps (Unix seconds), not capture times.
func (*LosslessProtocolDetails) UnmarshalJSON ¶ added in v1.1.0
func (d *LosslessProtocolDetails) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
type LosslessProtocols ¶ added in v1.1.0
type LosslessProtocols struct {
// contains filtered or unexported fields
}
LosslessProtocols is a provider-native response from GET /protocols. It exposes only selected convenience fields; all provider additions remain in each entry's Fields object.
func (LosslessProtocols) Entries ¶ added in v1.1.0
func (p LosslessProtocols) Entries() []LosslessProtocol
Entries returns the provider-native protocol records.
func (*LosslessProtocols) UnmarshalJSON ¶ added in v1.1.0
func (p *LosslessProtocols) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for the protocol array response.
type LosslessValue ¶ added in v1.1.0
type LosslessValue struct {
// contains filtered or unexported fields
}
LosslessValue preserves one JSON value exactly and exposes safe, typed convenience accessors. It distinguishes an absent object member (Field's ok=false), a present null (IsNull), and numeric zero (Number returns "0").
func (LosslessValue) Array ¶ added in v1.1.0
func (v LosslessValue) Array() ([]LosslessValue, error)
Array returns values from a JSON array while retaining each element exactly.
func (LosslessValue) IsNull ¶ added in v1.1.0
func (v LosslessValue) IsNull() bool
IsNull reports whether the preserved value is the JSON literal null.
func (LosslessValue) Number ¶ added in v1.1.0
func (v LosslessValue) Number() (json.Number, error)
Number returns the original numeric lexeme without a float64 conversion.
func (LosslessValue) Object ¶ added in v1.1.0
func (v LosslessValue) Object() (LosslessObject, error)
Object returns a nested open JSON object.
func (LosslessValue) RawJSON ¶ added in v1.1.0
func (v LosslessValue) RawJSON() []byte
RawJSON returns a copy of the exact JSON value bytes.
func (LosslessValue) String ¶ added in v1.1.0
func (v LosslessValue) String() (string, error)
String returns a JSON string value.
type LosslessYieldChart ¶ added in v1.1.0
type LosslessYieldChart struct {
// contains filtered or unexported fields
}
LosslessYieldChart is a provider-native response from GET /chart/{pool}. It contains only selected convenience accessors; all extra response and point fields remain available in open Fields objects.
func (LosslessYieldChart) Fields ¶ added in v1.1.0
func (c LosslessYieldChart) Fields() LosslessObject
Fields returns the complete open chart response object.
func (LosslessYieldChart) Points ¶ added in v1.1.0
func (c LosslessYieldChart) Points() ([]LosslessYieldChartPoint, bool, error)
Points returns chart records as open provider objects.
func (*LosslessYieldChart) UnmarshalJSON ¶ added in v1.1.0
func (c *LosslessYieldChart) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
type LosslessYieldChartPoint ¶ added in v1.1.0
type LosslessYieldChartPoint struct {
// contains filtered or unexported fields
}
LosslessYieldChartPoint is one provider-native chart record. Timestamp is an ISO-8601 provider timestamp, distinct from ResponseReceipt.CapturedAt.
func (LosslessYieldChartPoint) APY ¶ added in v1.1.0
func (p LosslessYieldChartPoint) APY() (json.Number, bool, error)
APY returns the exact APY percentage lexeme when present and non-null.
func (LosslessYieldChartPoint) APYBase ¶ added in v1.1.0
func (p LosslessYieldChartPoint) APYBase() (json.Number, bool, error)
APYBase returns the exact base APY percentage lexeme when present and non-null.
func (LosslessYieldChartPoint) APYReward ¶ added in v1.1.0
func (p LosslessYieldChartPoint) APYReward() (LosslessValue, bool)
APYReward returns the raw reward APY member, preserving absent/null/zero.
func (LosslessYieldChartPoint) Fields ¶ added in v1.1.0
func (p LosslessYieldChartPoint) Fields() LosslessObject
Fields returns the complete open provider object.
type LosslessYieldPool ¶ added in v1.1.0
type LosslessYieldPool struct {
// contains filtered or unexported fields
}
LosslessYieldPool is a provider-native yield pool. APY values are provider percentages, not ratios. Predictions and classification fields remain open in Fields and are not interpreted as observed APY.
func (LosslessYieldPool) APY ¶ added in v1.1.0
func (p LosslessYieldPool) APY() (json.Number, bool, error)
APY returns the exact APY percentage lexeme when present and non-null.
func (LosslessYieldPool) APYBase ¶ added in v1.1.0
func (p LosslessYieldPool) APYBase() (json.Number, bool, error)
APYBase returns the exact base APY percentage lexeme when present and non-null.
func (LosslessYieldPool) APYReward ¶ added in v1.1.0
func (p LosslessYieldPool) APYReward() (LosslessValue, bool)
APYReward returns the raw APY reward member. Use the returned present value plus IsNull to distinguish absent, null, and numeric zero.
func (LosslessYieldPool) Fields ¶ added in v1.1.0
func (p LosslessYieldPool) Fields() LosslessObject
Fields returns the complete open provider object.
func (LosslessYieldPool) PoolID ¶ added in v1.1.0
func (p LosslessYieldPool) PoolID() (string, bool, error)
PoolID returns the provider-native pool identifier, not a universal asset ID.
func (LosslessYieldPool) RewardTokens ¶ added in v1.1.0
func (p LosslessYieldPool) RewardTokens() (LosslessValue, bool)
RewardTokens returns the raw rewardTokens member. It preserves the distinction between absent, null, and an empty array.
type LosslessYieldPools ¶ added in v1.1.0
type LosslessYieldPools struct {
// contains filtered or unexported fields
}
LosslessYieldPools is a provider-native response from GET /pools.
func (LosslessYieldPools) Fields ¶ added in v1.1.0
func (p LosslessYieldPools) Fields() LosslessObject
Fields returns the complete open response object.
func (LosslessYieldPools) Pools ¶ added in v1.1.0
func (p LosslessYieldPools) Pools() ([]LosslessYieldPool, bool, error)
Pools returns provider-native pool records as open objects.
func (*LosslessYieldPools) UnmarshalJSON ¶ added in v1.1.0
func (p *LosslessYieldPools) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler.
type NarrativesService ¶
type NarrativesService struct {
// contains filtered or unexported fields
}
NarrativesService provides access to the Narratives endpoints.
func (*NarrativesService) GetPerformance ¶
GetPerformance Get chart of narratives based on category performance (with individual coins weighted by mcap) See: https://api-docs.defillama.com/#tag/narratives/get/fdv/performance/%7Bperiod%7D
type Option ¶
type Option func(*config) error
Option configures a Client.
func WithAPIKey ¶
WithAPIKey sets the DefiLlama Pro API key. The key is embedded as a single URL path segment (https://pro-api.llama.fi/{API_KEY}/...) — never a header or query parameter — and is redacted from all errors and diagnostics. The application decides how to source the secret (e.g. os.Getenv).
func WithBaseURLsForTesting ¶
WithBaseURLsForTesting overrides default base URLs. For tests and advanced use only: keys are the default origins ("https://api.llama.fi", "https://coins.llama.fi", "https://stablecoins.llama.fi", "https://yields.llama.fi", "https://pro-api.llama.fi").
func WithHTTPClient ¶
WithHTTPClient sets a custom *http.Client for all requests. When unset, a default client is built using WithTimeout.
func WithMaxResponseBodyBytes ¶ added in v1.2.0
WithMaxResponseBodyBytes sets the maximum number of response bytes retained and decoded for each request. The default is DefaultMaxResponseBodyBytes (32 MiB). An over-limit response returns a ResponseBodyTooLargeError and is never retried.
func WithPreferProForFree ¶
WithPreferProForFree routes the 31 Free endpoints through their official Pro equivalents when an API key is configured (/protocols -> /api/protocols, prices -> /coins/..., stablecoins -> /stablecoins/..., yields -> /yields/...). Default: false — Free routes use their own per-operation origins.
func WithReceiptObserver ¶ added in v1.1.0
func WithReceiptObserver(observer ReceiptObserver) Option
WithReceiptObserver receives an immutable ResponseReceipt for every HTTP response the SDK receives, including retryable responses before a later attempt succeeds. Use it when your application needs to retain provider receipts outside the SDK's ordinary typed response boundary.
The observer runs synchronously in the request goroutine. It receives a redacted URL and defensive copies from Body and Header; avoid logging or persisting receipt bodies unless your application's data policy allows it.
func WithRetryPolicy ¶
func WithRetryPolicy(p RetryPolicy) Option
WithRetryPolicy configures bounded retries for idempotent GET requests. Only transient network errors, HTTP 429 and HTTP 5xx are retried; Retry-After is honored. Default: no retries.
func WithTimeout ¶
WithTimeout sets the default request timeout. It is applied to the default http.Client; a custom WithHTTPClient manages its own timeouts. Per-request deadlines can always be tightened via context.
func WithUserAgent ¶
WithUserAgent overrides the default "defillama-go/<version>" User-Agent.
type OraclesService ¶
type OraclesService struct {
// contains filtered or unexported fields
}
OraclesService provides access to the Oracles endpoints.
func (*OraclesService) GetOracleChainChart ¶
GetOracleChainChart Get timeseries chart data by chain See: https://api-docs.defillama.com/#tag/oracles/get/api/v2/chart/oracle/chain/%7Bchain%7D
func (*OraclesService) GetOracleChainChartProtocolBreakdown ¶
func (s *OraclesService) GetOracleChainChartProtocolBreakdown(ctx context.Context, chain string) ([]any, error)
GetOracleChainChartProtocolBreakdown Get protocol breakdown timeseries chart data by chain See: https://api-docs.defillama.com/#tag/oracles/get/api/v2/chart/oracle/chain/%7Bchain%7D/protocol-breakdown
func (*OraclesService) GetOracleChart ¶
func (s *OraclesService) GetOracleChart(ctx context.Context) ([]any, error)
GetOracleChart Get timeseries chart data for all oracles See: https://api-docs.defillama.com/#tag/oracles/get/api/v2/chart/oracle
func (*OraclesService) GetOracleChartChainBreakdown ¶
func (s *OraclesService) GetOracleChartChainBreakdown(ctx context.Context) ([]any, error)
GetOracleChartChainBreakdown Get timeseries chart data breakdown by chain See: https://api-docs.defillama.com/#tag/oracles/get/api/v2/chart/oracle/chain-breakdown
func (*OraclesService) GetOracleChartProtocolBreakdown ¶
func (s *OraclesService) GetOracleChartProtocolBreakdown(ctx context.Context) ([]any, error)
GetOracleChartProtocolBreakdown Get timeseries chart data breakdown by protocol See: https://api-docs.defillama.com/#tag/oracles/get/api/v2/chart/oracle/protocol-breakdown
func (*OraclesService) GetOracleMetrics ¶
GetOracleMetrics Get oracle data overview See: https://api-docs.defillama.com/#tag/oracles/get/api/v2/metrics/oracle
func (*OraclesService) GetOracleProtocolChart ¶
func (s *OraclesService) GetOracleProtocolChart(ctx context.Context, protocol string) ([]any, error)
GetOracleProtocolChart Get timeseries chart data by protocol/oracle See: https://api-docs.defillama.com/#tag/oracles/get/api/v2/chart/oracle/protocol/%7Bprotocol%7D
func (*OraclesService) GetOracleProtocolChartChainBreakdown ¶
func (s *OraclesService) GetOracleProtocolChartChainBreakdown(ctx context.Context, protocol string) ([]any, error)
GetOracleProtocolChartChainBreakdown Get chain breakdown timeseries chart data by protocol/oracle See: https://api-docs.defillama.com/#tag/oracles/get/api/v2/chart/oracle/protocol/%7Bprotocol%7D/chain-breakdown
type OverviewOptions ¶
type OverviewOptions struct {
ExcludeTotalDataChart bool // query: excludeTotalDataChart
ExcludeTotalDataChartBreakdown bool // query: excludeTotalDataChartBreakdown
DataType *string // query: dataType
}
OverviewOptions holds optional/required query parameters. Nil pointer fields are omitted.
type PercentageOptions ¶
type PercentageOptions struct {
Timestamp *float64 // query: timestamp
LookForward *bool // query: lookForward
Period *string // query: period
}
PercentageOptions holds optional/required query parameters. Nil pointer fields are omitted.
type PreIPOCompany ¶
type PreIPOCompany struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Website string `json:"website"`
Sector string `json:"sector"`
LatestEstimatedValuation *float64 `json:"latestEstimatedValuation"`
LatestRaise *float64 `json:"latestRaise"`
LatestFundingValuation *float64 `json:"latestFundingValuation"`
LatestFundingDate string `json:"latestFundingDate"`
TotalRaised *float64 `json:"totalRaised"`
Raw map[string]any `json:"-"`
}
PreIPOCompany is an entry of GET /pre-ipo/v1/companies-list (data array).
func (*PreIPOCompany) UnmarshalJSON ¶
func (p *PreIPOCompany) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes the typed fields and retains the raw payload.
type PreIPOQuery ¶
type PreIPOQuery struct {
Company string // query: company
}
PreIPOQuery holds optional/required query parameters. Nil pointer fields are omitted.
type PreIPOService ¶
type PreIPOService struct {
// contains filtered or unexported fields
}
PreIPOService provides access to the PreIPO endpoints.
func (*PreIPOService) GetCompaniesList ¶
func (s *PreIPOService) GetCompaniesList(ctx context.Context) ([]PreIPOCompany, error)
GetCompaniesList Get list of all tracked pre-IPO companies See: https://api-docs.defillama.com/#tag/pre-ipo/get/pre-ipo/v1/companies-list
func (*PreIPOService) GetIntegrations ¶
func (s *PreIPOService) GetIntegrations(ctx context.Context, opts PreIPOQuery) (map[string]any, error)
GetIntegrations Get tradeable markets for a pre-IPO company See: https://api-docs.defillama.com/#tag/pre-ipo/get/pre-ipo/v1/integrations
func (*PreIPOService) GetRaises ¶
func (s *PreIPOService) GetRaises(ctx context.Context, opts PreIPOQuery) (map[string]any, error)
GetRaises Get funding rounds for a pre-IPO company See: https://api-docs.defillama.com/#tag/pre-ipo/get/pre-ipo/v1/raises
func (*PreIPOService) GetSummary ¶
func (s *PreIPOService) GetSummary(ctx context.Context, opts PreIPOQuery) (map[string]any, error)
GetSummary Get profile and latest valuation for a pre-IPO company See: https://api-docs.defillama.com/#tag/pre-ipo/get/pre-ipo/v1/summary
func (*PreIPOService) GetValuations ¶
func (s *PreIPOService) GetValuations(ctx context.Context, opts PreIPOQuery) (map[string]any, error)
GetValuations Get valuation history for a pre-IPO company See: https://api-docs.defillama.com/#tag/pre-ipo/get/pre-ipo/v1/valuations
type PricesService ¶
type PricesService struct {
// contains filtered or unexported fields
}
PricesService provides access to the Prices endpoints.
func (*PricesService) GetBatchHistoricalPrices ¶
func (s *PricesService) GetBatchHistoricalPrices(ctx context.Context, coins map[string][]int64) (map[string]any, error)
GetBatchHistoricalPrices Get historical prices for multiple tokens at multiple different timestamps See: https://api-docs.defillama.com/#tag/coins/get/batchHistorical
func (*PricesService) GetBlockAtTimestamp ¶
func (s *PricesService) GetBlockAtTimestamp(ctx context.Context, chain string, timestamp int64) (*Block, error)
GetBlockAtTimestamp Get the closest block to a timestamp See: https://api-docs.defillama.com/#tag/coins/get/block/%7Bchain%7D/%7Btimestamp%7D
func (*PricesService) GetChart ¶
func (s *PricesService) GetChart(ctx context.Context, coins []string, opts *ChartOptions) (map[string]any, error)
GetChart Get token prices at regular time intervals See: https://api-docs.defillama.com/#tag/coins/get/chart/%7Bcoins%7D
func (*PricesService) GetCurrentPrices ¶
func (s *PricesService) GetCurrentPrices(ctx context.Context, coins []string) (map[string]CoinPrice, error)
GetCurrentPrices Get current prices of tokens by contract address See: https://api-docs.defillama.com/#tag/coins/get/prices/current/%7Bcoins%7D
func (*PricesService) GetFirstPrices ¶
func (s *PricesService) GetFirstPrices(ctx context.Context, coins []string) (map[string]CoinPrice, error)
GetFirstPrices Get earliest timestamp price record for coins See: https://api-docs.defillama.com/#tag/coins/get/prices/first/%7Bcoins%7D
func (*PricesService) GetHistoricalLiquidity ¶
func (s *PricesService) GetHistoricalLiquidity(ctx context.Context, token string) (map[string]any, error)
GetHistoricalLiquidity Provides the name of contracts on a determined chain See: https://api-docs.defillama.com/#tag/token-liquidity/get/api/historicalLiquidity/%7Btoken%7D
func (*PricesService) GetHistoricalPrices ¶
func (s *PricesService) GetHistoricalPrices(ctx context.Context, coins []string, timestamp int64) (map[string]CoinPrice, error)
GetHistoricalPrices Get historical prices of tokens by contract address See: https://api-docs.defillama.com/#tag/coins/get/prices/historical/%7Btimestamp%7D/%7Bcoins%7D
func (*PricesService) GetPercentageChange ¶
func (s *PricesService) GetPercentageChange(ctx context.Context, coins []string, opts *PercentageOptions) (map[string]any, error)
GetPercentageChange Get percentage change in price over time See: https://api-docs.defillama.com/#tag/coins/get/percentage/%7Bcoins%7D
type ProAPIKeyRequiredError ¶
type ProAPIKeyRequiredError struct {
// Route is the registry route id ("GET /path").
Route string
}
ProAPIKeyRequiredError is returned locally — before any HTTP request is built — when a Pro endpoint is called without an API key.
func (*ProAPIKeyRequiredError) Error ¶
func (e *ProAPIKeyRequiredError) Error() string
Error implements error.
type Protocol ¶
type Protocol struct {
ID string `json:"id"`
Name string `json:"name"`
Symbol string `json:"symbol"`
Category string `json:"category"`
Chains []string `json:"chains"`
TVL float64 `json:"tvl"`
ChainTVLs map[string]float64 `json:"chainTvls"`
Change1d float64 `json:"change_1d"`
Change7d float64 `json:"change_7d"`
Raw map[string]any `json:"-"`
}
Protocol is an entry of GET /protocols.
func (*Protocol) UnmarshalJSON ¶
UnmarshalJSON decodes the typed fields and retains the raw payload.
type ProtocolDetails ¶
ProtocolDetails is the response of GET /protocol/{protocol}. The shape evolves, so the decoded payload is exposed via Raw with typed accessors for the stable fields.
func (*ProtocolDetails) ChainTVLs ¶
func (d *ProtocolDetails) ChainTVLs() map[string]any
ChainTVLs returns the per-chain TVL breakdown.
func (*ProtocolDetails) Name ¶
func (d *ProtocolDetails) Name() string
Name returns the protocol name, if present.
func (*ProtocolDetails) Slug ¶
func (d *ProtocolDetails) Slug() string
Slug returns the protocol slug, if present.
func (*ProtocolDetails) TVLHistory ¶
func (d *ProtocolDetails) TVLHistory() []any
TVLHistory returns the raw historical TVL series.
type RWAAsset ¶
type RWAAsset struct {
ID string `json:"id"`
Ticker string `json:"ticker"`
AssetName string `json:"assetName"`
AssetGroup string `json:"assetGroup"`
Issuer string `json:"issuer"`
Chain []string `json:"chain"`
Category []string `json:"category"`
OnChainMcap map[string]float64 `json:"onChainMcap"`
Price *float64 `json:"price"`
Stablecoin *bool `json:"stablecoin"`
Governance *bool `json:"governance"`
Raw map[string]any `json:"-"`
}
RWAAsset is an entry of GET /rwa/current and /rwa/chain/{chain}.
func (*RWAAsset) UnmarshalJSON ¶
UnmarshalJSON decodes the typed fields and retains the raw payload.
type RWAChartOptions ¶
type RWAChartOptions struct {
Key *string // query: key
IncludeStablecoin *bool // query: includeStablecoin
IncludeGovernance *bool // query: includeGovernance
}
RWAChartOptions holds optional/required query parameters. Nil pointer fields are omitted.
type RWAService ¶
type RWAService struct {
// contains filtered or unexported fields
}
RWAService provides access to the RWA endpoints.
func (*RWAService) GetAssetsByChain ¶
GetAssetsByChain List current RWA assets on a chain See: https://api-docs.defillama.com/#tag/rwa/get/rwa/chain/%7Bchain%7D
func (*RWAService) GetChainChart ¶
GetChainChart Get historical RWA chart data for a chain See: https://api-docs.defillama.com/#tag/rwa/get/rwa/chart/chain/%7Bchain%7D
func (*RWAService) GetChartChainBreakdown ¶
func (s *RWAService) GetChartChainBreakdown(ctx context.Context, opts *RWAChartOptions) ([]any, error)
GetChartChainBreakdown Get historical RWA metric breakdown by chain See: https://api-docs.defillama.com/#tag/rwa/get/rwa/chart/chain-breakdown
func (*RWAService) GetCurrentAssets ¶
func (s *RWAService) GetCurrentAssets(ctx context.Context) ([]RWAAsset, error)
GetCurrentAssets List all current RWA assets See: https://api-docs.defillama.com/#tag/rwa/get/rwa/current
func (*RWAService) GetList ¶
GetList List RWA ids and filter values See: https://api-docs.defillama.com/#tag/rwa/get/rwa/list
func (*RWAService) GetStats ¶
GetStats Get aggregate RWA stats by chain, category, platform, and asset group See: https://api-docs.defillama.com/#tag/rwa/get/rwa/stats
type RateLimitError ¶
RateLimitError is an HTTP 429 response. RetryAfter is the parsed Retry-After value, or zero when the header was absent/unparseable.
type ReceiptObserver ¶ added in v1.1.0
type ReceiptObserver func(ResponseReceipt)
ReceiptObserver receives one immutable receipt for every HTTP response the SDK receives, including retryable responses before a later retry succeeds. The observer runs synchronously in the calling request's goroutine.
type ResponseBodyTooLargeError ¶ added in v1.2.0
type ResponseBodyTooLargeError struct {
Limit int64
}
ResponseBodyTooLargeError reports a response that exceeded the configured body limit. It is never retryable because a retry would not reduce the body.
func (*ResponseBodyTooLargeError) Error ¶ added in v1.2.0
func (e *ResponseBodyTooLargeError) Error() string
Error implements error.
func (*ResponseBodyTooLargeError) Unwrap ¶ added in v1.2.0
func (e *ResponseBodyTooLargeError) Unwrap() error
Unwrap allows errors.Is(err, ErrResponseBodyTooLarge).
type ResponseReceipt ¶ added in v1.1.0
type ResponseReceipt struct {
// Route is the SDK route identifier, for example "GET /protocols".
Route string
// SourceURL is the redacted request URL actually selected for this response.
SourceURL string
// DocsURL points to the route's official API reference when available.
DocsURL string
// StatusCode is the HTTP response status.
StatusCode int
// Attempt is the one-based request attempt number for this operation.
Attempt int
// CapturedAt is when the SDK received the response, in UTC. It is distinct
// from any provider timestamp in the response body.
CapturedAt time.Time
// CompletedAt is when bounded reading, draining, and closing the original
// response body completed. It is distinct from provider event time.
CompletedAt time.Time
// Complete reports that the original body reached EOF within the configured
// limit and closed successfully. It does not indicate an HTTP success, valid
// JSON, or provider-data quality.
Complete bool
// contains filtered or unexported fields
}
ResponseReceipt is an immutable record of one HTTP response received by the SDK. It preserves the response body byte-for-byte and records the selected route, its redacted request URL, and transport lifecycle times. It may hold an incomplete prefix when the body cannot be fully read or exceeds the configured response limit.
Body returns a copy. Decode uses json.Decoder.UseNumber, so numbers decoded into interface values remain json.Number rather than float64. Receipts are intended for callers that need a lossless boundary around provider-native data; callers are responsible for retaining them securely.
func (ResponseReceipt) Body ¶ added in v1.1.0
func (r ResponseReceipt) Body() []byte
Body returns an independent copy of the exact response body bytes.
func (ResponseReceipt) BodySHA256 ¶ added in v1.1.0
func (r ResponseReceipt) BodySHA256() string
BodySHA256 returns the lowercase SHA-256 digest of the exact response body.
func (ResponseReceipt) Decode ¶ added in v1.1.0
func (r ResponseReceipt) Decode(out any) error
Decode decodes the exact receipt body into out with json.Number preserved. It rejects trailing data and multiple JSON values.
func (ResponseReceipt) Header ¶ added in v1.1.0
func (r ResponseReceipt) Header() http.Header
Header returns an independent copy of the response headers.
type RetryPolicy ¶
type RetryPolicy struct {
// MaxAttempts is the total number of attempts including the first (1 = off).
MaxAttempts int
// BaseDelay is the delay before the first retry; it doubles per attempt.
BaseDelay time.Duration
// MaxDelay caps a single delay.
MaxDelay time.Duration
// Jitter adds +/-50% randomization to each computed delay.
Jitter bool
}
RetryPolicy configures bounded retries for GET requests.
type Stablecoin ¶
type Stablecoin struct {
ID string `json:"id"`
Name string `json:"name"`
Symbol string `json:"symbol"`
PegType string `json:"pegType"`
PegMechanism string `json:"pegMechanism"`
Circulating map[string]any `json:"circulating"`
Chains []string `json:"chains"`
Price float64 `json:"price"`
Raw map[string]any `json:"-"`
}
Stablecoin is an entry of GET /stablecoins (peggedAssets).
func (*Stablecoin) UnmarshalJSON ¶
func (s *Stablecoin) UnmarshalJSON(b []byte) error
UnmarshalJSON decodes the typed fields and retains the raw payload.
type StablecoinChartOptions ¶
type StablecoinChartOptions struct {
Stablecoin *int64 // query: stablecoin
}
StablecoinChartOptions holds optional/required query parameters. Nil pointer fields are omitted.
type StablecoinsListOptions ¶
type StablecoinsListOptions struct {
IncludePrices *bool // query: includePrices
}
StablecoinsListOptions holds optional/required query parameters. Nil pointer fields are omitted.
type StablecoinsService ¶
type StablecoinsService struct {
// contains filtered or unexported fields
}
StablecoinsService provides access to the Stablecoins endpoints.
func (*StablecoinsService) GetStablecoin ¶
func (s *StablecoinsService) GetStablecoin(ctx context.Context, asset int64) (map[string]any, error)
GetStablecoin Get historical mcap and historical chain distribution of a stablecoin See: https://api-docs.defillama.com/#tag/stablecoins/get/stablecoin/%7Basset%7D
func (*StablecoinsService) GetStablecoinChains ¶
func (s *StablecoinsService) GetStablecoinChains(ctx context.Context) ([]any, error)
GetStablecoinChains Get current mcap sum of all stablecoins on each chain See: https://api-docs.defillama.com/#tag/stablecoins/get/stablecoinchains
func (*StablecoinsService) GetStablecoinCharts ¶
func (s *StablecoinsService) GetStablecoinCharts(ctx context.Context, opts *StablecoinChartOptions) ([]any, error)
GetStablecoinCharts Get historical mcap sum of all stablecoins See: https://api-docs.defillama.com/#tag/stablecoins/get/stablecoincharts/all
func (*StablecoinsService) GetStablecoinChartsByChain ¶
func (s *StablecoinsService) GetStablecoinChartsByChain(ctx context.Context, chain string, opts *StablecoinChartOptions) ([]any, error)
GetStablecoinChartsByChain Get historical mcap sum of all stablecoins in a chain See: https://api-docs.defillama.com/#tag/stablecoins/get/stablecoincharts/%7Bchain%7D
func (*StablecoinsService) GetStablecoinDominance ¶
func (s *StablecoinsService) GetStablecoinDominance(ctx context.Context, chain string, opts *StablecoinChartOptions) ([]any, error)
GetStablecoinDominance Get stablecoin dominance per chain along with the info about the larges coin in a chain See: https://api-docs.defillama.com/#tag/stablecoins/get/stablecoins/stablecoindominance/%7Bchain%7D
func (*StablecoinsService) GetStablecoinPrices ¶
func (s *StablecoinsService) GetStablecoinPrices(ctx context.Context) ([]any, error)
GetStablecoinPrices Get historical prices of all stablecoins See: https://api-docs.defillama.com/#tag/stablecoins/get/stablecoinprices
func (*StablecoinsService) GetStablecoins ¶
func (s *StablecoinsService) GetStablecoins(ctx context.Context, opts *StablecoinsListOptions) ([]Stablecoin, error)
GetStablecoins List all stablecoins along with their circulating amounts See: https://api-docs.defillama.com/#tag/stablecoins/get/stablecoins
type TVLChartOptions ¶
TVLChartOptions holds optional/required query parameters. Nil pointer fields are omitted.
type TVLService ¶
type TVLService struct {
// contains filtered or unexported fields
}
TVLService provides access to the TVL endpoints.
func (*TVLService) GetChainAssets ¶
GetChainAssets Get assets of all chains See: https://api-docs.defillama.com/#tag/tvl/get/api/chainAssets
func (*TVLService) GetChains ¶
func (s *TVLService) GetChains(ctx context.Context) ([]Chain, error)
GetChains Get current TVL of all chains See: https://api-docs.defillama.com/#tag/tvl/get/v2/chains
func (*TVLService) GetHistoricalChainTVL ¶
func (s *TVLService) GetHistoricalChainTVL(ctx context.Context) ([]any, error)
GetHistoricalChainTVL Get historical TVL (excludes liquid staking and double counted tvl) of DeFi on all chains See: https://api-docs.defillama.com/#tag/tvl/get/v2/historicalChainTvl
func (*TVLService) GetHistoricalChainTVLByChain ¶
GetHistoricalChainTVLByChain Get historical TVL (excludes liquid staking and double counted tvl) of a chain See: https://api-docs.defillama.com/#tag/tvl/get/v2/historicalChainTvl/%7Bchain%7D
func (*TVLService) GetInflows ¶
func (s *TVLService) GetInflows(ctx context.Context, protocol string, timestamp int64) (map[string]any, error)
GetInflows Lists the amount of inflows and outflows for a protocol at a given date See: https://api-docs.defillama.com/#tag/tvl/get/api/inflows/%7Bprotocol%7D/%7Btimestamp%7D
func (*TVLService) GetProtocol ¶
func (s *TVLService) GetProtocol(ctx context.Context, protocol string) (*ProtocolDetails, error)
GetProtocol Get historical TVL of a protocol and breakdowns by token and chain See: https://api-docs.defillama.com/#tag/tvl/get/protocol/%7Bprotocol%7D
func (*TVLService) GetProtocolReceipt ¶ added in v1.1.0
func (s *TVLService) GetProtocolReceipt(ctx context.Context, protocol string) (*ResponseReceipt, error)
GetProtocolReceipt returns the lossless HTTP receipt for GET /protocol/{protocol}. Decode it into LosslessProtocolDetails to retain exact numeric lexemes and open chain/token maps.
func (*TVLService) GetProtocolTVLChart ¶
func (s *TVLService) GetProtocolTVLChart(ctx context.Context, protocol string, opts *TVLChartOptions) ([]any, error)
GetProtocolTVLChart Get historical TVL chart for a protocol See: https://api-docs.defillama.com/#tag/tvl/get/api/v2/chart/tvl/protocol/%7Bprotocol%7D
func (*TVLService) GetProtocolTVLChartChainBreakdown ¶
func (s *TVLService) GetProtocolTVLChartChainBreakdown(ctx context.Context, protocol string, opts *TVLChartOptions) ([]any, error)
GetProtocolTVLChartChainBreakdown Get historical TVL chart for a protocol broken down by chain See: https://api-docs.defillama.com/#tag/tvl/get/api/v2/chart/tvl/protocol/%7Bprotocol%7D/chain-breakdown
func (*TVLService) GetProtocolTVLChartTokenBreakdown ¶
func (s *TVLService) GetProtocolTVLChartTokenBreakdown(ctx context.Context, protocol string, opts *TVLChartOptions) ([]any, error)
GetProtocolTVLChartTokenBreakdown Get historical TVL chart for a protocol broken down by token See: https://api-docs.defillama.com/#tag/tvl/get/api/v2/chart/tvl/protocol/%7Bprotocol%7D/token-breakdown
func (*TVLService) GetProtocolTVLMetrics ¶
func (s *TVLService) GetProtocolTVLMetrics(ctx context.Context, protocol string) (map[string]any, error)
GetProtocolTVLMetrics Get aggregate TVL metrics for a protocol See: https://api-docs.defillama.com/#tag/tvl/get/api/v2/metrics/tvl/protocol/%7Bprotocol%7D
func (*TVLService) GetProtocols ¶
func (s *TVLService) GetProtocols(ctx context.Context) ([]Protocol, error)
GetProtocols List all protocols on defillama along with their tvl See: https://api-docs.defillama.com/#tag/tvl/get/protocols
func (*TVLService) GetProtocolsReceipt ¶ added in v1.1.0
func (s *TVLService) GetProtocolsReceipt(ctx context.Context) (*ResponseReceipt, error)
GetProtocolsReceipt returns the lossless HTTP receipt for GET /protocols. Decode it into LosslessProtocols to retain exact numeric lexemes and open provider fields, or use ResponseReceipt.Decode with a caller-owned DTO.
func (*TVLService) GetTVL ¶
GetTVL Simplified endpoint to get current TVL of a protocol See: https://api-docs.defillama.com/#tag/tvl/get/tvl/%7Bprotocol%7D
func (*TVLService) GetTokenProtocols ¶
GetTokenProtocols Lists the amount of a certain token within all protocols. Data for the Token Usage page See: https://api-docs.defillama.com/#tag/tvl/get/api/tokenProtocols/%7Bsymbol%7D
type TransportError ¶
type TransportError struct {
// URL is the redacted request URL (API key replaced by {API_KEY}).
URL string
Err error
}
TransportError wraps a network-level failure (DNS, TLS, timeout, ...). Unwrap exposes the underlying error; errors.Is/As work through it.
func (*TransportError) Unwrap ¶
func (e *TransportError) Unwrap() error
Unwrap returns the wrapped network error.
type TreasuryChartOptions ¶
TreasuryChartOptions holds optional/required query parameters. Nil pointer fields are omitted.
type TreasuryService ¶
type TreasuryService struct {
// contains filtered or unexported fields
}
TreasuryService provides access to the Treasury endpoints.
func (*TreasuryService) GetTreasuryChart ¶
func (s *TreasuryService) GetTreasuryChart(ctx context.Context, protocol string, opts *TreasuryChartOptions) ([]any, error)
GetTreasuryChart Get historical treasury chart for a protocol See: https://api-docs.defillama.com/#tag/treasury/get/api/v2/chart/treasury/protocol/%7Bprotocol%7D
func (*TreasuryService) GetTreasuryChartChainBreakdown ¶
func (s *TreasuryService) GetTreasuryChartChainBreakdown(ctx context.Context, protocol string, opts *TreasuryChartOptions) ([]any, error)
GetTreasuryChartChainBreakdown Get historical treasury chart for a protocol broken down by chain See: https://api-docs.defillama.com/#tag/treasury/get/api/v2/chart/treasury/protocol/%7Bprotocol%7D/chain-breakdown
func (*TreasuryService) GetTreasuryChartTokenBreakdown ¶
func (s *TreasuryService) GetTreasuryChartTokenBreakdown(ctx context.Context, protocol string, opts *TreasuryChartOptions) ([]any, error)
GetTreasuryChartTokenBreakdown Get historical treasury chart for a protocol broken down by token See: https://api-docs.defillama.com/#tag/treasury/get/api/v2/chart/treasury/protocol/%7Bprotocol%7D/token-breakdown
func (*TreasuryService) GetTreasuryMetrics ¶
func (s *TreasuryService) GetTreasuryMetrics(ctx context.Context, protocol string) (map[string]any, error)
GetTreasuryMetrics Get aggregate treasury metrics for a protocol See: https://api-docs.defillama.com/#tag/treasury/get/api/v2/metrics/treasury/protocol/%7Bprotocol%7D
type VolumesService ¶
type VolumesService struct {
// contains filtered or unexported fields
}
VolumesService provides access to the Volumes endpoints.
func (*VolumesService) GetDEXOverview ¶
func (s *VolumesService) GetDEXOverview(ctx context.Context, opts OverviewOptions) (map[string]any, error)
GetDEXOverview List all dexs along with summaries of their volumes and dataType history data See: https://api-docs.defillama.com/#tag/volumes/get/overview/dexs
func (*VolumesService) GetDEXOverviewByChain ¶
func (s *VolumesService) GetDEXOverviewByChain(ctx context.Context, chain string, opts OverviewOptions) (map[string]any, error)
GetDEXOverviewByChain List all dexs along with summaries of their volumes and dataType history data filtering by chain See: https://api-docs.defillama.com/#tag/volumes/get/overview/dexs/%7Bchain%7D
func (*VolumesService) GetDEXSummary ¶
func (s *VolumesService) GetDEXSummary(ctx context.Context, protocol string, opts OverviewOptions) (map[string]any, error)
GetDEXSummary Get summary of dex volume with historical data See: https://api-docs.defillama.com/#tag/volumes/get/summary/dexs/%7Bprotocol%7D
func (*VolumesService) GetDerivativesOverview ¶
func (s *VolumesService) GetDerivativesOverview(ctx context.Context, opts OverviewOptions) (map[string]any, error)
GetDerivativesOverview Lists all derivatives along summaries of their volumes filtering by chain See: https://api-docs.defillama.com/#tag/perps/get/api/overview/derivatives
func (*VolumesService) GetDerivativesSummary ¶
func (s *VolumesService) GetDerivativesSummary(ctx context.Context, protocol string, opts OverviewOptions) (map[string]any, error)
GetDerivativesSummary Volume Details about a specific perp protocol See: https://api-docs.defillama.com/#tag/perps/get/api/summary/derivatives/%7Bprotocol%7D
func (*VolumesService) GetOpenInterestOverview ¶
func (s *VolumesService) GetOpenInterestOverview(ctx context.Context, opts OverviewOptions) (map[string]any, error)
GetOpenInterestOverview List all open interest dex exchanges along with summaries of their open interest See: https://api-docs.defillama.com/#tag/perps/get/overview/open-interest
func (*VolumesService) GetOptionsOverview ¶
func (s *VolumesService) GetOptionsOverview(ctx context.Context, opts OverviewOptions) (map[string]any, error)
GetOptionsOverview List all options dexs along with summaries of their volumes and dataType history data See: https://api-docs.defillama.com/#tag/volumes/get/overview/options
func (*VolumesService) GetOptionsOverviewByChain ¶
func (s *VolumesService) GetOptionsOverviewByChain(ctx context.Context, chain string, opts OverviewOptions) (map[string]any, error)
GetOptionsOverviewByChain List all options dexs along with summaries of their volumes and dataType history data filtering by chain See: https://api-docs.defillama.com/#tag/volumes/get/overview/options/%7Bchain%7D
func (*VolumesService) GetOptionsSummary ¶
func (s *VolumesService) GetOptionsSummary(ctx context.Context, protocol string, opts *DimensionOptions) (map[string]any, error)
GetOptionsSummary Get summary of options dex volume with historical data See: https://api-docs.defillama.com/#tag/volumes/get/summary/options/%7Bprotocol%7D
type YieldPool ¶
type YieldPool struct {
Pool string `json:"pool"`
Chain string `json:"chain"`
Project string `json:"project"`
Symbol string `json:"symbol"`
TVLUsd float64 `json:"tvlUsd"`
APY float64 `json:"apy"`
APYBase float64 `json:"apyBase"`
APYReward *float64 `json:"apyReward"`
Stablecoin bool `json:"stablecoin"`
IlRisk string `json:"ilRisk"`
Exposure string `json:"exposure"`
RewardTokens []string `json:"rewardTokens"`
Predictions map[string]any `json:"predictions"`
Raw map[string]any `json:"-"`
}
YieldPool is an entry of GET yields.llama.fi/pools (data array).
func (*YieldPool) UnmarshalJSON ¶
UnmarshalJSON decodes the typed fields and retains the raw payload.
type YieldsService ¶
type YieldsService struct {
// contains filtered or unexported fields
}
YieldsService provides access to the Yields endpoints.
func (*YieldsService) GetBorrowMarketHistory ¶
func (s *YieldsService) GetBorrowMarketHistory(ctx context.Context, id string, opts *HistoryRangeOptions) (map[string]any, error)
GetBorrowMarketHistory Retrieve daily borrow-side history for a borrow market See: https://api-docs.defillama.com/#tag/yields/get/yields/v2/borrow/markets/%7Bid%7D/history
func (*YieldsService) GetBorrowMarkets ¶
GetBorrowMarkets Retrieve the latest data for all borrow markets See: https://api-docs.defillama.com/#tag/yields/get/yields/v2/borrow/markets
func (*YieldsService) GetBorrowRoutes ¶
GetBorrowRoutes Retrieve the latest data for all borrow routes See: https://api-docs.defillama.com/#tag/yields/get/yields/v2/borrow/routes
func (*YieldsService) GetEarnPoolHistory ¶
func (s *YieldsService) GetEarnPoolHistory(ctx context.Context, id string, opts *HistoryRangeOptions) (map[string]any, error)
GetEarnPoolHistory Retrieve daily history for an earn pool See: https://api-docs.defillama.com/#tag/yields/get/yields/v2/earn/%7Bid%7D/history
func (*YieldsService) GetEarnPools ¶
GetEarnPools Retrieve the latest data for all earn pools See: https://api-docs.defillama.com/#tag/yields/get/yields/v2/earn
func (*YieldsService) GetLSTRates ¶
func (s *YieldsService) GetLSTRates(ctx context.Context) ([]any, error)
GetLSTRates Exchange rates and ETH peg of liquid staking tokens See: https://api-docs.defillama.com/#tag/yields/get/api/lstRates
func (*YieldsService) GetLegacyBorrowPools ¶
GetLegacyBorrowPools Borrow costs APY of assets from lending markets in the legacy v1 response format See: https://api-docs.defillama.com/#tag/yields/get/yields/v1/poolsBorrow
func (*YieldsService) GetLegacyLendBorrowChart ¶
func (s *YieldsService) GetLegacyLendBorrowChart(ctx context.Context, pool string) (map[string]any, error)
GetLegacyLendBorrowChart Historical borrow cost APY from a pool on a lending market in the legacy v1 response format See: https://api-docs.defillama.com/#tag/yields/get/yields/v1/chartLendBorrow/%7Bpool%7D
func (*YieldsService) GetLegacyPoolChart ¶
func (s *YieldsService) GetLegacyPoolChart(ctx context.Context, pool string) (map[string]any, error)
GetLegacyPoolChart Get historical APY and TVL of a pool in the legacy v1 response format See: https://api-docs.defillama.com/#tag/yields/get/yields/v1/chart/%7Bpool%7D
func (*YieldsService) GetLegacyPools ¶
GetLegacyPools Retrieve the latest data for all pools in the legacy v1 response format See: https://api-docs.defillama.com/#tag/yields/get/yields/v1/pools
func (*YieldsService) GetLoopStrategies ¶
GetLoopStrategies Retrieve the latest data for all loop strategies See: https://api-docs.defillama.com/#tag/yields/get/yields/v2/loops
func (*YieldsService) GetPerpFundingRates ¶
GetPerpFundingRates Funding rates and Open Interest of perps across exchanges, including both Decentralized and Centralized See: https://api-docs.defillama.com/#tag/yields/get/yields/perps
func (*YieldsService) GetPoolChart ¶
GetPoolChart Get historical APY and TVL of a pool See: https://api-docs.defillama.com/#tag/yields/get/chart/%7Bpool%7D
func (*YieldsService) GetPoolChartReceipt ¶ added in v1.1.0
func (s *YieldsService) GetPoolChartReceipt(ctx context.Context, pool string) (*ResponseReceipt, error)
GetPoolChartReceipt returns the lossless HTTP receipt for GET /chart/{pool}. Decode it into LosslessYieldChart to retain ISO-8601 provider timestamps and exact APY/TVL number lexemes.
func (*YieldsService) GetPools ¶
func (s *YieldsService) GetPools(ctx context.Context) ([]YieldPool, error)
GetPools Retrieve the latest data for all pools, including enriched information such as predictions See: https://api-docs.defillama.com/#tag/yields/get/pools
func (*YieldsService) GetPoolsReceipt ¶ added in v1.1.0
func (s *YieldsService) GetPoolsReceipt(ctx context.Context) (*ResponseReceipt, error)
GetPoolsReceipt returns the lossless HTTP receipt for GET /pools. Decode it into LosslessYieldPools to preserve provider-native pool IDs, number lexemes, and absent/null/zero distinctions for open response fields.
func (*YieldsService) GetVerifiedEarnPool ¶
GetVerifiedEarnPool Retrieve the latest verified data for one earn pool See: https://api-docs.defillama.com/#tag/yields/get/yields/v2/earn/verified/%7Bid%7D
func (*YieldsService) GetVerifiedEarnPoolHistory ¶
func (s *YieldsService) GetVerifiedEarnPoolHistory(ctx context.Context, id string, opts *HistoryRangeOptions) (map[string]any, error)
GetVerifiedEarnPoolHistory Retrieve daily verified history for an earn pool See: https://api-docs.defillama.com/#tag/yields/get/yields/v2/earn/verified/%7Bid%7D/history
func (*YieldsService) GetVerifiedEarnPools ¶
GetVerifiedEarnPools Retrieve the latest verified data for all measured earn pools See: https://api-docs.defillama.com/#tag/yields/get/yields/v2/earn/verified
func (*YieldsService) QueryEarnPools ¶
func (s *YieldsService) QueryEarnPools(ctx context.Context, opts EarnPoolsQuery) (map[string]any, error)
QueryEarnPools Retrieve a filtered, paginated page of earn pools See: https://api-docs.defillama.com/#tag/yields/get/yields/v2/earn/query
Source Files
¶
- client.go
- config.go
- errors.go
- helpers.go
- lossless.go
- options.go
- receipt.go
- route.go
- routes.go
- service_account.go
- service_bridges.go
- service_dat.go
- service_dimensions.go
- service_ecosystem.go
- service_emissions.go
- service_equities.go
- service_etfs.go
- service_fees.go
- service_financialstatements.go
- service_forks.go
- service_narratives.go
- service_oracles.go
- service_preipo.go
- service_prices.go
- service_rwa.go
- service_stablecoins.go
- service_treasury.go
- service_tvl.go
- service_volumes.go
- service_yields.go
- transport.go
- types.go
