goingecko

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 23 Imported by: 1

README

Goingecko

Coingecko API client for golang.

goingecko

Endpoints

Endpoint Status Function
/ping Ping
/simple/price SimplePrice
/simple/token_price/{id} SimpleTokenPrice
/simple/supported_vs_currencies SimpleSupportedVsCurrency
/coins/list CoinsList
/coins/markets CoinsMarket
/coins/{id} CoinsId
/coins/{id}/tickers CoinsIdTickers
/coins/{id}/history CoinsIdHistory
/coins/{id}/market_chart CoinsIdMarketChart
/coins/{id}/market_chart/range CoinsIdMarketChartRange
/coins/{id}/ohlc CoinsOhlc
/coins/{id}/contract/{contract_address} ContractInfo
/coins/{id}/contract/{contract_address}/market_chart/ ContractMarketChart
/coins/{id}/contract/{contract_address}/market_chart/range ContractMarketChartRange
/asset_platforms AssetPlatforms
/coins/categories/list CategoriesList
/coins/categories/ Categories
/exchanges Exchanges
/exchanges/list ExchangesList
/exchanges/{id} ExchangesId
/exchanges/{id}/tickers ExchangesIdTickers
/exchanges/{id}/volume_chart ExchangesIdVolumeChart
/derivaties Derivatives
/derivaties/exchanges DerivativesExchanges
/derivaties/exchanges/{id} DerivativesExchangesId
/derivaties/exchanges/list DerivativesExchangesList
/nfts/list NftsList
/nfts/{id} NftsId
/nfts/{asset_platform_id}/contract/{contract_address} NftsContract
/exchange_rates ExchangeRates
/search Search
/search/trending Trending
/global Global
/global/decentralized_finance_defi DecentrilizedFinanceDEFI
/companies/public_treasury/{coin_id} PublicTreasuryCoinId

Usage

package main

import (
	"fmt"

	"github.com/JulianToledano/goingecko"
)

func main() {
	cgClient := goingecko.NewClient(nil, "")
	defer cgClient.Close()

	data, err := cgClient.CoinsId("bitcoin", true, true, true, false, false, false)
	if err != nil {
		fmt.Print("Somethig went wrong...")
		return
	}
	fmt.Printf("Bitcoin price is: %f$", data.MarketData.CurrentPrice.Usd)
}

Check dir examples for more.

Thanks

This repo is based somehow in superoo7/go-gecko work.

Image was created with Gophers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpClient *http.Client, apiKey string) *Client

func (*Client) AssetPlatforms added in v0.3.0

func (c *Client) AssetPlatforms(filter string) (*assetPlatforms.AssetPlatforms, error)

func (*Client) Categories added in v0.3.0

func (c *Client) Categories(order string) (*categories.CategoriesWithMarketDataList, error)

Categories List all categories with market data Cache / Update Frequency: every 5 minutes Parameters: order: valid values: market_cap_desc (default), market_cap_asc, name_desc, name_asc, market_cap_change_24h_desc and market_cap_change_24h_asc

func (*Client) CategoriesList added in v0.3.0

func (c *Client) CategoriesList() (*categories.CategoriesList, error)

CategoriesList List all categories Cache / Update Frequency: every 5 minutes

func (*Client) Close

func (c *Client) Close()

func (*Client) CoinsId

func (c *Client) CoinsId(id string, localization, tickers, marketData, communityData, developerData, sparkline bool) (*coins.CoinID, error)

func (*Client) CoinsIdHistory

func (c *Client) CoinsIdHistory(id, date string, localization bool) (*coins.History, error)

func (*Client) CoinsIdMarketChart

func (c *Client) CoinsIdMarketChart(id, currency, days string) (*types.MarketChart, error)

func (*Client) CoinsIdMarketChartRange

func (c *Client) CoinsIdMarketChartRange(id, currency, from, to string) (*types.MarketChart, error)

func (*Client) CoinsIdTickers

func (c *Client) CoinsIdTickers(id, exchangeId, includeExchangeLogo, page, order, depth string) (*coins.Tickers, error)

func (*Client) CoinsList

func (c *Client) CoinsList() ([]*coins.CoinInfo, error)

func (*Client) CoinsMarket

func (c *Client) CoinsMarket(currency string, ids []string, category string, order string, perPage, page string, sparkline bool, priceChange []string) ([]*coins.Market, error)

func (*Client) CoinsOhlc

func (c *Client) CoinsOhlc(id, currency, days string) (*coins.Ohlc, error)

