Documentation
¶
Overview ¶
Package birdeye is an idiomatic Go client for the Birdeye crypto market data API (https://public-api.birdeye.so), written from scratch against Birdeye's official documentation — not generated code.
Docs: https://docs.birdeye.so/reference/birdeye-api-getting-started
Index ¶
- Constants
- Variables
- type Client
- type ClientConfig
- type Clock
- type Logger
- type Option
- func WithBaseURL(url string) Option
- func WithChain(chain string) Option
- func WithClock(clock Clock) Option
- func WithHTTPClient(hc *http.Client) Option
- func WithLogger(logger Logger) Option
- func WithRetries(maxAttempts int) Option
- func WithRetryPolicy(policy *RetryPolicy) Option
- func WithTimeout(d time.Duration) Option
- type RetryPolicy
Constants ¶
const ( ChainSolana = "solana" ChainEthereum = "ethereum" ChainArbitrum = "arbitrum" ChainAvalanche = "avalanche" ChainBSC = "bsc" ChainOptimism = "optimism" ChainPolygon = "polygon" ChainBase = "base" ChainZkSync = "zksync" ChainMonad = "monad" ChainHyperEVM = "hyperevm" ChainAptos = "aptos" ChainFogo = "fogo" ChainMantle = "mantle" ChainMegaETH = "megaeth" ChainRobinhood = "robinhood" ChainSui = "sui" )
Chain values accepted by the x-chain header. This list is not exhaustive and not enforced client-side — different endpoint families support different chain subsets (confirmed via documentation research across only a handful of endpoints), so passing an unlisted chain string is never blocked locally; let Birdeye's API be the source of truth and return an error for an unsupported chain.
Docs: https://docs.birdeye.so/reference/birdeye-api-authentication
const DefaultBaseURL = "https://public-api.birdeye.so"
DefaultBaseURL is Birdeye's production REST host.
Variables ¶
var ( // NewDefaultRetryPolicy creates the SDK's conservative default retry policy. NewDefaultRetryPolicy = transport.NewDefaultRetryPolicy // NoRetry creates a retry policy that makes one attempt only. NoRetry = transport.NoRetry )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Price groups every implemented price/OHLCV endpoint.
//
// Docs: https://docs.birdeye.so/reference/price-ohlcv
Price *price.Client
// contains filtered or unexported fields
}
Client is the SDK entry point. Construct with NewClient.
func NewClient ¶
NewClient builds a fully wired Client. apiKey is required — Birdeye rejects every endpoint without an X-API-KEY header. Performs no network I/O.
Docs: https://docs.birdeye.so/reference/birdeye-api-authentication
func (*Client) Do ¶
func (c *Client) Do(ctx context.Context, method, path string, query map[string]string, chain string, body interface{}, result interface{}) (*transport.ResponseMeta, error)
Do is the raw request escape hatch: call any Birdeye endpoint — including ones this SDK hasn't mapped to a typed method yet — without waiting for an SDK update. method/path/query/body follow the same conventions as every typed service method; chain overrides the client's default x-chain header for this call only ("" to use the default). result is decoded from the response envelope's "data" field (nil to discard it).
func (*Client) DoWithHeaders ¶
func (c *Client) DoWithHeaders(ctx context.Context, method, path string, query map[string]string, chain string, headers http.Header, body interface{}, result interface{}) (*transport.ResponseMeta, error)
DoWithHeaders is the raw escape hatch for endpoints that require an endpoint-specific header, such as x-perp. X-API-KEY is always taken from the client configuration and cannot be overridden here.
type ClientConfig ¶
type ClientConfig struct {
APIKey string
BaseURL string
DefaultChain string
HTTPClient *http.Client
Timeout time.Duration
Clock Clock
Logger Logger
RetryPolicy *RetryPolicy
}
ClientConfig holds every configurable knob of a Client. Zero value is unusable — an APIKey is always required; NewClient fills in defaults for every other unset field.
type Option ¶
type Option func(*ClientConfig)
Option configures a ClientConfig at construction time.
func WithBaseURL ¶
WithBaseURL overrides the REST host. Defaults to DefaultBaseURL.
func WithChain ¶
WithChain sets the default x-chain header sent on every request that doesn't override it per-call via a method's Options.Chain field. Leaving this unset is valid — Birdeye defaults to "solana" server-side when the header is omitted entirely.
func WithClock ¶
WithClock injects a clock used by retry timing. It is mainly useful for deterministic tests.
func WithHTTPClient ¶
WithHTTPClient uses hc to make API requests. Its timeout and transport are preserved, so WithTimeout has no effect when this option is used.
func WithLogger ¶
WithLogger sets the structured logger used by the client. The default logger discards all messages.
func WithRetries ¶
WithRetries changes only the maximum number of attempts while retaining the default backoff bounds. Values below one disable retries. GET requests alone are eligible; unsafe methods are never retried automatically.
func WithRetryPolicy ¶
func WithRetryPolicy(policy *RetryPolicy) Option
WithRetryPolicy overrides the default conservative retry policy (GET requests only; see transport.RetryPolicy). Pass NoRetry() to disable automatic retries entirely.
func WithTimeout ¶
WithTimeout sets the timeout of the SDK-created HTTP client. Use WithHTTPClient to configure a custom client directly.
type RetryPolicy ¶
type RetryPolicy = transport.RetryPolicy
RetryPolicy configures automatic retry behaviour for eligible requests.
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
error_handling
command
Example: handle a Birdeye API error gracefully using the typed error hierarchy (sentinel errors + *transport.BirdeyeError for detail).
|
Example: handle a Birdeye API error gracefully using the typed error hierarchy (sentinel errors + *transport.BirdeyeError for detail). |
|
get_ohlcv
command
Example: fetch v3 OHLCV candles for a token.
|
Example: fetch v3 OHLCV candles for a token. |
|
get_price
command
Example: fetch a single token's real-time price.
|
Example: fetch a single token's real-time price. |
|
multi_price
command
Example: fetch prices for multiple tokens in one call.
|
Example: fetch prices for multiple tokens in one call. |
|
token_search
command
token_search calls the current search endpoint through the raw API.
|
token_search calls the current search endpoint through the raw API. |
|
wallet_pnl
command
wallet_pnl demonstrates the raw request escape hatch for an endpoint that has not yet received a typed service.
|
wallet_pnl demonstrates the raw request escape hatch for an endpoint that has not yet received a typed service. |
|
Package price implements Birdeye's price and OHLCV endpoints: single and multi-token real-time price, v3 OHLCV candles (token and pair), and historical price lookup by Unix timestamp.
|
Package price implements Birdeye's price and OHLCV endpoints: single and multi-token real-time price, v3 OHLCV candles (token and pair), and historical price lookup by Unix timestamp. |
|
Package transport implements the shared HTTP request executor, response metadata capture, and error hierarchy used by every Birdeye service.
|
Package transport implements the shared HTTP request executor, response metadata capture, and error hierarchy used by every Birdeye service. |
