Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.48 KB

README.md

File metadata and controls

51 lines (38 loc) · 1.48 KB

coincap-go

CoinCap.io REST API wrapper written with Go. For docs checkout: https://docs.coincap.io/

Installation

go get -u github.com/softronaut/coincap-go

Usage

// Instance
client := coincap.DefaultClient() // uses http.DefaultClient
// Customization
retry := retryablehttp.NewClient() // or you can use a customized http.Client
retry.RetryMax = 3
retry.RetryWaitMax = time.Second * 5
client := coincap.CustomClient(retry.StandardClient())

// API interface
GetAssets(GetAssetsParams) (AssetsData, error)
GetAsset(id string) (AssetData, error)
GetAssetHistory(GetAssetHistoryParams) (AssetHistoriesData, error)
GetAssetMarkets(GetAssetMarketsParams) (AssetMarketsData, error)
GetRates() (RatesData, error)
GetRate(id string) (RateData, error)
GetExchanges() (ExchangesData, error)
GetExchange(id string) (ExchangeData, error)
GetMarkets(GetMarketsParams) (MarketsData, error)
GetCandles(GetCandlesParams) (CandlesData, error)

// Examples
assets, err := client.GetAssets(GetAssetsParams{Ids: []string{"bitcoin", "ethereum"}})
polkadot, err := client.GetAsset("polkadot")
linkUsdc, err := client.GetMarkets(GetMarketsParams{ExchangeId: "binance", BaseSymbol: "link", QuoteId: "usd-coin"})

Notes

Each response and parameter declared as struct.

Some parameter logics implemented (required parameters, api limits or start/end timestamp relations etc.).

gzip encoding enabled by default.

ToDo

  • WebSocket support
  • Extensive error handling