coinmarketcap

package module
v0.0.0-...-37a10db Latest Latest
Warning

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

Go to latest
Published: May 10, 2018 License: MIT Imports: 8 Imported by: 0

README

go-coinmarketcap

GoDoc

Usage

import "github.com/xkitpro/go-coinmarketcap"

Construct a new CoinMarketCap client:

cmc := coinmarketcap.NewClient()
Examples
package main

import cmc "github.com/xkitpro/go-coinmarketcap"

func main() {
    cli := cmc.NewClient()
    
    global, _, err := cli.GetGlobal(context.Background(), &cmc.GetGlobalOptions{
        Convert: "EUR",
    })
    if err != nil {
        log.Fatal(err)
    }
    
    fmt.Println(global)
}

For complete usage of go-coinmarketcap, see the full package docs.

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() *Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)

func (*Client) GetGlobal

func (c *Client) GetGlobal(ctx context.Context, opt *GetGlobalOptions) (*Global, *Response, error)

func (*Client) GetTicker

func (c *Client) GetTicker(ctx context.Context, id interface{}, opt *GetTickerOptions) (*Ticker, *Response, error)

func (*Client) ListTicker

func (c *Client) ListTicker(ctx context.Context, opt *ListTickerOptions) (TickerList, *Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(path string, opt interface{}) (*http.Request, error)

type GetGlobalOptions

type GetGlobalOptions struct {
	Convert string `url:"convert,omitempty"`
}

type GetTickerOptions

type GetTickerOptions struct {
	Convert string `url:"convert,omitempty"`
}

type Global

type Global struct {
	ActiveCryptocurrencies       int                    `json:"active_cryptocurrencies"`
	ActiveMarkets                int                    `json:"active_markets"`
	BitcoinPercentageOfMarketCap float32                `json:"bitcoin_percentage_of_market_cap"`
	Quotes                       map[string]GlobalQuote `json:"quotes"`
	LastUpdated                  int                    `json:"last_updated"`
}

type GlobalQuote

type GlobalQuote struct {
	TotalMarketCap float32 `json:"total_market_cap"`
	TotalVolume24h float32 `json:"total_volume_24h"`
}

type ListTickerOptions

type ListTickerOptions struct {
	Limit   int    `url:"limit,omitempty"`
	Start   int    `url:"start,omitempty"`
	Convert string `url:"convert,omitempty"`
}

type Metadata

type Metadata struct {
	Timestamp           int     `json:"timestamp"`
	NumCryptocurrencies int     `json:"num_cryptocurrencies"`
	Error               *string `json:"error"`
}

type Response

type Response struct {
	Data     interface{} `json:"data"`
	Metadata *Metadata   `json:"metadata"`
}

type Ticker

type Ticker struct {
	ID                int                    `json:"id"`
	Name              string                 `json:"name"`
	Symbol            string                 `json:"symbol"`
	WebsiteSlug       string                 `json:"website_slug"`
	Rank              int                    `json:"rank"`
	CirculatingSupply float32                `json:"circulating_supply"`
	TotalSupply       float32                `json:"total_supply"`
	MaxSupply         float32                `json:"max_supply"`
	Quotes            map[string]TickerQuote `json:"quotes"`
	LastUpdated       int                    `json:"last_updated"`
}

type TickerList

type TickerList map[string]*Ticker

type TickerQuote

type TickerQuote struct {
	Price float64 `json:"price"`
}

Jump to

Keyboard shortcuts

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