func (*Client) ContractInfo

func (c *Client) ContractInfo(id, contractAddress string) (*contract.ContractAddressInfo, error)

func (*Client) ContractMarketChart

func (c *Client) ContractMarketChart(id, contractAddress, vsCurrency, days string) (*types.MarketChart, error)

func (*Client) ContractMarketChartRange

func (c *Client) ContractMarketChartRange(id, contractAddress, vsCurrency, from, to string) (*types.MarketChart, error)

func (*Client) DecentrilizedFinanceDEFI

func (c *Client) DecentrilizedFinanceDEFI() (*global.Defi, error)

func (*Client) Derivatives added in v0.3.0

func (c *Client) Derivatives() ([]derivatives.Derivative, error)

Derivatives List all derivative tickers. Note: 'open_interest' and 'volume_24h' data are in USD Cache / Update Frequency: every 30 seconds

func (*Client) DerivativesExchanges added in v0.3.0

func (c *Client) DerivativesExchanges(order string, perPage, page int32) ([]derivatives.Exchange, error)

DerivativesExchanges List all derivative exchanges.

Cache / Update Frequency: every 60 seconds Parameters:

order(string) - order results using following params name_asc,name_desc,open_interest_btc_asc,
				open_interest_btc_desc,trade_volume_24h_btc_asc,trade_volume_24h_btc_desc

perPage(integer) - Total results per page page(integer) - Page through results

func (*Client) DerivativesExchangesId added in v0.3.0

func (c *Client) DerivativesExchangesId(id, includeTickers string) (*derivatives.ExchangeId, error)

DerivativesExchangesId show derivative exchange data

Dictionary:

last: latest unconverted price in the respective pair target currency
volume: unconverted 24h trading volume in the respective pair target currency
converted_last: latest converted price in BTC, ETH, and USD
converted_volume: converted 24h trading volume in BTC, ETH, and USD

Cache / Update Frequency: every 30 seconds Parameters:

id*(string) - pass the exchange id (can be obtained from derivatives/exchanges/list) eg. bitmex
includeTickers(string) - ['all', 'unexpired'] - expired to show unexpired tickers, all to list all tickers,
						 leave blank to omit tickers data in response

func (*Client) DerivativesExchangesList added in v0.3.0

func (c *Client) DerivativesExchangesList() ([]derivatives.DerivativesListItem, error)

DerivativesExchangesList List all derivative exchanges name and identifier.

Cache / Update Frequency: every 5 minutes

func (*Client) ExchangeRates

func (c *Client) ExchangeRates() (*exchangeRates.Rates, error)

func (*Client) Exchanges added in v0.3.0

func (c *Client) Exchanges(perPage, page string) (*exchanges.ExchangesList, error)

Exchanges List all exchanges Cache / Update Frequency: every 60 seconds Parameters per_page (string) Total results per page:

Valid values: 1...250
Total results per page
Default value:: 100

page (string) page through results

func (*Client) ExchangesId added in v0.3.0

func (c *Client) ExchangesId(id string) (*exchanges.ExchangeWithTicker, error)

ExchangesId Get exchange volume in BTC and tickers. For derivatives (e.g. bitmex, binance_futures), please use /derivatives/exchange/{id} endpoint.

IMPORTANT: Ticker object is limited to 100 items, to get more tickers, use /exchanges/{id}/tickers Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for more than 8 hours. Ticker is_anomaly is true if ticker's price is outliered by our system. You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide)

Dictionary:

last: latest unconverted price in the respective pair target currency volume: unconverted 24h trading volume in the respective pair target currency converted_last: latest converted price in BTC, ETH, and USD converted_volume: converted 24h trading volume in BTC, ETH, and USD timestamp: returns the last time that the price has changed last_traded_at: returns the last time that the price has changed last_fetch_at: returns the last time we call the API Cache / Update Frequency: every 60 seconds

func (*Client) ExchangesIdTickers added in v0.3.0

func (c *Client) ExchangesIdTickers(id, coinIds, includeExchangeLogo string, page int32, depth, order string) (*exchanges.Tickers, error)

ExchangesIdTickers Get exchange tickers (paginated) IMPORTANT: Ticker is_stale is true when ticker that has not been updated/unchanged from the exchange for more than 8 hours. Ticker is_anomaly is true if ticker's price is outliered by our system. You are responsible for managing how you want to display these information (e.g. footnote, different background, change opacity, hide)

Dictionary:

