├── backlog.md ├── coins ├── ohlc.go ├── list.go ├── tickers.go ├── history.go ├── statusUpdates.go ├── id.go └── markets.go ├── images └── goin.png ├── simple ├── supportedVsCurrency.go ├── price.go └── tokenPrice.go ├── go.mod ├── ping └── ping.go ├── types ├── marketChart.go └── types.go ├── assetPlatforms └── assetPlatforms.go ├── test ├── search_test.go ├── trending_test.go ├── exchangeRates_test.go ├── companies_test.go ├── goingecko_test.go ├── assetPlatforms_test.go ├── global_test.go ├── categories_test.go ├── simple_test.go ├── nfts_test.go ├── derivatives_test.go ├── contract_test.go ├── exchanges_test.go └── coins_test.go ├── search └── search.go ├── trending.go ├── examples ├── bitcoinPrice.go ├── pro.go └── checkTrending.go ├── trending └── trending.go ├── exchangeRates.go ├── global ├── defi.go └── global.go ├── companies.go ├── .gitignore ├── assetPlatforms.go ├── categories └── categories.go ├── companies └── companies.go ├── search.go ├── global.go ├── LICENSE ├── categories.go ├── endpoints.go ├── contract.go ├── client.go ├── exchangeRates └── exchangeRates.go ├── simple.go ├── nfts.go ├── derivatives └── derivatives.go ├── nfts └── nfts.go ├── derivatives.go ├── exchanges └── exchanges.go ├── contract └── contractAddress.go ├── README.md ├── coins.go └── exchanges.go /backlog.md: -------------------------------------------------------------------------------- 1 | # Backlog 2 | -------------------------------------------------------------------------------- /coins/ohlc.go: -------------------------------------------------------------------------------- 1 | package coins 2 | 3 | type Ohlc [][]float64 4 | -------------------------------------------------------------------------------- /images/goin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hey/goingecko/main/images/goin.png -------------------------------------------------------------------------------- /simple/supportedVsCurrency.go: -------------------------------------------------------------------------------- 1 | package simple 2 | 3 | type SupportedVsCurrency []string 4 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/JulianToledano/goingecko 2 | 3 | go 1.21 4 | 5 | toolchain go1.21.0 6 | -------------------------------------------------------------------------------- /ping/ping.go: -------------------------------------------------------------------------------- 1 | package ping 2 | 3 | type Ping struct { 4 | GeckoSays string `json:"gecko_says"` 5 | } 6 | -------------------------------------------------------------------------------- /simple/price.go: -------------------------------------------------------------------------------- 1 | package simple 2 | 3 | type Price map[string]PriceValues 4 | type PriceValues map[string]float64 5 | -------------------------------------------------------------------------------- /simple/tokenPrice.go: -------------------------------------------------------------------------------- 1 | package simple 2 | 3 | type TokenPrice map[string]TokenValues 4 | type TokenValues map[string]float64 5 | -------------------------------------------------------------------------------- /coins/list.go: -------------------------------------------------------------------------------- 1 | package coins 2 | 3 | type CoinInfo struct { 4 | ID string `json:"id"` 5 | Symbol string `json:"symbol"` 6 | Name string `json:"name"` 7 | } 8 | -------------------------------------------------------------------------------- /coins/tickers.go: -------------------------------------------------------------------------------- 1 | package coins 2 | 3 | import "github.com/JulianToledano/goingecko/types" 4 | 5 | type Tickers struct { 6 | Name string `json:"name"` 7 | Tickers []types.Ticker `json:"tickers"` 8 | } 9 | -------------------------------------------------------------------------------- /types/marketChart.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | type MarketChart struct { 4 | Prices [][]float64 `json:"prices"` 5 | MarketCaps [][]float64 `json:"market_caps"` 6 | TotalVolumes [][]float64 `json:"total_volumes"` 7 | } 8 | -------------------------------------------------------------------------------- /assetPlatforms/assetPlatforms.go: -------------------------------------------------------------------------------- 1 | package assetPlatforms 2 | 3 | type AssetPlatforms []Asset 4 | 5 | type Asset struct { 6 | ID string `json:"id"` 7 | ChainIdentifier int64 `json:"chain_identifier"` 8 | Name string `json:"name"` 9 | ShortName string `json:"shortName"` 10 | NativeCoinId string `json:"native_coin_id"` 11 | } 12 | -------------------------------------------------------------------------------- /test/search_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "github.com/JulianToledano/goingecko" 5 | "testing" 6 | ) 7 | 8 | func TestSearch(t *testing.T) { 9 | cgClient := goingecko.NewClient(nil, "") 10 | data, err := cgClient.Search("bitcoin") 11 | if data == nil { 12 | t.Errorf("Error") 13 | } 14 | if err != nil { 15 | t.Errorf("Error: %s", err) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/trending_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/JulianToledano/goingecko" 7 | ) 8 | 9 | func TestTrending(t *testing.T) { 10 | 11 | cgClient := goingecko.NewClient(nil, "") 12 | 13 | r, err := cgClient.Trending() 14 | if r == nil { 15 | t.Errorf("Error") 16 | } 17 | if err != nil { 18 | t.Errorf("Error: %s", err) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/exchangeRates_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/JulianToledano/goingecko" 7 | ) 8 | 9 | func TestExchangeRates(t *testing.T) { 10 | 11 | cgClient := goingecko.NewClient(nil, "") 12 | 13 | r, err := cgClient.ExchangeRates() 14 | if r == nil { 15 | t.Errorf("Error") 16 | } 17 | if err != nil { 18 | t.Errorf("Error: %s", err) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/companies_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "github.com/JulianToledano/goingecko" 5 | "testing" 6 | ) 7 | 8 | func TestPublicTreasuryCoinId(t *testing.T) { 9 | cgClient := goingecko.NewClient(nil, "") 10 | data, err := cgClient.PublicTreasuryCoinId("bitcoin") 11 | if data == nil { 12 | t.Errorf("Error") 13 | } 14 | if err != nil { 15 | t.Errorf("Error: %s", err) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/goingecko_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/JulianToledano/goingecko" 8 | ) 9 | 10 | func TestCoins(t *testing.T) { 11 | coin := "bitcoin" 12 | 13 | cgClient := goingecko.NewClient(nil, "") 14 | 15 | coinData, _ := cgClient.CoinsId(coin, true, true, true, true, true, true) 16 | fmt.Println(coinData.MarketData.CurrentPrice.Usd) 17 | 18 | } 19 | -------------------------------------------------------------------------------- /test/assetPlatforms_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "github.com/JulianToledano/goingecko" 5 | "testing" 6 | ) 7 | 8 | func TestAssetPlatforms(t *testing.T) { 9 | 10 | cgClient := goingecko.NewClient(nil, "") 11 | 12 | assetData, err := cgClient.AssetPlatforms("") 13 | if assetData == nil { 14 | t.Errorf("Error") 15 | } 16 | if err != nil { 17 | t.Errorf("Error: %s", err) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /search/search.go: -------------------------------------------------------------------------------- 1 | package search 2 | 3 | type Search struct { 4 | Coins []Item `json:"coins"` 5 | } 6 | 7 | type Item struct { 8 | ID string `json:"id"` 9 | Name string `json:"name"` 10 | ApiSymbol string `json:"api_symbol"` 11 | Symbol string `json:"symbol"` 12 | MarketCapRank int64 `json:"market_cap_rank"` 13 | Thumb string `json:"thumb"` 14 | Large string `json:"large"` 15 | } 16 | -------------------------------------------------------------------------------- /trending.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/JulianToledano/goingecko/trending" 7 | ) 8 | 9 | func (c *Client) Trending() (*trending.Trending, error) { 10 | resp, err := c.MakeReq(c.getTrendingURL()) 11 | if err != nil { 12 | return nil, err 13 | } 14 | 15 | var data *trending.Trending 16 | err = json.Unmarshal([]byte(resp), &data) 17 | if err != nil { 18 | return nil, err 19 | } 20 | return data, nil 21 | } 22 | -------------------------------------------------------------------------------- /examples/bitcoinPrice.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/JulianToledano/goingecko" 7 | ) 8 | 9 | func main() { 10 | cgClient := goingecko.NewClient(nil, "") 11 | defer cgClient.Close() 12 | 13 | data, err := cgClient.CoinsId("bitcoin", true, true, true, false, false, false) 14 | if err != nil { 15 | fmt.Print("Somethig went wrong...") 16 | return 17 | } 18 | fmt.Printf("Bitcoin price is: %f$", data.MarketData.CurrentPrice.Usd) 19 | } 20 | -------------------------------------------------------------------------------- /examples/pro.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/JulianToledano/goingecko" 7 | ) 8 | 9 | func main() { 10 | cgClient := goingecko.NewClient(nil, "pro api key", true) 11 | defer cgClient.Close() 12 | 13 | data, err := cgClient.CoinsId("bitcoin", true, true, true, false, false, false) 14 | if err != nil { 15 | fmt.Print("Somethig went wrong...") 16 | return 17 | } 18 | fmt.Printf("Bitcoin price is: %f$", data.MarketData.CurrentPrice.Usd) 19 | } 20 | -------------------------------------------------------------------------------- /trending/trending.go: -------------------------------------------------------------------------------- 1 | package trending 2 | 3 | type Trending struct { 4 | Coins []coin `json:"coins"` 5 | } 6 | 7 | type coin struct { 8 | Item item `json:"item"` 9 | } 10 | 11 | type item struct { 12 | ID string `json:"id"` 13 | Name string `json:"name"` 14 | Symbol string `json:"symbol"` 15 | MarketCapRank int32 `json:"market_cap_rank"` 16 | Thumb string `json:"thumb"` 17 | Large string `json:"large"` 18 | Score float64 `json:"score"` 19 | } 20 | -------------------------------------------------------------------------------- /exchangeRates.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/JulianToledano/goingecko/exchangeRates" 8 | ) 9 | 10 | func (c *Client) ExchangeRates() (*exchangeRates.Rates, error) { 11 | rUrl := fmt.Sprintf("%s", c.getExchangeRatesURL()) 12 | resp, err := c.MakeReq(rUrl) 13 | if err != nil { 14 | return nil, err 15 | } 16 | 17 | var data *exchangeRates.Rates 18 | err = json.Unmarshal([]byte(resp), &data) 19 | if err != nil { 20 | return nil, err 21 | } 22 | return data, nil 23 | } 24 | -------------------------------------------------------------------------------- /global/defi.go: -------------------------------------------------------------------------------- 1 | package global 2 | 3 | type Defi struct { 4 | Data defiInfo `json:"data"` 5 | } 6 | 7 | type defiInfo struct { 8 | DefiMarketCap string `json:"defi_market_cap"` 9 | EthMarketCap string `json:"eth_market_cap"` 10 | DefiToEthRatio string `json:"defi_to_eth_ratio"` 11 | TradingVolume24h string `json:"trading_volume_24h"` 12 | Defi_dominance string `json:"defi_dominance"` 13 | TopCoinName string `json:"top_coin_name"` 14 | TopCoinDefiDominance float64 `json:"top_coin_defi_dominance"` 15 | } 16 | -------------------------------------------------------------------------------- /companies.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/JulianToledano/goingecko/companies" 8 | ) 9 | 10 | func (c *Client) PublicTreasuryCoinId(id string) (*companies.Treasury, error) { 11 | rUrl := fmt.Sprintf("%s/public_treasury/%s", c.getCompaniesURL(), id) 12 | resp, err := c.MakeReq(rUrl) 13 | if err != nil { 14 | return nil, err 15 | } 16 | 17 | var data *companies.Treasury 18 | err = json.Unmarshal([]byte(resp), &data) 19 | if err != nil { 20 | return nil, err 21 | } 22 | return data, nil 23 | } 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Go ### 2 | # Binaries for programs and plugins 3 | *.exe 4 | *.exe~ 5 | *.dll 6 | *.so 7 | *.dylib 8 | 9 | # Test binary, built with `go test -c` 10 | *.test 11 | 12 | # Output of the go coverage tool, specifically when used with LiteIDE 13 | *.out 14 | 15 | # Dependency directories (remove the comment below to include it) 16 | # vendor/ 17 | 18 | ### Go Patch ### 19 | /vendor/ 20 | /Godeps/ 21 | 22 | ### vscode ### 23 | .vscode/* 24 | !.vscode/settings.json 25 | !.vscode/tasks.json 26 | !.vscode/launch.json 27 | !.vscode/extensions.json 28 | *.code-workspace 29 | 30 | .idea -------------------------------------------------------------------------------- /test/global_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/JulianToledano/goingecko" 7 | ) 8 | 9 | func TestGlobal(t *testing.T) { 10 | 11 | cgClient := goingecko.NewClient(nil, "") 12 | 13 | r, err := cgClient.Global() 14 | if r == nil { 15 | t.Errorf("Error") 16 | } 17 | if err != nil { 18 | t.Errorf("Error: %s", err) 19 | } 20 | } 21 | 22 | func TestDefi(t *testing.T) { 23 | 24 | cgClient := goingecko.NewClient(nil, "") 25 | 26 | r, err := cgClient.DecentrilizedFinanceDEFI() 27 | if r == nil { 28 | t.Errorf("Error") 29 | } 30 | if err != nil { 31 | t.Errorf("Error: %s", err) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /examples/checkTrending.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/JulianToledano/goingecko" 7 | ) 8 | 9 | func main() { 10 | cgClient := goingecko.NewClient(nil, "") 11 | defer cgClient.Close() 12 | 13 | treding, err := cgClient.Trending() 14 | if err != nil { 15 | fmt.Print("Something went wrong...") 16 | return 17 | } 18 | for _, coin := range treding.Coins { 19 | coinData, err := cgClient.CoinsId(coin.Item.ID, false, false, true, false, false, false) 20 | if err != nil { 21 | fmt.Printf("Error: %v", err) 22 | } 23 | fmt.Printf("Name: %s | Symbol: %s | Price: %f\n", coin.Item.Name, coin.Item.Symbol, coinData.MarketData.CurrentPrice.Usd) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /assetPlatforms.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | 8 | "github.com/JulianToledano/goingecko/assetPlatforms" 9 | ) 10 | 11 | func (c *Client) AssetPlatforms(filter string) (*assetPlatforms.AssetPlatforms, error) { 12 | params := url.Values{} 13 | 14 | if filter != "" { 15 | params.Add("filter", filter) 16 | } 17 | 18 | rUrl := fmt.Sprintf("%s?%s", c.getAssetPlatformsURL(), params.Encode()) 19 | resp, err := c.MakeReq(rUrl) 20 | if err != nil { 21 | return nil, err 22 | } 23 | var data *assetPlatforms.AssetPlatforms 24 | err = json.Unmarshal(resp, &data) 25 | if err != nil { 26 | return nil, err 27 | } 28 | return data, nil 29 | } 30 | -------------------------------------------------------------------------------- /test/categories_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "github.com/JulianToledano/goingecko" 5 | "testing" 6 | ) 7 | 8 | func TestCategoriesList(t *testing.T) { 9 | 10 | cgClient := goingecko.NewClient(nil, "") 11 | 12 | categoriesList, err := cgClient.CategoriesList() 13 | if categoriesList == nil { 14 | t.Errorf("Error") 15 | } 16 | if err != nil { 17 | t.Errorf("Error: %s", err) 18 | } 19 | } 20 | 21 | func TestCategories(t *testing.T) { 22 | 23 | cgClient := goingecko.NewClient(nil, "") 24 | 25 | categoriesList, err := cgClient.Categories("market_cap_desc") 26 | if categoriesList == nil { 27 | t.Errorf("Error") 28 | } 29 | if err != nil { 30 | t.Errorf("Error: %s", err) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /categories/categories.go: -------------------------------------------------------------------------------- 1 | package categories 2 | 3 | type CategoriesList []Category 4 | 5 | type Category struct { 6 | CategoryId string `json:"category_id"` 7 | Name string `json:"name"` 8 | } 9 | 10 | type CategoriesWithMarketDataList []CategoryWithMarketData 11 | 12 | type CategoryWithMarketData struct { 13 | ID string `json:"id"` 14 | Name string `json:"name"` 15 | MarketCap float64 `json:"market_cap"` 16 | MarketCapChange24h float64 `json:"market_cap_change_24h"` 17 | Content string `json:"content"` 18 | Top3Coins []string `json:"top_3_coins"` 19 | Volume24h float64 `json:"volume_24h"` 20 | UpdatedAt string `json:"updated_at"` 21 | } 22 | -------------------------------------------------------------------------------- /companies/companies.go: -------------------------------------------------------------------------------- 1 | package companies 2 | 3 | type Treasury struct { 4 | TotalHoldings float64 `json:"total_holdings"` 5 | TotalValueUsd float64 `json:"total_value_usd"` 6 | MarketCapDominance float64 `json:"market_cap_dominance"` 7 | Companies []Companies `json:"companies"` 8 | } 9 | 10 | type Companies struct { 11 | Name string `json:"name"` 12 | Symbol string `json:"symbol"` 13 | Country string `json:"country"` 14 | TotalHoldings int64 `json:"total_holdings"` 15 | TotalEntryValueUsd int64 `json:"total_entry_value_usd"` 16 | TotalCurrentValueUsd int64 `json:"total_current_value_usd"` 17 | PercentageOfTotalSupply float64 `json:"percentage_of_total_supply"` 18 | } 19 | -------------------------------------------------------------------------------- /search.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | 8 | "github.com/JulianToledano/goingecko/search" 9 | ) 10 | 11 | // Search for coins, categories and markets listed on CoinGecko ordered by largest Market Cap first. 12 | // 13 | // Cache / Update Frequency: every 15 minutes 14 | func (c *Client) Search(query string) (*search.Search, error) { 15 | params := url.Values{} 16 | if query != "" { 17 | params.Add("query", query) 18 | } 19 | 20 | rUrl := fmt.Sprintf("%s?%s", c.getSearchURL(), params.Encode()) 21 | resp, err := c.MakeReq(rUrl) 22 | if err != nil { 23 | return nil, err 24 | } 25 | 26 | var data *search.Search 27 | err = json.Unmarshal(resp, &data) 28 | if err != nil { 29 | return nil, err 30 | } 31 | 32 | return data, nil 33 | } 34 | -------------------------------------------------------------------------------- /global.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/JulianToledano/goingecko/global" 8 | ) 9 | 10 | func (c *Client) Global() (*global.Global, error) { 11 | resp, err := c.MakeReq(c.getGlobalURL()) 12 | if err != nil { 13 | return nil, err 14 | } 15 | 16 | var data *global.Global 17 | err = json.Unmarshal([]byte(resp), &data) 18 | if err != nil { 19 | return nil, err 20 | } 21 | return data, nil 22 | } 23 | 24 | func (c *Client) DecentrilizedFinanceDEFI() (*global.Defi, error) { 25 | rUrl := fmt.Sprintf("%s/decentralized_finance_defi", c.getGlobalURL()) 26 | resp, err := c.MakeReq(rUrl) 27 | if err != nil { 28 | return nil, err 29 | } 30 | 31 | var data *global.Defi 32 | err = json.Unmarshal([]byte(resp), &data) 33 | if err != nil { 34 | return nil, err 35 | } 36 | return data, nil 37 | } 38 | -------------------------------------------------------------------------------- /test/simple_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/JulianToledano/goingecko" 7 | ) 8 | 9 | func TestSimplePrice(t *testing.T) { 10 | cgClient := goingecko.NewClient(nil, "") 11 | 12 | r, _ := cgClient.SimplePrice("bitcoin,ethereum", "btc,eth", true, true, true, true) 13 | if r == nil { 14 | t.Errorf("Error") 15 | } 16 | 17 | } 18 | 19 | func TestSimpleTokenPrice(t *testing.T) { 20 | cgClient := goingecko.NewClient(nil, "") 21 | 22 | r, _ := cgClient.SimpleTokenPrice("ethereum", "0x0D8775F648430679A709E98d2b0Cb6250d2887EF", "btc,eth", true, true, true, true) 23 | if r == nil { 24 | t.Errorf("Error") 25 | } 26 | 27 | } 28 | 29 | func TestSimpleSupportedVsCurrency(t *testing.T) { 30 | cgClient := goingecko.NewClient(nil, "") 31 | 32 | supVcurr, _ := cgClient.SimpleSupportedVsCurrency() 33 | if supVcurr == nil { 34 | t.Errorf("Error") 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /test/nfts_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "github.com/JulianToledano/goingecko" 5 | "testing" 6 | ) 7 | 8 | func TestNftsList(t *testing.T) { 9 | cgClient := goingecko.NewClient(nil, "") 10 | data, err := cgClient.NftsList("", "", 0, 0) 11 | if data == nil { 12 | t.Errorf("Error") 13 | } 14 | if err != nil { 15 | t.Errorf("Error: %s", err) 16 | } 17 | } 18 | 19 | func TestNftsId(t *testing.T) { 20 | cgClient := goingecko.NewClient(nil, "") 21 | data, err := cgClient.NftsId("squiggly") 22 | if data == nil { 23 | t.Errorf("Error") 24 | } 25 | if err != nil { 26 | t.Errorf("Error: %s", err) 27 | } 28 | } 29 | 30 | func TestNftsContract(t *testing.T) { 31 | cgClient := goingecko.NewClient(nil, "") 32 | data, err := cgClient.NftsContract("ethereum", "0x36F379400DE6c6BCDF4408B282F8b685c56adc60") 33 | if data == nil { 34 | t.Errorf("Error") 35 | } 36 | if err != nil { 37 | t.Errorf("Error: %s", err) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /coins/history.go: -------------------------------------------------------------------------------- 1 | package coins 2 | 3 | import "github.com/JulianToledano/goingecko/types" 4 | 5 | type History struct { 6 | ID string `json:"id"` 7 | Symbol string `json:"symbol"` 8 | Name string `json:"name"` 9 | Localization types.Localization `json:"localization"` 10 | Image types.Image `json:"image"` 11 | MarketData HistoryMarketData `json:"market_data"` 12 | CommunityData types.CommunityData `json:"community_data"` 13 | DeveloperData types.DeveloperData `json:"developer_data"` 14 | PublicInterestStats types.PublicInterestStats `json:"public_interest_stats"` 15 | } 16 | 17 | type HistoryMarketData struct { 18 | CurrentPrice types.PriceRates `json:"current_price"` 19 | MarketCap types.PriceRates `json:"market_cap"` 20 | TotalVolume types.PriceRates `json:"total_volume"` 21 | } 22 | -------------------------------------------------------------------------------- /global/global.go: -------------------------------------------------------------------------------- 1 | package global 2 | 3 | import "github.com/JulianToledano/goingecko/types" 4 | 5 | type Global struct { 6 | Data data `json:"data"` 7 | } 8 | 9 | type data struct { 10 | ActiveCryptocurrencies int32 `json:"active_cryptocurrencies"` 11 | UpcomingIcos int32 `json:"upcoming_icos"` 12 | OngoingIcos int32 `json:"ongoing_icos"` 13 | EndedIcos int32 `json:"ended_icos"` 14 | Markets int32 `json:"markets"` 15 | TotalMarketCap types.PriceRates `json:"total_market_cap"` 16 | TotalVolume types.PriceRates `json:"total_volume"` 17 | MarketCapPercentage map[string]float64 `json:"market_cap_percentage"` 18 | MarketCapChangePercentage24hUsd float64 `json:"market_cap_change_percentage_24h_usd"` 19 | UpdatedAt float64 `json:"updated_at"` 20 | } 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-present Julián Toledano 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /test/derivatives_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "github.com/JulianToledano/goingecko" 5 | "testing" 6 | ) 7 | 8 | func TestDerivatives(t *testing.T) { 9 | cgClient := goingecko.NewClient(nil, "") 10 | data, err := cgClient.Derivatives() 11 | if data == nil { 12 | t.Errorf("Error") 13 | } 14 | if err != nil { 15 | t.Errorf("Error: %s", err) 16 | } 17 | } 18 | 19 | func TestDerivativesExchanges(t *testing.T) { 20 | cgClient := goingecko.NewClient(nil, "") 21 | data, err := cgClient.DerivativesExchanges("", 0, 0) 22 | if data == nil { 23 | t.Errorf("Error") 24 | } 25 | if err != nil { 26 | t.Errorf("Error: %s", err) 27 | } 28 | } 29 | 30 | func TestDerivativesExchangesId(t *testing.T) { 31 | cgClient := goingecko.NewClient(nil, "") 32 | data, err := cgClient.DerivativesExchangesId("binance_futures", "all") 33 | if data == nil { 34 | t.Errorf("Error") 35 | } 36 | if err != nil { 37 | t.Errorf("Error: %s", err) 38 | } 39 | } 40 | 41 | func TestDerivativesExchangesList(t *testing.T) { 42 | cgClient := goingecko.NewClient(nil, "") 43 | data, err := cgClient.DerivativesExchangesList() 44 | if data == nil { 45 | t.Errorf("Error") 46 | } 47 | if err != nil { 48 | t.Errorf("Error: %s", err) 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /test/contract_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/JulianToledano/goingecko" 7 | ) 8 | 9 | func TestContractInfo(t *testing.T) { 10 | coin := "ethereum" 11 | contract := "0x0D8775F648430679A709E98d2b0Cb6250d2887EF" 12 | 13 | cgClient := goingecko.NewClient(nil, "") 14 | 15 | contractData, err := cgClient.ContractInfo(coin, contract) 16 | if err != nil { 17 | t.Errorf("Error: %v", err) 18 | } else if contractData.ID != "basic-attention-token" { 19 | t.Errorf("Id: %s", contractData.ID) 20 | } 21 | 22 | } 23 | 24 | func TestContractMarketChart(t *testing.T) { 25 | coin := "ethereum" 26 | contract := "0x0D8775F648430679A709E98d2b0Cb6250d2887EF" 27 | 28 | cgClient := goingecko.NewClient(nil, "") 29 | 30 | contractData, err := cgClient.ContractMarketChart(coin, contract, "usd", "10") 31 | if err != nil { 32 | t.Errorf("Error: %v", err) 33 | } 34 | if contractData == nil { 35 | t.Errorf("Error nil") 36 | } 37 | } 38 | 39 | func TestContractMarketChartRange(t *testing.T) { 40 | coin := "ethereum" 41 | contract := "0x0D8775F648430679A709E98d2b0Cb6250d2887EF" 42 | 43 | cgClient := goingecko.NewClient(nil, "") 44 | 45 | contractData, err := cgClient.ContractMarketChartRange(coin, contract, "usd", "1392500000", "1422577232") 46 | if err != nil { 47 | t.Errorf("Error: %v", err) 48 | } 49 | if contractData == nil { 50 | t.Errorf("Error nil") 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /categories.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | 8 | "github.com/JulianToledano/goingecko/categories" 9 | ) 10 | 11 | // CategoriesList List all categories 12 | // Cache / Update Frequency: every 5 minutes 13 | func (c *Client) CategoriesList() (*categories.CategoriesList, error) { 14 | rUrl := fmt.Sprintf("%s/%s", c.getCategoriesURL(), "list") 15 | resp, err := c.MakeReq(rUrl) 16 | if err != nil { 17 | return nil, err 18 | } 19 | var data *categories.CategoriesList 20 | err = json.Unmarshal(resp, &data) 21 | if err != nil { 22 | return nil, err 23 | } 24 | return data, nil 25 | } 26 | 27 | // Categories List all categories with market data 28 | // Cache / Update Frequency: every 5 minutes 29 | // Parameters: 30 | // 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 31 | func (c *Client) Categories(order string) (*categories.CategoriesWithMarketDataList, error) { 32 | params := url.Values{} 33 | 34 | if order != "" { 35 | params.Add("order", order) 36 | } 37 | 38 | rUrl := fmt.Sprintf("%s?%s", c.getCategoriesURL(), params.Encode()) 39 | resp, err := c.MakeReq(rUrl) 40 | if err != nil { 41 | return nil, err 42 | } 43 | var data *categories.CategoriesWithMarketDataList 44 | err = json.Unmarshal(resp, &data) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return data, nil 49 | } 50 | -------------------------------------------------------------------------------- /test/exchanges_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "github.com/JulianToledano/goingecko" 5 | "testing" 6 | ) 7 | 8 | func TestExchanges(t *testing.T) { 9 | 10 | cgClient := goingecko.NewClient(nil, "") 11 | 12 | data, err := cgClient.Exchanges("", "") 13 | if data == nil { 14 | t.Errorf("Error") 15 | } 16 | if err != nil { 17 | t.Errorf("Error: %s", err) 18 | } 19 | } 20 | 21 | func TestExchangesList(t *testing.T) { 22 | cgClient := goingecko.NewClient(nil, "") 23 | data, err := cgClient.ExchangesList() 24 | if data == nil { 25 | t.Errorf("Error") 26 | } 27 | if err != nil { 28 | t.Errorf("Error: %s", err) 29 | } 30 | } 31 | 32 | func TestExchangesId(t *testing.T) { 33 | cgClient := goingecko.NewClient(nil, "") 34 | data, err := cgClient.ExchangesId("sushiswap") 35 | if data == nil { 36 | t.Errorf("Error") 37 | } 38 | if err != nil { 39 | t.Errorf("Error: %s", err) 40 | } 41 | } 42 | 43 | func TestExchangesIdTickers(t *testing.T) { 44 | cgClient := goingecko.NewClient(nil, "") 45 | data, err := cgClient.ExchangesIdTickers("sushiswap", "", "", 0, "", "") 46 | if data == nil { 47 | t.Errorf("Error") 48 | } 49 | if err != nil { 50 | t.Errorf("Error: %s", err) 51 | } 52 | } 53 | 54 | func TestExchangesIdVolumeChart(t *testing.T) { 55 | cgClient := goingecko.NewClient(nil, "") 56 | data, err := cgClient.ExchangesIdVolumeChart("sushiswap", "1") 57 | if data == nil { 58 | t.Errorf("Error") 59 | } 60 | if err != nil { 61 | t.Errorf("Error: %s", err) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /coins/statusUpdates.go: -------------------------------------------------------------------------------- 1 | package coins 2 | 3 | import "github.com/JulianToledano/goingecko/types" 4 | 5 | type StatusUpdates struct { 6 | StatusUpdates []Status `json:"status_updates"` 7 | } 8 | 9 | type Status struct { 10 | Description string `json:"description"` 11 | Category string `json:"category"` 12 | CreatedAt string `json:"created_at"` 13 | User string `json:"user"` 14 | UserTitle string `json:"user_title"` 15 | Pin bool `json:"pin"` 16 | Project Project `json:"project"` 17 | } 18 | 19 | type Project struct { 20 | Type string `json:"type"` 21 | ID string `json:"id"` 22 | Name string `json:"name"` 23 | Symbol string `json:"symbol"` 24 | Image types.Image `json:"image"` 25 | } 26 | 27 | /* 28 | { 29 | description: "Another big milestone for Fuse 🎉\r\n\r\nMajor crypto exchange MEXC Global has integrated the Fuse RPC and enabled FUSE deposits and withdrawals natively on the Fuse Network blockchain 😎\r\n\r\nRead more 👉 https://bit.ly/3rOopN4", 30 | category: "general", 31 | created_at: "2022-02-15T11:07:39.610Z", 32 | user: "Robert Miller", 33 | user_title: "Marcom Director ", 34 | pin: false, 35 | project: { 36 | type: "Coin", 37 | id: "fuse-network-token", 38 | name: "Fuse", 39 | symbol: "fuse", 40 | image: { 41 | thumb: "https://assets.coingecko.com/coins/images/10347/thumb/vUXKHEe.png?1601523640", 42 | small: "https://assets.coingecko.com/coins/images/10347/small/vUXKHEe.png?1601523640", 43 | large: "https://assets.coingecko.com/coins/images/10347/large/vUXKHEe.png?1601523640" 44 | } 45 | } 46 | } 47 | */ 48 | -------------------------------------------------------------------------------- /endpoints.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import "fmt" 4 | 5 | var ( 6 | version = "v3" 7 | BaseURL = fmt.Sprintf("https://api.coingecko.com/api/%s", version) 8 | ProBaseURL = fmt.Sprintf("https://pro-api.coingecko.com/api/%s", version) 9 | ) 10 | 11 | func (c *Client) getPingURL() string { 12 | return fmt.Sprintf("%s/ping", c.baseUrl) 13 | } 14 | 15 | func (c *Client) getSimpleURL() string { 16 | return fmt.Sprintf("%s/simple", c.baseUrl) 17 | } 18 | 19 | func (c *Client) getCoinsURL() string { 20 | return fmt.Sprintf("%s/coins", c.baseUrl) 21 | } 22 | 23 | func (c *Client) getAssetPlatformsURL() string { 24 | return fmt.Sprintf("%s/asset_platforms", c.baseUrl) 25 | } 26 | 27 | func (c *Client) getCategoriesURL() string { 28 | return fmt.Sprintf("%s/categories", c.getCoinsURL()) 29 | } 30 | 31 | func (c *Client) getExchangesURL() string { 32 | return fmt.Sprintf("%s/exchanges", c.baseUrl) 33 | } 34 | 35 | func (c *Client) getDerivativesURL() string { 36 | return fmt.Sprintf("%s/derivatives", c.baseUrl) 37 | } 38 | 39 | func (c *Client) getNftsURL() string { 40 | return fmt.Sprintf("%s/nfts", c.baseUrl) 41 | } 42 | 43 | func (c *Client) getSearchURL() string { 44 | return fmt.Sprintf("%s/search", c.baseUrl) 45 | } 46 | 47 | func (c *Client) getContractURL() string { 48 | return fmt.Sprintf("%s/coins", c.baseUrl) 49 | } 50 | 51 | func (c *Client) getExchangeRatesURL() string { 52 | return fmt.Sprintf("%s/exchange_rates", c.baseUrl) 53 | } 54 | 55 | func (c *Client) getTrendingURL() string { 56 | return fmt.Sprintf("%s/search/trending", c.baseUrl) 57 | } 58 | 59 | func (c *Client) getGlobalURL() string { 60 | return fmt.Sprintf("%s/global", c.baseUrl) 61 | } 62 | 63 | func (c *Client) getCompaniesURL() string { 64 | return fmt.Sprintf("%s/companies", c.baseUrl) 65 | } 66 | -------------------------------------------------------------------------------- /contract.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | 8 | "github.com/JulianToledano/goingecko/contract" 9 | "github.com/JulianToledano/goingecko/types" 10 | ) 11 | 12 | func (c *Client) ContractInfo(id, contractAddress string) (*contract.ContractAddressInfo, error) { 13 | rUrl := fmt.Sprintf("%s/%s/%s/%s", c.getContractURL(), id, "contract", contractAddress) 14 | resp, err := c.MakeReq(rUrl) 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | var data *contract.ContractAddressInfo 20 | err = json.Unmarshal([]byte(resp), &data) 21 | if err != nil { 22 | return nil, err 23 | } 24 | return data, nil 25 | } 26 | 27 | func (c *Client) ContractMarketChart(id, contractAddress, vsCurrency, days string) (*types.MarketChart, error) { 28 | params := url.Values{} 29 | params.Add("vs_currency", vsCurrency) 30 | params.Add("days", days) 31 | 32 | rUrl := fmt.Sprintf("%s/%s/%s/%s/%s?%s", c.getContractURL(), id, "contract", contractAddress, "market_chart", params.Encode()) 33 | resp, err := c.MakeReq(rUrl) 34 | if err != nil { 35 | return nil, err 36 | } 37 | 38 | var data *types.MarketChart 39 | err = json.Unmarshal([]byte(resp), &data) 40 | if err != nil { 41 | return nil, err 42 | } 43 | return data, nil 44 | } 45 | 46 | func (c *Client) ContractMarketChartRange(id, contractAddress, vsCurrency, from, to string) (*types.MarketChart, error) { 47 | params := url.Values{} 48 | params.Add("vs_currency", vsCurrency) 49 | params.Add("from", from) 50 | params.Add("to", to) 51 | 52 | rUrl := fmt.Sprintf("%s/%s/%s/%s/%s?%s", c.getContractURL(), id, "contract", contractAddress, "market_chart/range", params.Encode()) 53 | resp, err := c.MakeReq(rUrl) 54 | if err != nil { 55 | return nil, err 56 | } 57 | 58 | var data *types.MarketChart 59 | err = json.Unmarshal([]byte(resp), &data) 60 | if err != nil { 61 | return nil, err 62 | } 63 | return data, nil 64 | } 65 | -------------------------------------------------------------------------------- /client.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io" 7 | "net/http" 8 | 9 | "github.com/JulianToledano/goingecko/ping" 10 | ) 11 | 12 | const apiHeader = "x-cg-demo-api-key" 13 | const proApiHeader = "x-cg-pro-api-key" 14 | 15 | type Client struct { 16 | httpClient *http.Client 17 | baseUrl string 18 | apiKey string 19 | apiHeader string 20 | } 21 | 22 | func NewClient(httpClient *http.Client, apiKey string, isPro ...bool) *Client { 23 | if httpClient == nil { 24 | httpClient = http.DefaultClient 25 | } 26 | 27 | if isPro != nil { 28 | return &Client{ 29 | httpClient: httpClient, 30 | baseUrl: ProBaseURL, 31 | apiKey: apiKey, 32 | apiHeader: proApiHeader, 33 | } 34 | } 35 | 36 | return &Client{ 37 | httpClient: httpClient, 38 | baseUrl: BaseURL, 39 | apiKey: apiKey, 40 | apiHeader: apiHeader, 41 | } 42 | } 43 | 44 | func (c *Client) Close() { 45 | c.httpClient.CloseIdleConnections() 46 | } 47 | 48 | func doReq(req *http.Request, client *http.Client) ([]byte, error) { 49 | resp, err := client.Do(req) 50 | if err != nil { 51 | return nil, err 52 | } 53 | defer resp.Body.Close() 54 | body, err := io.ReadAll(resp.Body) 55 | if err != nil { 56 | return nil, err 57 | } 58 | if http.StatusOK != resp.StatusCode { 59 | return nil, fmt.Errorf("%s", body) 60 | } 61 | return body, nil 62 | } 63 | 64 | // MakeReq HTTP request helper 65 | func (c *Client) MakeReq(url string) ([]byte, error) { 66 | req, err := http.NewRequest("GET", url, nil) 67 | 68 | if c.apiKey != "" { 69 | req.Header.Add(c.apiHeader, c.apiKey) 70 | } 71 | 72 | if err != nil { 73 | return nil, err 74 | } 75 | resp, err := doReq(req, c.httpClient) 76 | if err != nil { 77 | return nil, err 78 | } 79 | return resp, err 80 | } 81 | 82 | // Ping /ping endpoint 83 | func (c *Client) Ping() (*ping.Ping, error) { 84 | resp, err := c.MakeReq(fmt.Sprintf("%s/ping", c.baseUrl)) 85 | if err != nil { 86 | return nil, err 87 | } 88 | var data *ping.Ping 89 | err = json.Unmarshal(resp, &data) 90 | if err != nil { 91 | return nil, err 92 | } 93 | return data, nil 94 | } 95 | -------------------------------------------------------------------------------- /exchangeRates/exchangeRates.go: -------------------------------------------------------------------------------- 1 | package exchangeRates 2 | 3 | type Rates struct { 4 | Rates coinRates `json:"rates"` 5 | } 6 | 7 | type rateInfo struct { 8 | Name string `json:"name"` 9 | Unit string `json:"unit"` 10 | Value float64 `json:"value"` 11 | Type string `json:"type"` 12 | } 13 | 14 | type coinRates struct { 15 | Btc rateInfo `json:"btc"` 16 | Eth rateInfo `json:"eth"` 17 | Ltc rateInfo `json:"ltc"` 18 | Bch rateInfo `json:"bch"` 19 | Bnb rateInfo `json:"bnb"` 20 | Eos rateInfo `json:"eos"` 21 | Xrp rateInfo `json:"xrp"` 22 | Xlm rateInfo `json:"xlm"` 23 | Link rateInfo `json:"link"` 24 | Dot rateInfo `json:"dot"` 25 | Yfi rateInfo `json:"yfi"` 26 | Usd rateInfo `json:"usd"` 27 | Aed rateInfo `json:"aed"` 28 | Ars rateInfo `json:"ars"` 29 | Aud rateInfo `json:"aud"` 30 | Bdt rateInfo `json:"bdt"` 31 | Bhd rateInfo `json:"bhd"` 32 | Bmd rateInfo `json:"bmd"` 33 | Brl rateInfo `json:"brl"` 34 | Cad rateInfo `json:"cad"` 35 | Chf rateInfo `json:"chf"` 36 | Clp rateInfo `json:"clp"` 37 | Cny rateInfo `json:"cny"` 38 | Czk rateInfo `json:"czk"` 39 | Dkk rateInfo `json:"dkk"` 40 | Eur rateInfo `json:"eur"` 41 | Gbp rateInfo `json:"gbp"` 42 | Hkd rateInfo `json:"hkd"` 43 | Huf rateInfo `json:"huf"` 44 | Idr rateInfo `json:"idr"` 45 | Ils rateInfo `json:"ils"` 46 | Inr rateInfo `json:"inr"` 47 | Jpy rateInfo `json:"jpy"` 48 | Krw rateInfo `json:"krw"` 49 | Kwd rateInfo `json:"kwd"` 50 | Lkr rateInfo `json:"lkr"` 51 | Mmk rateInfo `json:"mmk"` 52 | Mxn rateInfo `json:"mxn"` 53 | Myr rateInfo `json:"myr"` 54 | Ngn rateInfo `json:"ngn"` 55 | Nok rateInfo `json:"nok"` 56 | Nzd rateInfo `json:"nzd"` 57 | Php rateInfo `json:"php"` 58 | Pkr rateInfo `json:"pkr"` 59 | Pln rateInfo `json:"pln"` 60 | Rub rateInfo `json:"rub"` 61 | Sar rateInfo `json:"sar"` 62 | Sek rateInfo `json:"sek"` 63 | Sgd rateInfo `json:"sgd"` 64 | Thb rateInfo `json:"thb"` 65 | Try rateInfo `json:"try"` 66 | Twd rateInfo `json:"twd"` 67 | Uah rateInfo `json:"uah"` 68 | Vef rateInfo `json:"vef"` 69 | Vnd rateInfo `json:"vnd"` 70 | Zar rateInfo `json:"zar"` 71 | Xdr rateInfo `json:"xdr"` 72 | Xag rateInfo `json:"xag"` 73 | Xau rateInfo `json:"xau"` 74 | Bits rateInfo `json:"bits"` 75 | Sats rateInfo `json:"sats"` 76 | } 77 | -------------------------------------------------------------------------------- /coins/id.go: -------------------------------------------------------------------------------- 1 | package coins 2 | 3 | import "github.com/JulianToledano/goingecko/types" 4 | 5 | type CoinID struct { 6 | ID string `json:"id"` 7 | Symbol string `json:"symbol"` 8 | Name string `json:"name"` 9 | AssetPlatformID string `json:"asset_platform_id"` 10 | BlockTimeInMinutes int `json:"block_time_in_minutes"` 11 | HashingAlgorithm string `json:"hashing_algorithm"` 12 | Categories []string `json:"categories"` 13 | // PublicNotice ¿? `json:"public_notice"` 14 | // AdditionalNotices ¿? `json:"public_notices"` 15 | Localization types.Localization `json:"localization"` 16 | Description types.Description `json:"description"` 17 | Links types.Links `json:"links"` 18 | Image types.Image `json:"image"` 19 | CountryOrigin string `json:"country_origin"` 20 | GenesisData string `json:"genesis_date"` 21 | SentimentVotesUpPercent float32 `json:"sentiment_votes_up_percentage"` 22 | SentimentVotesDownPercent float32 `json:"sentiment_votes_down_percentage"` 23 | MarketCapRank int `json:"market_cap_rank"` 24 | CoingeckoRank int `json:"coingecko_rank"` 25 | CoingeckoScore float32 `json:"coingecko_score"` 26 | DeveloperScore float32 `json:"developer_score"` 27 | CommunityScore float32 `json:"community_score"` 28 | LiquidityScore float32 `json:"liquidity_score"` 29 | PublicInterestScore float32 `json:"public_interest_score"` 30 | MarketData types.MarketData `json:"market_data"` 31 | CommunityData types.CommunityData `json:"community_data"` 32 | DeveloperData types.DeveloperData `json:"developer_data"` 33 | PublicInterestStats types.PublicInterestStats `json:"public_interest_stats"` 34 | Tickers []types.Ticker `json:"tickers"` 35 | } 36 | 37 | type ReposUrl struct { 38 | Github []string `json:"github"` 39 | Bitbucket []string `json:"bitbucket"` 40 | } 41 | -------------------------------------------------------------------------------- /simple.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | "strconv" 8 | 9 | "github.com/JulianToledano/goingecko/simple" 10 | ) 11 | 12 | func (c *Client) SimplePrice(ids, vsCurrencies string, includeMarketCap, includeDayVolume, includeDayChange, includeLastTimeUpdated bool) (simple.Price, error) { 13 | params := url.Values{} 14 | 15 | params.Add("ids", ids) 16 | params.Add("vs_currencies", vsCurrencies) 17 | params.Add("include_market_cap", strconv.FormatBool(includeMarketCap)) 18 | params.Add("include_24hr_vol", strconv.FormatBool(includeDayVolume)) 19 | params.Add("include_24hr_change", strconv.FormatBool(includeDayChange)) 20 | params.Add("include_last_updated_at", strconv.FormatBool(includeLastTimeUpdated)) 21 | 22 | rUrl := fmt.Sprintf("%s/%s?%s", c.getSimpleURL(), "price", params.Encode()) 23 | resp, err := c.MakeReq(rUrl) 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | var data simple.Price 29 | err = json.Unmarshal([]byte(resp), &data) 30 | if err != nil { 31 | return nil, err 32 | } 33 | return data, nil 34 | } 35 | 36 | func (c *Client) SimpleTokenPrice(id, contractAddresses, vsCurrencies string, includeMarketCap, includeDayVolume, includeDayChange, includeLastTimeUpdated bool) (simple.TokenPrice, error) { 37 | params := url.Values{} 38 | 39 | params.Add("contract_addresses", contractAddresses) 40 | params.Add("vs_currencies", vsCurrencies) 41 | params.Add("include_market_cap", strconv.FormatBool(includeMarketCap)) 42 | params.Add("include_24hr_vol", strconv.FormatBool(includeDayVolume)) 43 | params.Add("include_24hr_change", strconv.FormatBool(includeDayChange)) 44 | params.Add("include_last_updated_at", strconv.FormatBool(includeLastTimeUpdated)) 45 | 46 | rUrl := fmt.Sprintf("%s/%s/%s?%s", c.getSimpleURL(), "token_price", id, params.Encode()) 47 | resp, err := c.MakeReq(rUrl) 48 | if err != nil { 49 | return nil, err 50 | } 51 | 52 | var data simple.TokenPrice 53 | err = json.Unmarshal([]byte(resp), &data) 54 | if err != nil { 55 | return nil, err 56 | } 57 | return data, nil 58 | } 59 | 60 | func (c *Client) SimpleSupportedVsCurrency() (*simple.SupportedVsCurrency, error) { 61 | rUrl := fmt.Sprintf("%s/%s", c.getSimpleURL(), "supported_vs_currencies") 62 | resp, err := c.MakeReq(rUrl) 63 | if err != nil { 64 | return nil, err 65 | } 66 | 67 | var data *simple.SupportedVsCurrency 68 | err = json.Unmarshal(resp, &data) 69 | if err != nil { 70 | return nil, err 71 | } 72 | return data, nil 73 | } 74 | -------------------------------------------------------------------------------- /nfts.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | 8 | "github.com/JulianToledano/goingecko/nfts" 9 | ) 10 | 11 | // NftsList Use this to obtain all the NFT ids in order to make API calls, paginated to 100 items. 12 | // 13 | // Cache / Update Frequency: every 5 minutes 14 | // Parameters: 15 | // 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 16 | // assetPlatformId(string) - The id of the platform issuing tokens (See asset_platforms endpoint for list of options) 17 | // per_page(integer) - Valid values: 1..250. Total results per page 18 | // page(integer) - Page through results 19 | func (c *Client) NftsList(order, assetPlatformId string, perPage, page int32) ([]nfts.Nft, error) { 20 | params := url.Values{} 21 | if order != "" { 22 | params.Add("order", order) 23 | } 24 | if assetPlatformId != "" { 25 | params.Add("asset_platform_id", assetPlatformId) 26 | } 27 | if perPage > 0 { 28 | params.Add("per_page", string(perPage)) 29 | } 30 | if page > 0 { 31 | params.Add("page", string(page)) 32 | } 33 | 34 | rUrl := fmt.Sprintf("%s/list?%s", c.getNftsURL(), params.Encode()) 35 | resp, err := c.MakeReq(rUrl) 36 | if err != nil { 37 | return nil, err 38 | } 39 | 40 | var data []nfts.Nft 41 | err = json.Unmarshal(resp, &data) 42 | if err != nil { 43 | return nil, err 44 | } 45 | 46 | return data, nil 47 | } 48 | 49 | // NftsId Get current data (name, price_floor, volume_24h ...) for an NFT collection. native_currency (string) is only a representative of the currency. 50 | // 51 | // Cache / Update Frequency: every 60 seconds 52 | // Parameters: 53 | // id*(string) - id of nft collection (can be obtained from /nfts/list) 54 | func (c *Client) NftsId(id string) (*nfts.NftId, error) { 55 | rUrl := fmt.Sprintf("%s/%s", c.getNftsURL(), id) 56 | resp, err := c.MakeReq(rUrl) 57 | if err != nil { 58 | return nil, err 59 | } 60 | 61 | var data *nfts.NftId 62 | err = json.Unmarshal(resp, &data) 63 | if err != nil { 64 | return nil, err 65 | } 66 | 67 | return data, nil 68 | } 69 | 70 | // NftsContract 71 | func (c *Client) NftsContract(assetPlatform, contract string) (*nfts.NftId, error) { 72 | rUrl := fmt.Sprintf("%s/%s/contract/%s", c.getNftsURL(), assetPlatform, contract) 73 | resp, err := c.MakeReq(rUrl) 74 | if err != nil { 75 | return nil, err 76 | } 77 | 78 | var data *nfts.NftId 79 | err = json.Unmarshal(resp, &data) 80 | if err != nil { 81 | return nil, err 82 | } 83 | 84 | return data, nil 85 | } 86 | -------------------------------------------------------------------------------- /test/coins_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/JulianToledano/goingecko" 7 | ) 8 | 9 | func TestCoinsList(t *testing.T) { 10 | 11 | cgClient := goingecko.NewClient(nil, "") 12 | 13 | coinData, _ := cgClient.CoinsList() 14 | if coinData == nil { 15 | t.Errorf("Error") 16 | } 17 | } 18 | 19 | func TestCoinsMarket(t *testing.T) { 20 | 21 | cgClient := goingecko.NewClient(nil, "") 22 | ids := []string{ 23 | "bitcoin", 24 | "ethereum", 25 | } 26 | priceChange := make([]string, 0) 27 | 28 | priceChange = append(priceChange, "24h") 29 | coinData, _ := cgClient.CoinsMarket("usd", ids, "", "", "100", "1", true, priceChange) 30 | if coinData == nil { 31 | t.Errorf("Error") 32 | } 33 | } 34 | 35 | func TestCoinsIds(t *testing.T) { 36 | 37 | cgClient := goingecko.NewClient(nil, "") 38 | 39 | coinData, err := cgClient.CoinsId("bitcoin", true, true, true, true, true, true) 40 | if err != nil { 41 | t.Errorf("Error: %s", err) 42 | } 43 | if coinData == nil { 44 | t.Errorf("Error") 45 | } 46 | 47 | } 48 | 49 | func TestCoinsIdsTickers(t *testing.T) { 50 | 51 | cgClient := goingecko.NewClient(nil, "") 52 | 53 | coinData, err := cgClient.CoinsIdTickers("bitcoin", "", "", "", "", "") 54 | if coinData == nil { 55 | t.Errorf("Error") 56 | } 57 | if err != nil { 58 | t.Errorf("Error: %s", err) 59 | } 60 | } 61 | 62 | func TestCoinsIdsHistory(t *testing.T) { 63 | 64 | cgClient := goingecko.NewClient(nil, "") 65 | 66 | coinData, err := cgClient.CoinsIdHistory("bitcoin", "30-12-17", true) 67 | if coinData == nil { 68 | t.Errorf("Error") 69 | } 70 | if err != nil { 71 | t.Errorf("Error: %s", err) 72 | } 73 | } 74 | 75 | func TestCoinsIdsMarketChart(t *testing.T) { 76 | 77 | cgClient := goingecko.NewClient(nil, "") 78 | 79 | coinData, err := cgClient.CoinsIdMarketChart("bitcoin", "usd", "10") 80 | if coinData == nil { 81 | t.Errorf("Error") 82 | } 83 | if err != nil { 84 | t.Errorf("Error: %s", err) 85 | } 86 | } 87 | 88 | func TestCoinsIdsMarketChartRange(t *testing.T) { 89 | 90 | cgClient := goingecko.NewClient(nil, "") 91 | 92 | coinData, err := cgClient.CoinsIdMarketChartRange("bitcoin", "usd", "1392577232", "1422577232") 93 | if coinData == nil { 94 | t.Errorf("Error") 95 | } 96 | if err != nil { 97 | t.Errorf("Error: %s", err) 98 | } 99 | } 100 | 101 | func TestCoinsIdsOhlc(t *testing.T) { 102 | 103 | cgClient := goingecko.NewClient(nil, "") 104 | 105 | coinData, err := cgClient.CoinsOhlc("bitcoin", "usd", "7") 106 | if coinData == nil { 107 | t.Errorf("Error") 108 | } 109 | if err != nil { 110 | t.Errorf("Error: %s", err) 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /coins/markets.go: -------------------------------------------------------------------------------- 1 | package coins 2 | 3 | import "github.com/JulianToledano/goingecko/types" 4 | 5 | type Market struct { 6 | ID string `json:"ID"` 7 | Symbol string `json:"symbol"` 8 | Name string `json:"name"` 9 | Image string `json:"image"` 10 | CurrentPrice float64 `json:"current_price"` 11 | MarketCap float64 `json:"market_cap"` 12 | MarkeCcapRank int32 `json:"market_cap_rank"` 13 | FullyDilutedValuation float64 `json:"fully_diluted_valuation"` 14 | TotalVolume float64 `json:"total_volume"` 15 | HighDay float64 `json:"high_24h"` 16 | LowDay float64 `json:"low_24h"` 17 | PriceChangeDay float64 `json:"price_change_24h"` 18 | PriceChangePercentageDay float64 `json:"price_change_percentage_24h"` 19 | MarketCapChangeDay float64 `json:"market_cap_change_24h"` 20 | MarketCapChangePercentageDay float64 `json:"market_cap_change_percentage_24h"` 21 | CirculatingSupply float64 `json:"circulating_supply"` 22 | TotalSupply float64 `json:"total_supply"` 23 | MaxSupply float64 `json:"max_supply"` 24 | Ath float64 `json:"ath"` 25 | AthChangePercentage float64 `json:"ath_change_percentage"` 26 | AthDate string `json:"ath_date"` 27 | Atl float64 `json:"atl"` 28 | AtlChangePercentage float64 `json:"atl_change_percentage"` 29 | AtlDate string `json:"atl_date"` 30 | Roi types.Roi `json:"roi"` 31 | LastUpdated string `json:"last_updated"` 32 | SparklineInWeek types.Sparkline `json:"sparkline_in_7d"` 33 | PriceChangePercentageTwoWeeksInCurrency float64 `json:"price_change_percentage_14d_in_currency"` 34 | PriceChangePercentageHourInCurrency float64 `json:"price_change_percentage_1h_in_currency"` 35 | PriceChangePercentageThreeMonthsInCurrency float64 `json:"price_change_percentage_200d_in_currency"` 36 | PriceChangePercentageDayInCurrency float64 `json:"price_change_percentage_24h_in_currency"` 37 | PriceChangePercentageMonthInCurrency float64 `json:"price_change_percentage_30d_in_currency"` 38 | PriceChangePercentageWeekInCurrency float64 `json:"price_change_percentage_7d_in_currency"` 39 | } 40 | -------------------------------------------------------------------------------- /derivatives/derivatives.go: -------------------------------------------------------------------------------- 1 | package derivatives 2 | 3 | type Derivative struct { 4 | Market string `json:"market"` 5 | Symbol string `json:"symbol"` 6 | IndexId string `json:"index_id"` 7 | Price string `json:"price"` 8 | PricePercentageChange24h float64 `json:"price_percentage_change_24h"` 9 | ContractType string `json:"contract_type"` 10 | Index float64 `json:"index"` 11 | Basis float64 `json:"basis"` 12 | Spread float64 `json:"spread"` 13 | FundingRate float64 `json:"funding_rate"` 14 | OpenInterest float64 `json:"open_interest"` 15 | Volume24h float64 `json:"volume_24h"` 16 | LastTradedAt int64 `json:"last_traded_at"` 17 | ExpiredAt int64 `json:"expired_at"` 18 | } 19 | 20 | type Exchange struct { 21 | Name string `json:"name"` 22 | ID string `json:"id"` 23 | OpenInterestBtc float64 `json:"open_interest_btc"` 24 | TradeVolume24hBtc string `json:"trade_volume_24h_btc"` 25 | NumberOfPerpetualPairs int32 `json:"number_of_perpetual_pairs"` 26 | NumberOfFuturesPairs int32 `json:"number_of_futures_pairs"` 27 | Image string `json:"image"` 28 | YearEstablished int32 `json:"year_established"` 29 | Country string `json:"country"` 30 | Description string `json:"description"` 31 | Url string `json:"url"` 32 | } 33 | 34 | type ExchangeId struct { 35 | Name string `json:"name"` 36 | OpenInterestBtc float64 `json:"open_interest_btc"` 37 | TradeVolume24hBtc string `json:"trade_volume_24h_btc"` 38 | NumberOfPerpetualPairs int64 `json:"number_of_perpetual_pairs"` 39 | NumberOfPuturesPairs int64 `json:"number_of_futures_pairs"` 40 | Image string `json:"image"` 41 | YearEstablished int32 `json:"year_established"` 42 | Country string `json:"country"` 43 | Description string `json:"description"` 44 | Url string `json:"url"` 45 | Tickers []Ticker `json:"tickers"` 46 | } 47 | 48 | type Ticker struct { 49 | Symbol string `json:"symbol"` 50 | Base string `json:"base"` 51 | Target string `json:"target"` 52 | TradeURL string `json:"trade_url"` 53 | ContractType string `json:"contract_type"` 54 | Last float64 `json:"last"` 55 | H24PercentageChange float64 `json:"h24_percentage_change"` 56 | Index float64 `json:"index"` 57 | IndexBasicPercentage float64 `json:"index_basic_percentage"` 58 | BidAskSpread float64 `json:"bid_ask_spread"` 59 | FundingRate float64 `json:"funding_rate"` 60 | OpenInterestUsd float64 `json:"open_interest_usd"` 61 | H24Volume float64 `json:"h24_volume"` 62 | ConvertedVolume Converted `json:"converted_volume"` 63 | ConvertedLast Converted `json:"converted_last"` 64 | LastTradedAt string `json:"last_traded_at"` 65 | ExpiredAt float64 `json:"expired_at"` 66 | } 67 | 68 | type Converted struct { 69 | Btc string `json:"btc"` 70 | Eth string `json:"eth"` 71 | Usd string `json:"usd"` 72 | } 73 | 74 | type DerivativesListItem struct { 75 | ID string `json:"id"` 76 | Name string `json:"name"` 77 | } 78 | -------------------------------------------------------------------------------- /nfts/nfts.go: -------------------------------------------------------------------------------- 1 | package nfts 2 | 3 | type Nft struct { 4 | Id string `json:"id"` 5 | ContractAddress string `json:"contract_address"` 6 | Name string `json:"name"` 7 | AssetPlatformId string `json:"asset_platform_id"` 8 | Symbol string `json:"symbol"` 9 | } 10 | 11 | type NftId struct { 12 | Id string `json:"id"` 13 | ContractAddress string `json:"contract_address"` 14 | AssetPlatformId string `json:"asset_platform_id"` 15 | Name string `json:"name"` 16 | Symbol string `json:"symbol"` 17 | Image Image `json:"image"` 18 | Description string `json:"description"` 19 | NativeCurrency string `json:"native_currency"` 20 | NativeCurrencySymbol string `json:"native_currency_symbol"` 21 | FloorPrice Price `json:"floor_price"` 22 | MarketCap Price `json:"market_cap"` 23 | Volume24H Price `json:"volume_24h"` 24 | FloorPriceInUsd24HPercentageChange float64 `json:"floor_price_in_usd_24h_percentage_change"` 25 | FloorPrice24HPercentageChange Price `json:"floor_price_24h_percentage_change"` 26 | MarketCap24HPercentageChange Price `json:"market_cap_24h_percentage_change"` 27 | Volume24HPercentageChange Price `json:"volume_24h_percentage_change"` 28 | NumberOfUniqueAddresses float64 `json:"number_of_unique_addresses"` 29 | NumberOfUniqueAddresses24HPercentageChange float64 `json:"number_of_unique_addresses_24h_percentage_change"` 30 | VolumeInUsd24HPercentageChange float64 `json:"volume_in_usd_24h_percentage_change"` 31 | TotalSupply float64 `json:"total_supply"` 32 | OneDaySales float64 `json:"one_day_sales"` 33 | OneDaySales24HPercentageChange float64 `json:"one_day_sales_24h_percentage_change"` 34 | OneDayAverageSalePrice float64 `json:"one_day_average_sale_price"` 35 | OneDayAverageSalePrice24HPercentageChange float64 `json:"one_day_average_sale_price_24h_percentage_change"` 36 | Links Links `json:"links"` 37 | FloorPrice7DPercentageChange Price `json:"floor_price_7d_percentage_change"` 38 | FloorPrice14DPercentageChange Price `json:"floor_price_14d_percentage_change"` 39 | FloorPrice30DPercentageChange Price `json:"floor_price_30d_percentage_change"` 40 | FloorPrice60DPercentageChange Price `json:"floor_price_60d_percentage_change"` 41 | FloorPrice1YPercentageChange Price `json:"floor_price_1y_percentage_change"` 42 | Explorers []Explorers `json:"explorers"` 43 | } 44 | 45 | type Price struct { 46 | Usd float64 `json:"usd"` 47 | NativeCurrency float64 `json:"native_currency"` 48 | } 49 | 50 | type Image struct { 51 | Small string `json:"small"` 52 | } 53 | 54 | type Links struct { 55 | Homepage string `json:"homepage"` 56 | Twitter string `json:"twitter"` 57 | Discord string `json:"discord"` 58 | } 59 | 60 | type Explorers struct { 61 | Name string `json:"name"` 62 | Link string `json:"link"` 63 | } 64 | -------------------------------------------------------------------------------- /derivatives.go: -------------------------------------------------------------------------------- 1 | package goingecko 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net/url" 7 | 8 | "github.com/JulianToledano/goingecko/derivatives" 9 | ) 10 | 11 | // Derivatives List all derivative tickers. 12 | // Note: 'open_interest' and 'volume_24h' data are in USD 13 | // Cache / Update Frequency: every 30 seconds 14 | func (c *Client) Derivatives() ([]derivatives.Derivative, error) { 15 | 16 | rUrl := fmt.Sprintf("%s", c.getDerivativesURL()) 17 | resp, err := c.MakeReq(rUrl) 18 | if err != nil { 19 | return nil, err 20 | } 21 | 22 | var data []derivatives.Derivative 23 | err = json.Unmarshal(resp, &data) 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | return data, nil 29 | } 30 | 31 | // DerivativesExchanges List all derivative exchanges. 32 | // 33 | // Cache / Update Frequency: every 60 seconds 34 | // Parameters: 35 | // 36 | // order(string) - order results using following params name_asc,name_desc,open_interest_btc_asc, 37 | // open_interest_btc_desc,trade_volume_24h_btc_asc,trade_volume_24h_btc_desc 38 | // 39 | // perPage(integer) - Total results per page 40 | // page(integer) - Page through results 41 | func (c *Client) DerivativesExchanges(order string, perPage, page int32) ([]derivatives.Exchange, error) { 42 | params := url.Values{} 43 | if order != "" { 44 | params.Add("order", order) 45 | } 46 | if perPage > 0 { 47 | params.Add("per_page", string(perPage)) 48 | } 49 | if page > 0 { 50 | params.Add("page", string(page)) 51 | } 52 | 53 | rUrl := fmt.Sprintf("%s/exchanges?%s", c.getDerivativesURL(), params.Encode()) 54 | resp, err := c.MakeReq(rUrl) 55 | if err != nil { 56 | return nil, err 57 | } 58 | 59 | var data []derivatives.Exchange 60 | err = json.Unmarshal(resp, &data) 61 | if err != nil { 62 | return nil, err 63 | } 64 | 65 | return data, nil 66 | } 67 | 68 | // DerivativesExchangesId show derivative exchange data 69 | // 70 | // Dictionary: 71 | // 72 | // last: latest unconverted price in the respective pair target currency 73 | // volume: unconverted 24h trading volume in the respective pair target currency 74 | // converted_last: latest converted price in BTC, ETH, and USD 75 | // converted_volume: converted 24h trading volume in BTC, ETH, and USD 76 | // 77 | // Cache / Update Frequency: every 30 seconds 78 | // Parameters: 79 | // 80 | // id*(string) - pass the exchange id (can be obtained from derivatives/exchanges/list) eg. bitmex 81 | // includeTickers(string) - ['all', 'unexpired'] - expired to show unexpired tickers, all to list all tickers, 82 | // leave blank to omit tickers data in response 83 | func (c *Client) DerivativesExchangesId(id, includeTickers string) (*derivatives.ExchangeId, error) { 84 | params := url.Values{} 85 | if includeTickers != "" { 86 | params.Add("include_tickers", includeTickers) 87 | } 88 | 89 | rUrl := fmt.Sprintf("%s/exchanges/%s?%s", c.getDerivativesURL(), id, params.Encode()) 90 | resp, err := c.MakeReq(rUrl) 91 | if err != nil { 92 | return nil, err 93 | } 94 | 95 | var data *derivatives.ExchangeId 96 | err = json.Unmarshal(resp, &data) 97 | if err != nil { 98 | return nil, err 99 | } 100 | 101 | return data, nil 102 | } 103 | 104 | // DerivativesExchangesList List all derivative exchanges name and identifier. 105 | // 106 | // Cache / Update Frequency: every 5 minutes 107 | func (c *Client) DerivativesExchangesList() ([]derivatives.DerivativesListItem, error) { 108 | rUrl := fmt.Sprintf("%s/exchanges/list", c.getDerivativesURL()) 109 | resp, err := c.MakeReq(rUrl) 110 | if err != nil { 111 | return nil, err 112 | } 113 | 114 | var data []derivatives.DerivativesListItem 115 | err = json.Unmarshal(resp, &data) 116 | if err != nil { 117 | return nil, err 118 | } 119 | 120 | return data, nil 121 | } 122 | -------------------------------------------------------------------------------- /exchanges/exchanges.go: -------------------------------------------------------------------------------- 1 | package exchanges 2 | 3 | type Exchange struct { 4 | ID string `json:"id"` 5 | Name string `json:"name"` 6 | YearEstablished int32 `json:"year_established"` 7 | Country string `json:"country"` 8 | Description string `json:"description"` 9 | Url string `json:"url"` 10 | Image string `json:"image"` 11 | HasTradingIncentive bool `json:"has_trading_incentive"` 12 | TrustScore int32 `json:"trust_score"` 13 | TrustScoreRank int32 `json:"trust_score_rank"` 14 | TradeVolume24h float64 `json:"trade_volume_24h_btc"` 15 | TradeVolume24jBtcNormalice float64 `json:"trade_volume_24h_btc_normalized"` 16 | } 17 | 18 | type ExchangesList []Exchange 19 | 20 | type ExchangeId struct { 21 | ID string `json:"id"` 22 | Name string `json:"name"` 23 | } 24 | 25 | type ExchangeWithTicker struct { 26 | Name string `json:"name"` 27 | YearEstablished int32 `json:"year_established"` 28 | Country string `json:"country"` 29 | Description string `json:"description"` 30 | Url string `json:"url"` 31 | Image string `json:"image"` 32 | FacebookUrl string `json:"facebook_url"` 33 | RedditYrl string `json:"reddit_url"` 34 | TelegramUrl string `json:"telegram_url"` 35 | SlackUrl string `json:"slack_url"` 36 | OtherUrl1 string `json:"other_url_1"` 37 | OtherUrl2 string `json:"other_url_2"` 38 | TwitterHandle string `json:"twitter_handle"` 39 | HasTradingIncentive bool `json:"has_trading_incentive"` 40 | Centralized bool `json:"centralized"` 41 | PublicNotice string `json:"public_notice"` 42 | AlertNotice string `json:"alert_notice"` 43 | TrustScore int32 `json:"trust_score"` 44 | TrustScoreRank int32 `json:"trust_score_rank"` 45 | TradeVolume24hBtc float64 `json:"trade_volume_24h_btc"` 46 | TradeVolume24hBtcNormalized float64 `json:"trade_volume_24h_btc_normalized"` 47 | Tickers []Ticker `json:"tickers"` 48 | StatusUpdates []StatusUpdates `json:"status_updates"` 49 | } 50 | 51 | type Tickers struct { 52 | Name string `json:"name"` 53 | Tickers []Ticker `json:"tickers"` 54 | } 55 | 56 | type Ticker struct { 57 | Base string `json:"base"` 58 | Target string `json:"target"` 59 | Market Market `json:"Market"` 60 | Last float64 `json:"Last"` 61 | Volume float64 `json:"volume"` 62 | ConvertedLast Converted `json:"converted_last"` 63 | ConvertedVolume Converted `json:"converted_volume"` 64 | TrustScore string `json:"trust_score"` 65 | BidAskSpreadPercentage float64 `json:"bid_ask_spread_percentage"` 66 | Timestamp string `json:"timestamp"` 67 | LastTradedAt string `json:"last_traded_at"` 68 | LastFetchAt string `json:"last_fetch_at"` 69 | IsAnomaly bool `json:"is_anomaly"` 70 | IsStale bool `json:"is_stale"` 71 | TradeUrl string `json:"trade_url"` 72 | TokenInfoUrl string `json:"token_info_url"` 73 | CoinID string `json:"coin_id"` 74 | TargetCoinID string `json:"target_coin_id"` 75 | } 76 | 77 | type StatusUpdates struct { 78 | // ?? 79 | } 80 | 81 | type Market struct { 82 | Name string `json:"name"` 83 | Identifier string `json:"identifier"` 84 | HasTradingIncentive bool `json:"has_trading_incentive"` 85 | } 86 | 87 | type Converted struct { 88 | Btc float64 `json:"btc"` 89 | Eth float64 `json:"eth"` 90 | Usd float64 `json:"usd"` 91 | } 92 | 93 | var VolumeChartValidDays = map[string]struct{}{ 94 | "1": {}, 95 | "7": {}, 96 | "14": {}, 97 | "30": {}, 98 | "90": {}, 99 | "180": {}, 100 | "365": {}, 101 | } 102 | 103 | type Volume []interface{} 104 | -------------------------------------------------------------------------------- /contract/contractAddress.go: -------------------------------------------------------------------------------- 1 | package contract 2 | 3 | import "github.com/JulianToledano/goingecko/types" 4 | 5 | // TODO: missing a lot of info 6 | type ContractAddressInfo struct { 7 | ID string `json:"id"` 8 | Symbol string `json:"symbol"` 9 | Name string `json:"name"` 10 | AssetPlatformId string `json:"asset_platform_id"` 11 | Platforms map[string]string `json:"platforms"` 12 | BlockTimeInMinutes int `json:"block_time_in_minutes"` 13 | Hashing_algorithm string `json:"hashing_algorithm"` 14 | Categories []string `json:"categories"` 15 | // public_notice `json:"//`" 16 | // additional_notices [] `json:"//`" 17 | Localization types.Localization `json:"localization"` 18 | Jescription types.Description `json:"description"` 19 | Links types.Links `json:"links"` 20 | Image types.Image `json:"image"` 21 | CountryOrigin string `json:"country_origin"` 22 | GenesisDate string `json:"genesis_date"` 23 | Contract_address string `json:"contract_address"` 24 | Sentiment_votes_up_percentage float64 `json:"sentiment_votes_up_percentage"` 25 | Sentiment_votes_down_percentage float64 `json:"sentiment_votes_down_percentage"` 26 | IcoData IcoData `json:"ico_data"` 27 | MarketCapRank int32 `json:"market_cap_rank"` 28 | CoingeckoRank int32 `json:"coingecko_rank"` 29 | CoingeckoScore float64 `json:"coingecko_score"` 30 | DeveloperScore float64 `json:"developer_score"` 31 | CommunityScore float64 `json:"community_score"` 32 | LiquidityScore float64 `json:"liquidity_score"` 33 | PublicInterestScore float64 `json:"public_interest_score"` 34 | MarketData types.MarketData `json:"market_data"` 35 | CommunityData types.CommunityData `json:"community_data"` 36 | DeveloperData types.DeveloperData `json:"developer_data"` 37 | PublicInterestStats types.PublicInterestStats `json:"public_interest_stats"` 38 | StatusUpdates []string `json:"status_updates"` 39 | LastUpdated string `json:"last_updated"` 40 | Tickers []types.Ticker `json:"tickers"` 41 | } 42 | 43 | type IcoData struct { 44 | IcoStartDate string `json:"ico_start_date"` 45 | IcoEndDate string `json:"ico_end_date"` 46 | ShortDesc string `json:"short_desc"` 47 | Description string `json:"description"` 48 | Links Links `json:"Linkslinks"` 49 | SoftcapCurrency string `json:"softcap_currency"` 50 | HardcapCurrency string `json:"hardcap_currency"` 51 | TotalRaisedCurrency string `json:"total_raised_currency"` 52 | // softcap_amount `json:"nullsoftcap_amount"` 53 | // hardcap_amount `json:"nullhardcap_amount"` 54 | // total_raised `json:"nulltotal_raised"` 55 | QuotePreSaleCurrency string `json:"quote_pre_sale_currency"` 56 | // base_pre_sale_amount `json:"nullbase_pre_sale_amount"` 57 | // quote_pre_sale_amount `json:"nullquote_pre_sale_amount"` 58 | QuotePublicSaleCurrency string `json:"quote_public_sale_currency"` 59 | BasePublicSaleAmount float64 `json:"base_public_sale_amount"` 60 | QuotePublicSaleAmount float64 `json:"quote_public_sale_amount"` 61 | AcceptingCurrencies string `json:"accepting_currencies"` 62 | CountryOrigin string `json:"country_origin"` 63 | // pre_sale_start_date `json:"nullpre_sale_start_date"` 64 | // pre_sale_end_date `json:"nullpre_sale_end_date"` 65 | // bounty_detail_url 66 | // amount_for_sale 67 | KycRequired bool `json:"kyc_required"` 68 | // whitelist_available 69 | // pre_sale_available 70 | PreSaleEnded bool `json:"pre_sale_ended"` 71 | } 72 | 73 | type Links struct { 74 | Web string `json:"web"` 75 | Blog string `json:"blog"` 76 | Github string `json:"github"` 77 | Twitter string `json:"twitter"` 78 | Facebook string `json:"facebook"` 79 | Telegram string `json:"telegram"` 80 | Whitepaper string `json:"whitepaper"` 81 | } 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Goingecko 2 | 3 | Coingecko API client for golang. 4 | 5 |
6 |
7 |