Documentation
¶
Overview ¶
Package coinglass provides a Go SDK for the Coinglass API v4 (https://open-api-v4.coinglass.com). It exposes service structs grouped by resource (Futures, Spot, Options, ETF, Indicators) accessible as fields on Client.
Package coinglass provides a Go SDK for the Coinglass API v4.
Index ¶
- Constants
- Variables
- func BoolPtr(b bool) *bool
- func Float64Ptr(f float64) *float64
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func StringPtr(s string) *string
- type APIError
- type ArbitrageItem
- type BasisHistoryParams
- type BasisPoint
- type Client
- type CoinMarket
- type CoinbasePremiumParams
- type CoinsMarketsParams
- type ETFFlowParams
- type ETFFlowPoint
- type ETFItem
- type ETFNetAssetsParams
- type ETFNetAssetsPoint
- type ETFService
- func (s *ETFService) BitcoinFlowHistory(ctx context.Context, params *ETFFlowParams) ([]ETFFlowPoint, error)
- func (s *ETFService) BitcoinList(ctx context.Context) ([]ETFItem, error)
- func (s *ETFService) BitcoinNetAssetsHistory(ctx context.Context, params *ETFNetAssetsParams) ([]ETFNetAssetsPoint, error)
- func (s *ETFService) EthereumFlowHistory(ctx context.Context, params *ETFFlowParams) ([]ETFFlowPoint, error)
- func (s *ETFService) EthereumList(ctx context.Context) ([]ETFItem, error)
- func (s *ETFService) GrayscaleHoldings(ctx context.Context) ([]GrayscaleHolding, error)
- type ExchangePair
- type FearGreedParams
- type FearGreedPoint
- type FundingRateArbitrageParams
- type FundingRateExchange
- type FundingRateExchangeListParams
- type FundingRateHistoryParams
- type FundingRatePoint
- type FuturesService
- func (s *FuturesService) CoinsMarkets(ctx context.Context, params *CoinsMarketsParams) ([]CoinMarket, error)
- func (s *FuturesService) FundingRateArbitrage(ctx context.Context, params *FundingRateArbitrageParams) ([]ArbitrageItem, error)
- func (s *FuturesService) FundingRateExchangeList(ctx context.Context, params *FundingRateExchangeListParams) ([]FundingRateExchange, error)
- func (s *FuturesService) FundingRateHistory(ctx context.Context, params *FundingRateHistoryParams) ([]FundingRatePoint, error)
- func (s *FuturesService) FundingRateOiWeighted(ctx context.Context, params *FundingRateHistoryParams) ([]FundingRatePoint, error)
- func (s *FuturesService) LargeOrders(ctx context.Context, params *LargeOrdersParams) ([]LargeOrder, error)
- func (s *FuturesService) LiquidationAggregatedHistory(ctx context.Context, params *LiquidationAggregatedHistoryParams) ([]LiquidationPoint, error)
- func (s *FuturesService) LiquidationCoinList(ctx context.Context, params *LiquidationCoinListParams) ([]LiquidationCoin, error)
- func (s *FuturesService) LiquidationHeatmap(ctx context.Context, model int, params *LiquidationHeatmapParams) (*LiquidationHeatmap, error)
- func (s *FuturesService) LiquidationHistory(ctx context.Context, params *LiquidationHistoryParams) ([]LiquidationPoint, error)
- func (s *FuturesService) LiquidationMap(ctx context.Context, params *LiquidationMapParams) (*LiquidationMap, error)
- func (s *FuturesService) LongShortRatioHistory(ctx context.Context, params *LongShortRatioParams) ([]LongShortPoint, error)
- func (s *FuturesService) OpenInterestAggregatedHistory(ctx context.Context, params *OIHistoryParams) ([]OIHistoryPoint, error)
- func (s *FuturesService) OpenInterestExchangeList(ctx context.Context, params *OIExchangeListParams) ([]OIExchangeItem, error)
- func (s *FuturesService) OpenInterestHistory(ctx context.Context, params *OIHistoryParams) ([]OIHistoryPoint, error)
- func (s *FuturesService) OrderbookHistory(ctx context.Context, params *OrderbookHistoryParams) ([]OrderbookPoint, error)
- func (s *FuturesService) PairsMarkets(ctx context.Context, params *PairsMarketsParams) ([]PairMarket, error)
- func (s *FuturesService) PriceChangeList(ctx context.Context) ([]PriceChangeItem, error)
- func (s *FuturesService) SupportedCoins(ctx context.Context) ([]string, error)
- func (s *FuturesService) SupportedExchangePairs(ctx context.Context, params *SupportedExchangePairsParams) (map[string][]ExchangePair, error)
- func (s *FuturesService) TakerBuySellHistory(ctx context.Context, params *TakerBuySellHistoryParams) ([]TakerBuySellPoint, error)
- func (s *FuturesService) TopLongShortRatioHistory(ctx context.Context, params *LongShortRatioParams) ([]LongShortPoint, error)
- func (s *FuturesService) WhaleAlert(ctx context.Context, params *WhaleAlertParams) ([]WhaleAlert, error)
- type GrayscaleHolding
- type IndicatorsService
- func (s *IndicatorsService) BasisHistory(ctx context.Context, params *BasisHistoryParams) ([]BasisPoint, error)
- func (s *IndicatorsService) BitcoinRainbowChart(ctx context.Context) (*RainbowChart, error)
- func (s *IndicatorsService) CoinbasePremium(ctx context.Context, params *CoinbasePremiumParams) ([]PremiumPoint, error)
- func (s *IndicatorsService) FearGreedHistory(ctx context.Context, params *FearGreedParams) ([]FearGreedPoint, error)
- func (s *IndicatorsService) RSIList(ctx context.Context, params *RSIListParams) ([]RSIItem, error)
- func (s *IndicatorsService) StablecoinMarketCap(ctx context.Context, params *StablecoinMarketCapParams) ([]StablecoinPoint, error)
- func (s *IndicatorsService) StockToFlow(ctx context.Context) (*StockToFlow, error)
- type LargeOrder
- type LargeOrdersParams
- type LiquidationAggregatedHistoryParams
- type LiquidationCoin
- type LiquidationCoinListParams
- type LiquidationHeatmap
- type LiquidationHeatmapParams
- type LiquidationHeatmapPoint
- type LiquidationHistoryParams
- type LiquidationMap
- type LiquidationMapParams
- type LiquidationPoint
- type LongShortPoint
- type LongShortRatioParams
- type OIExchangeItem
- type OIExchangeListParams
- type OIHistoryParams
- type OIHistoryPoint
- type Option
- type OptionHistoryParams
- type OptionInfo
- type OptionMaxPain
- type OptionOIPoint
- type OptionParams
- type OptionVolPoint
- type OptionsService
- func (s *OptionsService) ExchangeOIHistory(ctx context.Context, params *OptionHistoryParams) ([]OptionOIPoint, error)
- func (s *OptionsService) ExchangeVolHistory(ctx context.Context, params *OptionHistoryParams) ([]OptionVolPoint, error)
- func (s *OptionsService) Info(ctx context.Context, params *OptionParams) (*OptionInfo, error)
- func (s *OptionsService) MaxPain(ctx context.Context, params *OptionParams) (*OptionMaxPain, error)
- type OrderbookHistoryParams
- type OrderbookPoint
- type PairMarket
- type PairsMarketsParams
- type PremiumPoint
- type PriceChangeItem
- type PricePoint
- type RSIItem
- type RSIListParams
- type RainbowChart
- type SpotCoinMarket
- type SpotCoinsMarketsParams
- type SpotOrderbookHistoryParams
- type SpotPairMarket
- type SpotPairsMarketsParams
- type SpotPriceHistoryParams
- type SpotService
- func (s *SpotService) CoinsMarkets(ctx context.Context, params *SpotCoinsMarketsParams) ([]SpotCoinMarket, error)
- func (s *SpotService) OrderbookHistory(ctx context.Context, params *SpotOrderbookHistoryParams) ([]OrderbookPoint, error)
- func (s *SpotService) PairsMarkets(ctx context.Context, params *SpotPairsMarketsParams) ([]SpotPairMarket, error)
- func (s *SpotService) PriceHistory(ctx context.Context, params *SpotPriceHistoryParams) ([]PricePoint, error)
- func (s *SpotService) SupportedCoins(ctx context.Context) ([]string, error)
- func (s *SpotService) TakerBuySellHistory(ctx context.Context, params *SpotTakerBuySellHistoryParams) ([]TakerBuySellPoint, error)
- type SpotTakerBuySellHistoryParams
- type StablecoinMarketCapParams
- type StablecoinPoint
- type StockToFlow
- type SupportedExchangePairsParams
- type TakerBuySellHistoryParams
- type TakerBuySellPoint
- type WhaleAlert
- type WhaleAlertParams
Constants ¶
const DefaultBaseDelay = 500 * time.Millisecond
DefaultBaseDelay is the default initial backoff delay used for retry attempts, unless overridden with WithRetry.
const DefaultBaseURL = "https://open-api-v4.coinglass.com"
DefaultBaseURL is the default Coinglass API v4 base URL used by NewClient unless overridden with WithBaseURL.
const DefaultMaxAttempts = 1
DefaultMaxAttempts is the default number of attempts (including the initial request) made for a request before giving up when receiving HTTP 429 responses, unless overridden with WithRetry.
const DefaultTimeout = 30 * time.Second
DefaultTimeout is the default HTTP client timeout used unless overridden with WithTimeout.
Variables ¶
var ( ErrUnauthorized = errors.New("coinglass: unauthorized — check your API key") // ErrNotFound is returned when the API responds with HTTP 404. ErrNotFound = errors.New("coinglass: resource not found") // ErrRateLimited is returned when the API responds with HTTP 429 and // all retry attempts have been exhausted. ErrRateLimited = errors.New("coinglass: rate limit exceeded") )
Sentinel errors that can be checked with errors.Is against errors returned from service methods. The underlying *APIError is always available via errors.As for accessing StatusCode/RawBody.
Functions ¶
func Float64Ptr ¶
Float64Ptr returns a pointer to the provided float64 value.
Types ¶
type APIError ¶
type APIError struct {
// StatusCode is the HTTP status code returned by the API.
StatusCode int
// Code is the Coinglass API-level code, if present in the response.
Code string
// Message is a human-readable error message.
Message string
// RawBody contains the raw response body for debugging purposes.
RawBody []byte
}
APIError represents an error response returned by the Coinglass API. It is returned by every service method when the API responds with a non-2xx HTTP status code or a non-zero API code.
type ArbitrageItem ¶
type ArbitrageItem struct {
Symbol string `json:"symbol"`
Exchange string `json:"exchange"`
FundingRate float64 `json:"fundingRate"`
Spread float64 `json:"spread"`
}
ArbitrageItem represents a single funding-rate arbitrage opportunity.
type BasisHistoryParams ¶
type BasisHistoryParams struct {
Symbol string `url:"symbol"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
}
BasisHistoryParams holds parameters for BasisHistory.
type BasisPoint ¶
BasisPoint represents a single futures basis history point.
type Client ¶
type Client struct {
// Futures provides access to the futures endpoints.
Futures *FuturesService
// Spot provides access to the spot endpoints.
Spot *SpotService
// Options provides access to the options endpoints.
Options *OptionsService
// ETF provides access to the ETF endpoints.
ETF *ETFService
// Indicators provides access to the indicator endpoints.
Indicators *IndicatorsService
// contains filtered or unexported fields
}
Client is the entry point of the Coinglass Go SDK. It holds the HTTP configuration and exposes one service struct per API resource group. A Client is safe for concurrent use by multiple goroutines.
func NewClient ¶
NewClient creates a new Coinglass API client authenticated with the given apiKey. The apiKey is sent in the CG-API-KEY header on every request. Behaviour can be customized via Option values such as WithBaseURL, WithHTTPClient, WithTimeout, and WithRetry.
Example:
client := coinglass.NewClient("YOUR_API_KEY",
coinglass.WithTimeout(15*time.Second),
coinglass.WithRetry(3, time.Second),
)
func NewClientFromEnv ¶
NewClientFromEnv reads the API key from the COINGLASS_API_KEY environment variable and returns a new Coinglass client. Additional Option values can be passed to override timeouts, retries, etc.
func (*Client) WSClient ¶ added in v1.1.0
WSClient returns a new WebSocket client authenticated with the same API key as the HTTP client. The Coinglass WebSocket API is served from a dedicated host (wss://open-ws.coinglass.com/ws-api) independent of the REST base URL, so no base URL is inherited. Additional websocket.Option values can be passed to override the endpoint, handshake timeout, or ping interval.
type CoinMarket ¶
type CoinMarket struct {
Symbol string `json:"symbol"`
Price float64 `json:"price"`
PriceChange1h float64 `json:"priceChange1h"`
PriceChange24h float64 `json:"priceChange24h"`
VolumeUsd24h float64 `json:"volumeUsd24h"`
OpenInterestUsd float64 `json:"openInterestUsd"`
FundingRate float64 `json:"fundingRate"`
TurnoverNumber24h float64 `json:"turnoverNumber24h"`
}
CoinMarket represents a single futures coin market snapshot.
type CoinbasePremiumParams ¶
type CoinbasePremiumParams struct {
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
}
CoinbasePremiumParams holds optional parameters for CoinbasePremium.
type CoinsMarketsParams ¶
type CoinsMarketsParams struct {
Symbol *string `url:"symbol,omitempty"`
Exchanges []string `url:"exchanges,omitempty"`
Limit *int `url:"limit,omitempty"`
}
CoinsMarketsParams holds the optional parameters for CoinsMarkets.
type ETFFlowParams ¶
ETFFlowParams holds parameters for ETF flow history endpoints.
type ETFFlowPoint ¶
type ETFFlowPoint struct {
Timestamp int64 `json:"t"`
NetFlow float64 `json:"netFlow"`
TotalInflow float64 `json:"totalInflow"`
TotalOutflow float64 `json:"totalOutflow"`
}
ETFFlowPoint represents a single ETF flow history point.
type ETFItem ¶
type ETFItem struct {
Ticker string `json:"ticker"`
Name string `json:"name"`
Holdings float64 `json:"holdings"`
}
ETFItem represents a single ETF listing entry.
type ETFNetAssetsParams ¶
type ETFNetAssetsParams struct {
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
}
ETFNetAssetsParams holds parameters for BitcoinNetAssetsHistory.
type ETFNetAssetsPoint ¶
ETFNetAssetsPoint represents a single ETF net-assets history point.
type ETFService ¶
type ETFService struct {
// contains filtered or unexported fields
}
ETFService provides access to all Coinglass ETF endpoints.
func (*ETFService) BitcoinFlowHistory ¶
func (s *ETFService) BitcoinFlowHistory(ctx context.Context, params *ETFFlowParams) ([]ETFFlowPoint, error)
BitcoinFlowHistory returns Bitcoin ETF flow history.
func (*ETFService) BitcoinList ¶
func (s *ETFService) BitcoinList(ctx context.Context) ([]ETFItem, error)
BitcoinList returns the list of Bitcoin ETFs.
func (*ETFService) BitcoinNetAssetsHistory ¶
func (s *ETFService) BitcoinNetAssetsHistory(ctx context.Context, params *ETFNetAssetsParams) ([]ETFNetAssetsPoint, error)
BitcoinNetAssetsHistory returns Bitcoin ETF net assets history.
func (*ETFService) EthereumFlowHistory ¶
func (s *ETFService) EthereumFlowHistory(ctx context.Context, params *ETFFlowParams) ([]ETFFlowPoint, error)
EthereumFlowHistory returns Ethereum ETF flow history.
func (*ETFService) EthereumList ¶
func (s *ETFService) EthereumList(ctx context.Context) ([]ETFItem, error)
EthereumList returns the list of Ethereum ETFs.
func (*ETFService) GrayscaleHoldings ¶
func (s *ETFService) GrayscaleHoldings(ctx context.Context) ([]GrayscaleHolding, error)
GrayscaleHoldings returns the Grayscale holdings list.
type ExchangePair ¶
type ExchangePair struct {
Exchange string `json:"exchange"`
Symbol string `json:"symbol"`
Pair string `json:"pair"`
}
ExchangePair describes a single futures exchange + symbol pair.
type FearGreedParams ¶
type FearGreedParams struct {
Limit *int `url:"limit,omitempty"`
}
FearGreedParams holds optional parameters for FearGreedHistory.
type FearGreedPoint ¶
type FearGreedPoint struct {
Value int `json:"value"`
Classification string `json:"classification"`
Timestamp int64 `json:"t"`
}
FearGreedPoint represents a single Fear & Greed Index history point.
type FundingRateArbitrageParams ¶
type FundingRateArbitrageParams struct {
Symbol *string `url:"symbol,omitempty"`
Interval *string `url:"interval,omitempty"`
Limit *int `url:"limit,omitempty"`
}
FundingRateArbitrageParams holds optional parameters for FundingRateArbitrage.
type FundingRateExchange ¶
type FundingRateExchange struct {
Exchange string `json:"exchange"`
FundingRate float64 `json:"fundingRate"`
Timestamp int64 `json:"t"`
}
FundingRateExchange represents funding-rate data for a specific exchange.
type FundingRateExchangeListParams ¶
type FundingRateExchangeListParams struct {
Symbol string `url:"symbol"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
Exchange *string `url:"exchange,omitempty"`
}
FundingRateExchangeListParams holds parameters for FundingRateExchangeList.
type FundingRateHistoryParams ¶
type FundingRateHistoryParams struct {
Symbol string `url:"symbol"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
}
FundingRateHistoryParams holds parameters for FundingRateHistory.
type FundingRatePoint ¶
type FundingRatePoint struct {
FundingRate float64 `json:"fundingRate"`
FundingRateAnnualPercent float64 `json:"fundingRateAnnualPercent"`
Timestamp int64 `json:"t"`
}
FundingRatePoint represents a single funding-rate OHLC point.
type FuturesService ¶
type FuturesService struct {
// contains filtered or unexported fields
}
FuturesService provides access to all Coinglass futures endpoints.
func (*FuturesService) CoinsMarkets ¶
func (s *FuturesService) CoinsMarkets(ctx context.Context, params *CoinsMarketsParams) ([]CoinMarket, error)
CoinsMarkets returns futures coin markets.
func (*FuturesService) FundingRateArbitrage ¶
func (s *FuturesService) FundingRateArbitrage(ctx context.Context, params *FundingRateArbitrageParams) ([]ArbitrageItem, error)
FundingRateArbitrage returns funding-rate arbitrage opportunities.
func (*FuturesService) FundingRateExchangeList ¶
func (s *FuturesService) FundingRateExchangeList(ctx context.Context, params *FundingRateExchangeListParams) ([]FundingRateExchange, error)
FundingRateExchangeList returns funding-rate history grouped by exchange.
func (*FuturesService) FundingRateHistory ¶
func (s *FuturesService) FundingRateHistory(ctx context.Context, params *FundingRateHistoryParams) ([]FundingRatePoint, error)
FundingRateHistory returns funding-rate OHLC history.
func (*FuturesService) FundingRateOiWeighted ¶
func (s *FuturesService) FundingRateOiWeighted(ctx context.Context, params *FundingRateHistoryParams) ([]FundingRatePoint, error)
FundingRateOiWeighted returns OI-weighted funding-rate OHLC history.
func (*FuturesService) LargeOrders ¶
func (s *FuturesService) LargeOrders(ctx context.Context, params *LargeOrdersParams) ([]LargeOrder, error)
LargeOrders returns large limit orders from the orderbook.
func (*FuturesService) LiquidationAggregatedHistory ¶
func (s *FuturesService) LiquidationAggregatedHistory(ctx context.Context, params *LiquidationAggregatedHistoryParams) ([]LiquidationPoint, error)
LiquidationAggregatedHistory returns aggregated coin liquidation history.
func (*FuturesService) LiquidationCoinList ¶
func (s *FuturesService) LiquidationCoinList(ctx context.Context, params *LiquidationCoinListParams) ([]LiquidationCoin, error)
LiquidationCoinList returns the liquidation coin list.
func (*FuturesService) LiquidationHeatmap ¶
func (s *FuturesService) LiquidationHeatmap(ctx context.Context, model int, params *LiquidationHeatmapParams) (*LiquidationHeatmap, error)
LiquidationHeatmap returns a liquidation heatmap for the requested model (1, 2 or 3).
func (*FuturesService) LiquidationHistory ¶
func (s *FuturesService) LiquidationHistory(ctx context.Context, params *LiquidationHistoryParams) ([]LiquidationPoint, error)
LiquidationHistory returns pair liquidation history.
func (*FuturesService) LiquidationMap ¶
func (s *FuturesService) LiquidationMap(ctx context.Context, params *LiquidationMapParams) (*LiquidationMap, error)
LiquidationMap returns the liquidation map for a symbol/pair.
func (*FuturesService) LongShortRatioHistory ¶
func (s *FuturesService) LongShortRatioHistory(ctx context.Context, params *LongShortRatioParams) ([]LongShortPoint, error)
LongShortRatioHistory returns the global long/short account ratio history.
func (*FuturesService) OpenInterestAggregatedHistory ¶
func (s *FuturesService) OpenInterestAggregatedHistory(ctx context.Context, params *OIHistoryParams) ([]OIHistoryPoint, error)
OpenInterestAggregatedHistory returns aggregated OHLC open-interest history.
func (*FuturesService) OpenInterestExchangeList ¶
func (s *FuturesService) OpenInterestExchangeList(ctx context.Context, params *OIExchangeListParams) ([]OIExchangeItem, error)
OpenInterestExchangeList returns open-interest history grouped by exchange.
func (*FuturesService) OpenInterestHistory ¶
func (s *FuturesService) OpenInterestHistory(ctx context.Context, params *OIHistoryParams) ([]OIHistoryPoint, error)
OpenInterestHistory returns OHLC open-interest history for a symbol and interval.
func (*FuturesService) OrderbookHistory ¶
func (s *FuturesService) OrderbookHistory(ctx context.Context, params *OrderbookHistoryParams) ([]OrderbookPoint, error)
OrderbookHistory returns orderbook heatmap history.
func (*FuturesService) PairsMarkets ¶
func (s *FuturesService) PairsMarkets(ctx context.Context, params *PairsMarketsParams) ([]PairMarket, error)
PairsMarkets returns futures pair markets.
func (*FuturesService) PriceChangeList ¶
func (s *FuturesService) PriceChangeList(ctx context.Context) ([]PriceChangeItem, error)
PriceChangeList returns the futures price change list.
func (*FuturesService) SupportedCoins ¶
func (s *FuturesService) SupportedCoins(ctx context.Context) ([]string, error)
SupportedCoins returns the list of coins supported by Coinglass futures.
func (*FuturesService) SupportedExchangePairs ¶
func (s *FuturesService) SupportedExchangePairs(ctx context.Context, params *SupportedExchangePairsParams) (map[string][]ExchangePair, error)
SupportedExchangePairs returns the supported futures exchange pairs, optionally filtered by a single exchange.
func (*FuturesService) TakerBuySellHistory ¶
func (s *FuturesService) TakerBuySellHistory(ctx context.Context, params *TakerBuySellHistoryParams) ([]TakerBuySellPoint, error)
TakerBuySellHistory returns futures taker buy/sell volume history.
func (*FuturesService) TopLongShortRatioHistory ¶
func (s *FuturesService) TopLongShortRatioHistory(ctx context.Context, params *LongShortRatioParams) ([]LongShortPoint, error)
TopLongShortRatioHistory returns the top trader long/short account ratio history.
func (*FuturesService) WhaleAlert ¶
func (s *FuturesService) WhaleAlert(ctx context.Context, params *WhaleAlertParams) ([]WhaleAlert, error)
WhaleAlert returns the Hyperliquid whale alert feed.
type GrayscaleHolding ¶
type GrayscaleHolding struct {
Symbol string `json:"symbol"`
Asset string `json:"asset"`
Holdings float64 `json:"holdings"`
ValueUsd float64 `json:"valueUsd"`
}
GrayscaleHolding represents a single Grayscale holdings entry.
type IndicatorsService ¶
type IndicatorsService struct {
// contains filtered or unexported fields
}
IndicatorsService provides access to Coinglass market-indicator endpoints.
func (*IndicatorsService) BasisHistory ¶
func (s *IndicatorsService) BasisHistory(ctx context.Context, params *BasisHistoryParams) ([]BasisPoint, error)
BasisHistory returns the futures basis history.
func (*IndicatorsService) BitcoinRainbowChart ¶
func (s *IndicatorsService) BitcoinRainbowChart(ctx context.Context) (*RainbowChart, error)
BitcoinRainbowChart returns the Bitcoin rainbow chart data.
func (*IndicatorsService) CoinbasePremium ¶
func (s *IndicatorsService) CoinbasePremium(ctx context.Context, params *CoinbasePremiumParams) ([]PremiumPoint, error)
CoinbasePremium returns the Coinbase premium index history.
func (*IndicatorsService) FearGreedHistory ¶
func (s *IndicatorsService) FearGreedHistory(ctx context.Context, params *FearGreedParams) ([]FearGreedPoint, error)
FearGreedHistory returns the Fear & Greed Index history.
func (*IndicatorsService) RSIList ¶
func (s *IndicatorsService) RSIList(ctx context.Context, params *RSIListParams) ([]RSIItem, error)
RSIList returns the futures RSI list.
func (*IndicatorsService) StablecoinMarketCap ¶
func (s *IndicatorsService) StablecoinMarketCap(ctx context.Context, params *StablecoinMarketCapParams) ([]StablecoinPoint, error)
StablecoinMarketCap returns the stablecoin market-cap history.
func (*IndicatorsService) StockToFlow ¶
func (s *IndicatorsService) StockToFlow(ctx context.Context) (*StockToFlow, error)
StockToFlow returns the stock-to-flow model data.
type LargeOrder ¶
type LargeOrder struct {
Symbol string `json:"symbol"`
Exchange string `json:"exchange"`
Side string `json:"side"`
Price float64 `json:"price"`
Size float64 `json:"size"`
ValueUsd float64 `json:"valueUsd"`
Timestamp int64 `json:"t"`
}
LargeOrder represents a large limit order in the orderbook.
type LargeOrdersParams ¶
type LargeOrdersParams struct {
Symbol string `url:"symbol"`
Exchange string `url:"exchange"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
}
LargeOrdersParams holds parameters for LargeOrders.
type LiquidationAggregatedHistoryParams ¶
type LiquidationAggregatedHistoryParams struct {
Symbol string `url:"symbol"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
}
LiquidationAggregatedHistoryParams holds parameters for LiquidationAggregatedHistory.
type LiquidationCoin ¶
type LiquidationCoin struct {
Symbol string `json:"symbol"`
Exchange string `json:"exchange"`
LiquidationUsd float64 `json:"liquidationUsd"`
Timestamp int64 `json:"t"`
}
LiquidationCoin represents a liquidation coin list entry.
type LiquidationCoinListParams ¶
type LiquidationCoinListParams struct {
Symbol *string `url:"symbol,omitempty"`
Limit *int `url:"limit,omitempty"`
}
LiquidationCoinListParams holds optional parameters for LiquidationCoinList.
type LiquidationHeatmap ¶
type LiquidationHeatmap struct {
Model int `json:"model"`
Data []LiquidationHeatmapPoint `json:"data"`
Raw json.RawMessage `json:"-"`
}
LiquidationHeatmap is the modelled liquidation heatmap response.
type LiquidationHeatmapParams ¶
type LiquidationHeatmapParams struct {
Symbol string `url:"symbol"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
}
LiquidationHeatmapParams holds parameters for LiquidationHeatmap.
type LiquidationHeatmapPoint ¶
type LiquidationHeatmapPoint struct {
Price float64 `json:"price"`
LiquidationUsd float64 `json:"liquidationUsd"`
}
LiquidationHeatmapPoint is one bucket in a liquidation heatmap.
type LiquidationHistoryParams ¶
type LiquidationHistoryParams struct {
Symbol string `url:"symbol"`
Pair string `url:"pair"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
}
LiquidationHistoryParams holds parameters for LiquidationHistory.
type LiquidationMap ¶
type LiquidationMap struct {
Symbol string `json:"symbol"`
Data json.RawMessage `json:"data"`
Raw json.RawMessage `json:"-"`
}
LiquidationMap represents the liquidation map response.
type LiquidationMapParams ¶
type LiquidationMapParams struct {
Symbol string `url:"symbol"`
Pair string `url:"pair"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
}
LiquidationMapParams holds parameters for LiquidationMap.
type LiquidationPoint ¶
type LiquidationPoint struct {
BuyQty float64 `json:"buyQty"`
SellQty float64 `json:"sellQty"`
BuyAmount float64 `json:"buyAmount"`
SellAmount float64 `json:"sellAmount"`
Timestamp int64 `json:"t"`
}
LiquidationPoint represents a single liquidation history point.
type LongShortPoint ¶
type LongShortPoint struct {
LongAccount float64 `json:"longAccount"`
ShortAccount float64 `json:"shortAccount"`
LongRatio float64 `json:"longRatio"`
ShortRatio float64 `json:"shortRatio"`
Timestamp int64 `json:"t"`
}
LongShortPoint represents a single long/short account ratio point.
type LongShortRatioParams ¶
type LongShortRatioParams struct {
Symbol string `url:"symbol"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
Exchange *string `url:"exchange,omitempty"`
}
LongShortRatioParams holds parameters for long/short ratio history endpoints.
type OIExchangeItem ¶
type OIExchangeItem struct {
Exchange string `json:"exchange"`
OpenInterest float64 `json:"openInterest"`
OpenInterestUsd float64 `json:"openInterestUsd"`
Timestamp int64 `json:"t"`
}
OIExchangeItem represents open interest broken down by exchange.
type OIExchangeListParams ¶
type OIExchangeListParams struct {
Symbol string `url:"symbol"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
Exchange *string `url:"exchange,omitempty"`
}
OIExchangeListParams holds parameters for OpenInterestExchangeList.
type OIHistoryParams ¶
type OIHistoryParams struct {
Symbol string `url:"symbol"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
}
OIHistoryParams holds parameters for open-interest history endpoints.
type OIHistoryPoint ¶
type OIHistoryPoint struct {
OpenInterest float64 `json:"openInterest"`
OpenInterestUsd float64 `json:"openInterestUsd"`
Timestamp int64 `json:"t"`
}
OIHistoryPoint represents a single open interest OHLC point.
type Option ¶
type Option func(*Client)
Option configures a Client. Options are applied in the order they are passed to NewClient.
func WithBaseURL ¶
WithBaseURL overrides the default Coinglass API base URL (https://open-api-v4.coinglass.com). This is primarily useful for testing against a mock server.
func WithHTTPClient ¶
WithHTTPClient sets a custom *http.Client used to perform requests. This allows callers to configure transport-level behaviour such as proxies, TLS settings, or custom RoundTrippers.
func WithRetry ¶
WithRetry configures automatic retry behaviour for HTTP 429 (rate limited) responses. maxAttempts is the total number of attempts (including the first one) and baseDelay is the initial backoff delay used for exponential backoff (delay doubles on each subsequent retry unless a Retry-After header is present, in which case that value takes precedence).
func WithTimeout ¶
WithTimeout sets the timeout applied to the underlying HTTP client for every request made by the Client.
type OptionHistoryParams ¶
type OptionHistoryParams struct {
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
}
OptionHistoryParams holds parameters for options history endpoints.
type OptionInfo ¶
type OptionInfo struct {
Underlying string `json:"underlying"`
Expiry int64 `json:"expiry"`
Data json.RawMessage `json:"data"`
Raw json.RawMessage `json:"-"`
}
OptionInfo represents general options information for an underlying.
type OptionMaxPain ¶
type OptionMaxPain struct {
Underlying string `json:"underlying"`
Expiry int64 `json:"expiry"`
MaxPain float64 `json:"maxPain"`
Data json.RawMessage `json:"data"`
Raw json.RawMessage `json:"-"`
}
OptionMaxPain represents the max-pain analysis for an underlying asset.
type OptionOIPoint ¶
type OptionOIPoint struct {
Exchange string `json:"exchange"`
TotalOI float64 `json:"totalOI"`
Timestamp int64 `json:"t"`
}
OptionOIPoint represents a single exchange open-interest history point.
type OptionParams ¶
type OptionParams struct {
Underlying string `url:"underlying"`
Expiry *int64 `url:"expiry,omitempty"`
Interval *string `url:"interval,omitempty"`
}
OptionParams holds parameters for MaxPain and Info.
type OptionVolPoint ¶
type OptionVolPoint struct {
Exchange string `json:"exchange"`
TotalVol float64 `json:"totalVol"`
Timestamp int64 `json:"t"`
}
OptionVolPoint represents a single exchange volume history point.
type OptionsService ¶
type OptionsService struct {
// contains filtered or unexported fields
}
OptionsService provides access to all Coinglass options endpoints.
func (*OptionsService) ExchangeOIHistory ¶
func (s *OptionsService) ExchangeOIHistory(ctx context.Context, params *OptionHistoryParams) ([]OptionOIPoint, error)
ExchangeOIHistory returns options exchange open-interest history.
func (*OptionsService) ExchangeVolHistory ¶
func (s *OptionsService) ExchangeVolHistory(ctx context.Context, params *OptionHistoryParams) ([]OptionVolPoint, error)
ExchangeVolHistory returns options exchange volume history.
func (*OptionsService) Info ¶
func (s *OptionsService) Info(ctx context.Context, params *OptionParams) (*OptionInfo, error)
Info returns options information for the given underlying.
func (*OptionsService) MaxPain ¶
func (s *OptionsService) MaxPain(ctx context.Context, params *OptionParams) (*OptionMaxPain, error)
MaxPain returns the option max-pain analysis for the given underlying.
type OrderbookHistoryParams ¶
type OrderbookHistoryParams struct {
Symbol string `url:"symbol"`
Exchange string `url:"exchange"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
}
OrderbookHistoryParams holds parameters for OrderbookHistory.
type OrderbookPoint ¶
type OrderbookPoint struct {
Price float64 `json:"price"`
BidQty float64 `json:"bidQty"`
AskQty float64 `json:"askQty"`
BidAmount float64 `json:"bidAmount"`
AskAmount float64 `json:"askAmount"`
Timestamp int64 `json:"t"`
}
OrderbookPoint represents a single orderbook heatmap point.
type PairMarket ¶
type PairMarket struct {
Exchange string `json:"exchange"`
Symbol string `json:"symbol"`
Pair string `json:"pair"`
Price float64 `json:"price"`
PriceChange24h float64 `json:"priceChange24h"`
VolumeUsd24h float64 `json:"volumeUsd24h"`
OpenInterestUsd float64 `json:"openInterestUsd"`
}
PairMarket represents a single futures trading pair market snapshot.
type PairsMarketsParams ¶
type PairsMarketsParams struct {
Symbol *string `url:"symbol,omitempty"`
Exchange *string `url:"exchange,omitempty"`
Limit *int `url:"limit,omitempty"`
}
PairsMarketsParams holds the optional parameters for PairsMarkets.
type PremiumPoint ¶
PremiumPoint represents a single Coinbase premium index point.
type PriceChangeItem ¶
type PriceChangeItem struct {
Symbol string `json:"symbol"`
Change1h float64 `json:"change1h"`
Change24h float64 `json:"change24h"`
Change7d float64 `json:"change7d"`
}
PriceChangeItem represents a single entry in the price change list.
type PricePoint ¶
type PricePoint struct {
Open float64 `json:"open"`
High float64 `json:"high"`
Low float64 `json:"low"`
Close float64 `json:"close"`
Volume float64 `json:"volume"`
Timestamp int64 `json:"t"`
}
PricePoint represents a single OHLC price history point.
type RSIItem ¶
type RSIItem struct {
Symbol string `json:"symbol"`
Interval string `json:"interval"`
RSI float64 `json:"rsi"`
Timestamp int64 `json:"t"`
}
RSIItem represents a single RSI list entry.
type RSIListParams ¶
type RSIListParams struct {
Symbol *string `url:"symbol,omitempty"`
Interval *string `url:"interval,omitempty"`
Limit *int `url:"limit,omitempty"`
}
RSIListParams holds parameters for RSIList.
type RainbowChart ¶
type RainbowChart struct {
Data json.RawMessage `json:"data"`
Raw json.RawMessage `json:"-"`
}
RainbowChart represents the Bitcoin rainbow chart response.
type SpotCoinMarket ¶
type SpotCoinMarket struct {
Symbol string `json:"symbol"`
Price float64 `json:"price"`
PriceChange24h float64 `json:"priceChange24h"`
VolumeUsd24h float64 `json:"volumeUsd24h"`
}
SpotCoinMarket represents a single spot coin market snapshot.
type SpotCoinsMarketsParams ¶
type SpotCoinsMarketsParams struct {
Symbol *string `url:"symbol,omitempty"`
Exchange *string `url:"exchange,omitempty"`
Limit *int `url:"limit,omitempty"`
}
SpotCoinsMarketsParams holds optional parameters for CoinsMarkets.
type SpotOrderbookHistoryParams ¶
type SpotOrderbookHistoryParams struct {
Symbol string `url:"symbol"`
Exchange string `url:"exchange"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
}
SpotOrderbookHistoryParams holds parameters for Spot OrderbookHistory.
type SpotPairMarket ¶
type SpotPairMarket struct {
Exchange string `json:"exchange"`
Symbol string `json:"symbol"`
Pair string `json:"pair"`
Price float64 `json:"price"`
PriceChange24h float64 `json:"priceChange24h"`
VolumeUsd24h float64 `json:"volumeUsd24h"`
}
SpotPairMarket represents a single spot pair market snapshot.
type SpotPairsMarketsParams ¶
type SpotPairsMarketsParams struct {
Symbol *string `url:"symbol,omitempty"`
Exchange *string `url:"exchange,omitempty"`
Limit *int `url:"limit,omitempty"`
}
SpotPairsMarketsParams holds optional parameters for PairsMarkets.
type SpotPriceHistoryParams ¶
type SpotPriceHistoryParams struct {
Symbol string `url:"symbol"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
}
SpotPriceHistoryParams holds parameters for PriceHistory.
type SpotService ¶
type SpotService struct {
// contains filtered or unexported fields
}
SpotService provides access to all Coinglass spot market endpoints.
func (*SpotService) CoinsMarkets ¶
func (s *SpotService) CoinsMarkets(ctx context.Context, params *SpotCoinsMarketsParams) ([]SpotCoinMarket, error)
CoinsMarkets returns spot coin markets.
func (*SpotService) OrderbookHistory ¶
func (s *SpotService) OrderbookHistory(ctx context.Context, params *SpotOrderbookHistoryParams) ([]OrderbookPoint, error)
OrderbookHistory returns the spot orderbook heatmap history.
func (*SpotService) PairsMarkets ¶
func (s *SpotService) PairsMarkets(ctx context.Context, params *SpotPairsMarketsParams) ([]SpotPairMarket, error)
PairsMarkets returns spot pair markets.
func (*SpotService) PriceHistory ¶
func (s *SpotService) PriceHistory(ctx context.Context, params *SpotPriceHistoryParams) ([]PricePoint, error)
PriceHistory returns spot price OHLC history.
func (*SpotService) SupportedCoins ¶
func (s *SpotService) SupportedCoins(ctx context.Context) ([]string, error)
SupportedCoins returns the list of coins supported by Coinglass spot markets.
func (*SpotService) TakerBuySellHistory ¶
func (s *SpotService) TakerBuySellHistory(ctx context.Context, params *SpotTakerBuySellHistoryParams) ([]TakerBuySellPoint, error)
TakerBuySellHistory returns spot taker buy/sell volume history.
type SpotTakerBuySellHistoryParams ¶
type SpotTakerBuySellHistoryParams struct {
Symbol string `url:"symbol"`
Exchange string `url:"exchange"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
}
SpotTakerBuySellHistoryParams holds parameters for Spot TakerBuySellHistory.
type StablecoinMarketCapParams ¶
type StablecoinMarketCapParams struct {
Limit *int `url:"limit,omitempty"`
StartTime *int64 `url:"startTime,omitempty"`
EndTime *int64 `url:"endTime,omitempty"`
}
StablecoinMarketCapParams holds optional parameters for StablecoinMarketCap.
type StablecoinPoint ¶
StablecoinPoint represents a single stablecoin market-cap history point.
type StockToFlow ¶
type StockToFlow struct {
Data json.RawMessage `json:"data"`
Raw json.RawMessage `json:"-"`
}
StockToFlow represents the stock-to-flow model response.
type SupportedExchangePairsParams ¶
type SupportedExchangePairsParams struct {
Exchange *string `url:"exchange,omitempty"`
}
SupportedExchangePairsParams holds the optional parameters for SupportedExchangePairs.
type TakerBuySellHistoryParams ¶
type TakerBuySellHistoryParams struct {
Symbol string `url:"symbol"`
Exchange string `url:"exchange"`
Interval string `url:"interval"`
Limit *int `url:"limit,omitempty"`
}
TakerBuySellHistoryParams holds parameters for TakerBuySellHistory.
type TakerBuySellPoint ¶
type TakerBuySellPoint struct {
BuyVolume float64 `json:"buyVolume"`
SellVolume float64 `json:"sellVolume"`
Timestamp int64 `json:"t"`
}
TakerBuySellPoint represents a single taker buy/sell volume point.
type WhaleAlert ¶
type WhaleAlert struct {
Symbol string `json:"symbol"`
Side string `json:"side"`
Size float64 `json:"size"`
Price float64 `json:"price"`
Time int64 `json:"time"`
Link string `json:"link"`
}
WhaleAlert represents a Hyperliquid whale alert entry.
type WhaleAlertParams ¶
type WhaleAlertParams struct {
Symbol *string `url:"symbol,omitempty"`
Interval *string `url:"interval,omitempty"`
Limit *int `url:"limit,omitempty"`
}
WhaleAlertParams holds optional parameters for WhaleAlert.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
basic
command
Package main demonstrates basic usage of the coinglass-go SDK: client initialization, Futures/Spot/Options queries, and error handling.
|
Package main demonstrates basic usage of the coinglass-go SDK: client initialization, Futures/Spot/Options queries, and error handling. |
|
concurrency
command
Package main demonstrates that a coinglass-go Client is safe to share across goroutines, fetching open-interest history for multiple symbols concurrently.
|
Package main demonstrates that a coinglass-go Client is safe to share across goroutines, fetching open-interest history for multiple symbols concurrently. |
|
etf
command
Package main demonstrates ETF and market Indicators usage of the coinglass-go SDK: Bitcoin/Ethereum ETF flows, Grayscale holdings, the Fear & Greed Index, and the Bitcoin rainbow chart.
|
Package main demonstrates ETF and market Indicators usage of the coinglass-go SDK: Bitcoin/Ethereum ETF flows, Grayscale holdings, the Fear & Greed Index, and the Bitcoin rainbow chart. |
|
websocket
command
Package main demonstrates the coinglass-go WebSocket client: connecting, subscribing to the liquidation orders, spot trades, futures trades, and futures ticker channels, and decoding incoming messages.
|
Package main demonstrates the coinglass-go WebSocket client: connecting, subscribing to the liquidation orders, spot trades, futures trades, and futures ticker channels, and decoding incoming messages. |
|
Package websocket provides a client for the Coinglass real-time WebSocket API (https://docs.coinglass.com/reference/ws-getting-started).
|
Package websocket provides a client for the Coinglass real-time WebSocket API (https://docs.coinglass.com/reference/ws-getting-started). |