last: latest unconverted price in the respective pair target currency volume: unconverted 24h trading volume in the respective pair target currency converted_last: latest converted price in BTC, ETH, and USD converted_volume: converted 24h trading volume in BTC, ETH, and USD timestamp: returns the last time that the price has changed last_traded_at: returns the last time that the price has changed last_fetch_at: returns the last time we call the API Cache / Update Frequency: every 60 seconds Parameters:

id* - string - pass the exchange id (can be obtained from /exchanges/list) eg. binance
coinIds - string - filter tickers by coin_ids (ref: v3/coins/list)
includeExchangeLogo - string - flag to show exchange_logo. valid values: true, false
page - integer - Page through results
depth - string - lag to show 2% orderbook depth. i.e., cost_to_move_up_usd and cost_to_move_down_usd. valid values: true, false
order - string - valid values: trust_score_desc (default), trust_score_asc and volume_desc

func (*Client) ExchangesIdVolumeChart added in v0.3.0

func (c *Client) ExchangesIdVolumeChart(id, days string) ([]exchanges.Volume, error)

ExchangesIdVolumeChart Get 24 hour rolling trading volume data (in BTC) for a given exchange. Data granularity is automatic (cannot be adjusted)

1 day = 10-minutely
2-90 days = hourly
91 days above = daily

Note: exclusive endpoint is available for paid users to query more than 1 year of historical data

Cache / Update Frequency: every 60 seconds Parameters: id* - string - pass the exchange id (can be obtained from /exchanges/list) eg. binance days* - string - Data up to number of days ago (1/7/14/30/90/180/365)

func (*Client) ExchangesList added in v0.3.0

func (c *Client) ExchangesList() ([]exchanges.ExchangeId, error)

ExchangesList Use this to obtain all the markets' id in order to make API calls Cache / Update Frequency: every 5 minutes

func (*Client) Global

func (c *Client) Global() (*global.Global, error)

func (*Client) MakeReq

func (c *Client) MakeReq(url string) ([]byte, error)

MakeReq HTTP request helper

func (*Client) NftsContract added in v0.3.0

func (c *Client) NftsContract(assetPlatform, contract string) (*nfts.NftId, error)

NftsContract

func (*Client) NftsId added in v0.3.0

func (c *Client) NftsId(id string) (*nfts.NftId, error)

NftsId Get current data (name, price_floor, volume_24h ...) for an NFT collection. native_currency (string) is only a representative of the currency.

Cache / Update Frequency: every 60 seconds Parameters: id*(string) - id of nft collection (can be obtained from /nfts/list)

func (*Client) NftsList added in v0.3.0

func (c *Client) NftsList(order, assetPlatformId string, perPage, page int32) ([]nfts.Nft, error)

NftsList Use this to obtain all the NFT ids in order to make API calls, paginated to 100 items.

Cache / Update Frequency: every 5 minutes Parameters: order(string) - valid values: h24_volume_native_asc, h24_volume_native_desc, floor_price_native_asc, floor_price_native_desc, market_cap_native_asc, market_cap_native_desc, market_cap_usd_asc, market_cap_usd_desc assetPlatformId(string) - The id of the platform issuing tokens (See asset_platforms endpoint for list of options) per_page(integer) - Valid values: 1..250. Total results per page page(integer) - Page through results

func (*Client) Ping

func (c *Client) Ping() (*ping.Ping, error)

Ping /ping endpoint

func (*Client) PublicTreasuryCoinId added in v0.3.0

func (c *Client) PublicTreasuryCoinId(id string) (*companies.Treasury, error)

func (*Client) Search added in v0.3.0

func (c *Client) Search(query string) (*search.Search, error)

Search for coins, categories and markets listed on CoinGecko ordered by largest Market Cap first.

Cache / Update Frequency: every 15 minutes

func (*Client) SimplePrice

func (c *Client) SimplePrice(ids, vsCurrencies string, includeMarketCap, includeDayVolume, includeDayChange, includeLastTimeUpdated bool) (simple.Price, error)

func (*Client) SimpleSupportedVsCurrency

func (c *Client) SimpleSupportedVsCurrency() (*simple.SupportedVsCurrency, error)

func (*Client) SimpleTokenPrice

func (c *Client) SimpleTokenPrice(id, contractAddresses, vsCurrencies string, includeMarketCap, includeDayVolume, includeDayChange, includeLastTimeUpdated bool) (simple.TokenPrice, error)

func (*Client) Trending

func (c *Client) Trending() (*trending.Trending, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL