cryptocomparego

package module
v0.0.0-...-cd2010e Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 16 Imported by: 0

README

Build Status GoDoc Go Report Card Coverage Status Average time to resolve an issue Percentage of issues still open

Cryptocomparego

Cryptocomparego is a Golang client library for accessing the Cryptocompare API.

You can view the client API docs here: http://godoc.org/github.com/lucazulian/cryptocomparego

You can view Cryptocompare API docs here: https://www.cryptocompare.com/api/

Usage

import "github.com/lucazulian/cryptocomparego"

Examples

To get general info for all the coins available:

ctx := context.TODO()

client := cryptocomparego.NewClient(nil)
coinList, _, err := client.Coin.List(ctx)

if err != nil {
    fmt.Printf("Something bad happened: %s\n", err)
    return err
}

Contributing

We love pull requests! Please see the contribution guidelines.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

func ReadAndAssignResponseBody

func ReadAndAssignResponseBody(res *http.Response) (io.Reader, error)

Types

type Client

type Client struct {
	BaseURL *url.URL

	MinURL *url.URL

	UserAgent string

	Coin CoinService

	Price PriceService

	PriceMulti PriceMultiService

	PriceMultiFull PriceMultiFullService

	SocialStats SocialStatsService

	Histoday HistodayService

	Histohour HistohourService

	Histomin HistominuteService

	HistohourSocialStats HistohourSocialStatsService
	// contains filtered or unexported fields
}

func New

func New(httpClient *http.Client, opts ...ClientOpt) (*Client, error)

func NewClient

func NewClient(httpClient *http.Client) *Client

func (*Client) Do

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

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method string, baseUrl url.URL, urlStr string, body interface{}) (*http.Request, error)

func (*Client) OnRequestCompleted

func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)

type ClientOpt

type ClientOpt func(*Client) error

func SetBaseURL

func SetBaseURL(bu string) ClientOpt

func SetUserAgent

func SetUserAgent(ua string) ClientOpt

type CodeRepository

type CodeRepository struct {
	List   []CodeRepositoryItem `json:"List"`
	Points int                  `json:"Points"`
}

type CodeRepositoryItem

type CodeRepositoryItem struct {
	Stars             int    `json:"stars"`
	Language          string `json:"language"`
	Forks             int    `json:"forks"`
	OpenTotalIssues   string `json:"open_total_issues"`
	Subscribers       int    `json:"subscribers"`
	Size              string `json:"size"`
	Url               string `json:"url"`
	LastUpdate        string `json:"last_update"`
	LastPush          string `json:"last_push"`
	CreatedAt         string `json:"created_at"`
	Fork              bool   `json:"fork,string"`
	Source            Source `json:"source"`
	Parent            Source `json:"parent"`
	OpenPullIssues    string `json:"open_pull_issues"`
	ClosedPullIssues  string `json:"closed_pull_issues"`
	ClosedTotalIssues string `json:"closed_total_issues"`
	OpenIssues        string `json:"open_issues"`
	ClosedIssues      string `json:"closed_issues"`
}

type Coin

type Coin struct {
	Id        string `json:"Id"`
	Url       string `json:"Url"`
	ImageUrl  string `json:"ImageUrl"`
	Name      string `json:"Name"`
	Symbol    string `json:"Symbol"`
	CoinName  string `json:"CoinName"`
	FullName  string `json:"FullName"`
	Algorithm string `json:"Algorithm"`
	ProofType string `json:"ProofType"`
	SortOrder string `json:"SortOrder"`
}

type CoinNamesSorter

type CoinNamesSorter []Coin

TODO try to remove Sorter duplication

func (CoinNamesSorter) Len

func (a CoinNamesSorter) Len() int

func (CoinNamesSorter) Less

func (a CoinNamesSorter) Less(i, j int) bool

func (CoinNamesSorter) Swap

func (a CoinNamesSorter) Swap(i, j int)

type CoinService

type CoinService interface {
	List(context.Context) ([]Coin, *Response, error)
}

type CoinServiceOp

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

func (*CoinServiceOp) List

func (s *CoinServiceOp) List(ctx context.Context) ([]Coin, *Response, error)

type CryptoCompare

type CryptoCompare struct {
	SimilarItems        []SimilarItem        `json:"SimilarItems"`
	CryptopianFollowers []CryptopianFollower `json:"CryptopianFollowers"`
	Comments            string               `json:"Comments"`
	Points              int                  `json:"Points"`
	Posts               string               `json:"Posts"`
	Followers           int                  `json:"Followers"`
	PageViewsSplit      PageViewsSplit       `json:"PageViewsSplit"`
	PageViews           int                  `json:"PageViews"`
}

type CryptopianFollower

type CryptopianFollower struct {
	Id       int    `json:"Id"`
	Name     string `json:"Name"`
	ImageUrl string `json:"ImageUrl"`
	Url      string `json:"Url"`
	Type     string `json:"Type"`
}

type ErrorResponse

type ErrorResponse struct {
	Response  *http.Response
	Message   string `json:"message"`
	RequestID string `json:"request_id"`
}

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Facebook

type Facebook struct {
	Likes        int    `json:"likes"`
	IsClosed     bool   `json:"is_closed,string"`
	TalkingAbout string `json:"talking_about"`
	Name         string `json:"name"`
	Link         string `json:"link"`
	Points       int    `json:"Points"`
}

type General

type General struct {
	Name     string      `json:"Name"`
	CoinName interface{} `json:"CoinName"`
	Type     interface{} `json:"Type"`
	Points   int         `json:"Points"`
}

type Histoday

type Histoday struct {
	Time       int64   `json:"time"`
	Close      float64 `json:"close"`
	High       float64 `json:"high"`
	Low        float64 `json:"low"`
	Open       float64 `json:"open"`
	VolumeFrom float64 `json:"volumefrom"`
	VolumeTo   float64 `json:"volumeto"`
}

type HistodayRequest

type HistodayRequest struct {
	Fsym          string
	Tsym          string
	E             string
	ExtraParams   string
	Sign          bool
	TryConversion bool
	Aggregate     int // Not Used For Now
	Limit         int
	ToTs          time.Time // Not Used For Now
	AllData       bool
}

func NewHistodayRequest

func NewHistodayRequest(fsym string, tsym string, limitDays int, allData bool) *HistodayRequest

func (*HistodayRequest) FormattedQueryString

func (hr *HistodayRequest) FormattedQueryString(baseUrl string) string

type HistodayService

type HistodayService interface {
	Get(context.Context, *HistodayRequest) ([]Histoday, *Response, error)
}

Get the history kline data of any cryptocurrency in any other currency that you need.

type HistodayServiceOp

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

func (*HistodayServiceOp) Get

func (s *HistodayServiceOp) Get(ctx context.Context, histodayRequest *HistodayRequest) ([]Histoday, *Response, error)

type Histohour

type Histohour struct {
	Time       int64   `json:"time"`
	Close      float64 `json:"close"`
	High       float64 `json:"high"`
	Low        float64 `json:"low"`
	Open       float64 `json:"open"`
	VolumeFrom float64 `json:"volumefrom"`
	VolumeTo   float64 `json:"volumeto"`
}

type HistohourRequest

type HistohourRequest struct {
	Fsym          string
	Tsym          string
	E             string
	ExtraParams   string
	Sign          bool
	TryConversion bool
	Aggregate     int // Not Used For Now
	Limit         int
	ToTs          time.Time
}

func NewHistohourRequest

func NewHistohourRequest(fsym string, tsym string, limit int, fromTime time.Time) *HistohourRequest

func (*HistohourRequest) FormattedQueryString

func (hr *HistohourRequest) FormattedQueryString(baseUrl string) string

type HistohourResponse

type HistohourResponse struct {
	Response          string         `json:"Response"`
	Message           string         `json:"Message"` // Error Message
	Type              int            `json:"Type"`
	Aggregated        bool           `json:"Aggregated"`
	Data              []Histohour    `json:"Data"`
	TimeTo            int64          `json:"TimeTo"`
	TimeFrom          int64          `json:"TimeFrom"`
	FirstValueInArray bool           `json:"FirstValueInArray"`
	ConversionType    conversionType `json:"ConversionType"`
}

type HistohourService

type HistohourService interface {
	Get(context.Context, *HistohourRequest) (*HistohourResponse, *Response, error)
}

Get the history kline data of any cryptocurrency in any other currency that you need.

type HistohourServiceOp

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

func (*HistohourServiceOp) Get

func (s *HistohourServiceOp) Get(ctx context.Context, histohourRequest *HistohourRequest) (*HistohourResponse, *Response, error)

type HistohourSocialStats

type HistohourSocialStats struct {
	Time                     int64   `json:"time"`
	Comments                 int64   `json:"comments"`
	Posts                    int64   `json:"posts"`
	Followers                int64   `json:"followers"`
	Points                   int64   `json:"points"`
	OverviewPageViews        int64   `json:"overview_page_views"`
	AnalysisPageViews        int64   `json:"analysis_page_views"`
	MarketsPageViews         int64   `json:"markets_page_views"`
	ChartsPageViews          int64   `json:"charts_page_views"`
	TradesPageViews          int64   `json:"trades_page_views"`
	ForumPageViews           int64   `json:"forum_page_views"`
	InfluencePageViews       int64   `json:"influence_page_views"`
	TotalPageViews           int64   `json:"total_page_views"`
	FbLikes                  int64   `json:"fb_likes"`
	FbTalkingAbout           int64   `json:"fb_talking_about"`
	TwitterFollowers         int64   `json:"twitter_followers"`
	TwitterFollowing         int64   `json:"twitter_following"`
	TwitterLists             int64   `json:"twitter_lists"`
	TwitterFavourites        int64   `json:"twitter_favourites"`
	TwitterStatuses          int64   `json:"twitter_statuses"`
	RedditSubscribers        int64   `json:"reddit_subscribers"`
	RedditActiveUsers        int64   `json:"reddit_active_users"`
	RedditPostsPerHour       float64 `json:"reddit_posts_per_hour"`
	RedditPostsPerDay        float64 `json:"reddit_posts_per_day"`
	RedditCommentsPerHour    float64 `json:"reddit_comments_per_hour"`
	RedditCommentsPerDay     float64 `json:"reddit_comments_per_day"`
	CodeRepoStars            int64   `json:"code_repo_stars"`
	CodeRepoForks            int64   `json:"code_repo_forks"`
	CodeRepoSubscribers      int64   `json:"code_repo_subscribers"`
	CodeRepoOpenPullIssues   int64   `json:"code_repo_open_pull_issues"`
	CodeRepoClosedPullIssues int64   `json:"code_repo_closed_pull_issues"`
	CodeRepoOpenIssues       int64   `json:"code_repo_open_issues"`
	CodeRepoClosedIssues     int64   `json:"code_repo_closed_issues"`
}

type HistohourSocialStatsRequest

type HistohourSocialStatsRequest struct {
	CoinId      int
	Limit       int
	ToTs        time.Time
	ExtraParams string
	Sign        bool

	Aggregate                       int // Not Used For Now
	AggregatePredictableTimePeriods bool
}

func NewHistohourSocialStatsRequest

func NewHistohourSocialStatsRequest(coinId int, limit int, toTs time.Time) *HistohourSocialStatsRequest

func (*HistohourSocialStatsRequest) FormattedQueryString

func (hr *HistohourSocialStatsRequest) FormattedQueryString(baseUrl string) string

type HistohourSocialStatsResponse

type HistohourSocialStatsResponse struct {
	Response   string                 `json:"Response"`
	Message    string                 `json:"Message"` // Error Message
	HasWarning bool                   `json:"HasWarning"`
	Type       int                    `json:"Type"`
	Data       []HistohourSocialStats `json:"Data,omitempty"`
}

type HistohourSocialStatsService

type HistohourSocialStatsService interface {
	Get(context.Context, *HistohourSocialStatsRequest) (*HistohourSocialStatsResponse, *Response, error)
}

type HistohourSocialStatsServiceOp

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

func (*HistohourSocialStatsServiceOp) Get

type Histominute

type Histominute struct {
	Time       int64   `json:"time"`
	Close      float64 `json:"close"`
	High       float64 `json:"high"`
	Low        float64 `json:"low"`
	Open       float64 `json:"open"`
	VolumeFrom float64 `json:"volumefrom"`
	VolumeTo   float64 `json:"volumeto"`
}

type HistominuteRequest

type HistominuteRequest struct {
	Fsym          string
	Tsym          string
	E             string
	ExtraParams   string
	Sign          bool
	TryConversion bool
	Aggregate     int // Not Used For Now
	Limit         int
	ToTs          int64
}

func NewHistominuteRequest

func NewHistominuteRequest(fsym string, tsym string, limitMinutes int, fromTime int64) *HistominuteRequest

func (*HistominuteRequest) FormattedQueryString

func (hr *HistominuteRequest) FormattedQueryString(baseUrl string) string

type HistominuteResponse

type HistominuteResponse struct {
	Response          string         `json:"Response"`
	Message           string         `json:"Message"` // Error Message
	Type              int            `json:"Type"`
	Aggregated        bool           `json:"Aggregated"`
	Data              []Histominute  `json:"Data"`
	TimeTo            int64          `json:"TimeTo"`
	TimeFrom          int64          `json:"TimeFrom"`
	FirstValueInArray bool           `json:"FirstValueInArray"`
	ConversionType    conversionType `json:"ConversionType"`
}

type HistominuteService

type HistominuteService interface {
	Get(context.Context, *HistominuteRequest) (*HistominuteResponse, *Response, error)
}

Get the history kline data of any cryptocurrency in any other currency that you need.

type HistominuteServiceOp

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

func (*HistominuteServiceOp) Get

type PageViewsSplit

type PageViewsSplit struct {
	Overview  int `json:"Overview"`
	Markets   int `json:"Markets"`
	Analysis  int `json:"Analysis"`
	Charts    int `json:"Charts"`
	Trades    int `json:"Trades"`
	Forum     int `json:"Forum"`
	Influence int `json:"Influence"`
}

type Price

type Price struct {
	Name  string
	Value float64
}

type PriceFull

type PriceFull struct {
	Type string `json:"TYPE"`
}

type PriceMulti

type PriceMulti struct {
	Name  string
	Value []Price
}

type PriceMultiFull

type PriceMultiFull struct {
	Raw     map[string]map[string]PriceMultiFullAgg `json:"RAW"`
	Display map[string]map[string]PriceMultiFullAgg `json:"DISPLAY"`
}

type PriceMultiFullAgg

type PriceMultiFullAgg struct {
	Agg map[string]PriceFull
}

type PriceMultiFullService

type PriceMultiFullService interface {
	List(context.Context, *PriceMultiRequest) ([]PriceMultiFull, *Response, error)
}

Get all the current trading info (price, vol, open, high, low etc) of any list of cryptocurrencies in any other currency that you need. If the crypto does not trade directly into the toSymbol requested, BTC will be used for conversion. This API also returns Display values for all the fields.If the oposite pair trades we invert it (eg.: BTC-XMR)".

type PriceMultiFullServiceOp

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

func (*PriceMultiFullServiceOp) List

func (s *PriceMultiFullServiceOp) List(ctx context.Context, priceMultiRequest *PriceMultiRequest) ([]PriceMultiFull, *Response, error)

type PriceMultiNameSorter

type PriceMultiNameSorter []PriceMulti

TODO try to remove Sorter duplication

func (PriceMultiNameSorter) Len

func (a PriceMultiNameSorter) Len() int

func (PriceMultiNameSorter) Less

func (a PriceMultiNameSorter) Less(i, j int) bool

func (PriceMultiNameSorter) Swap

func (a PriceMultiNameSorter) Swap(i, j int)

type PriceMultiRequest

type PriceMultiRequest struct {
	Fsyms         []string
	Tsyms         []string
	E             string
	ExtraParams   string
	Sign          bool
	TryConversion bool
}

func NewPriceMultiFullRequest

func NewPriceMultiFullRequest(fsyms []string, tsyms []string) *PriceMultiRequest

func NewPriceMultiRequest

func NewPriceMultiRequest(fsyms []string, tsyms []string) *PriceMultiRequest

func (*PriceMultiRequest) FormattedQueryString

func (pr *PriceMultiRequest) FormattedQueryString(baseUrl string) string

type PriceMultiService

type PriceMultiService interface {
	List(context.Context, *PriceMultiRequest) ([]PriceMulti, *Response, error)
}

Same as single API path but with multiple from symbols.

type PriceMultiServiceOp

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

func (*PriceMultiServiceOp) List

func (s *PriceMultiServiceOp) List(ctx context.Context, priceMultiRequest *PriceMultiRequest) ([]PriceMulti, *Response, error)

type PriceNameSorter

type PriceNameSorter []Price

TODO try to remove Sorter duplication

func (PriceNameSorter) Len

func (a PriceNameSorter) Len() int

func (PriceNameSorter) Less

func (a PriceNameSorter) Less(i, j int) bool

func (PriceNameSorter) Swap

func (a PriceNameSorter) Swap(i, j int)

type PriceRequest

type PriceRequest struct {
	Fsym          string
	Tsyms         []string
	E             string
	ExtraParams   string
	Sign          bool
	TryConversion bool
}

func NewPriceRequest

func NewPriceRequest(fsym string, tsyms []string) *PriceRequest

func (*PriceRequest) FormattedQueryString

func (pr *PriceRequest) FormattedQueryString(baseUrl string) string

type PriceService

type PriceService interface {
	List(context.Context, *PriceRequest) ([]Price, *Response, error)
}

Get the current price of any cryptocurrency in any other currency that you need. If the crypto does not trade directly into the toSymbol requested, BTC will be used for conversion. If the oposite pair trades we invert it (eg.: BTC-XMR).

type PriceServiceOp

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

func (*PriceServiceOp) List

func (s *PriceServiceOp) List(ctx context.Context, priceRequest *PriceRequest) ([]Price, *Response, error)

type Reddit

type Reddit struct {
	Subscribers       int     `json:"subscribers"`
	ActiveUsers       int     `json:"active_users"`
	CommunityCreation string  `json:"community_creation"`
	PostsPerHour      float64 `json:"posts_per_hour,string"`
	PostsPerDay       float64 `json:"posts_per_day,string"`
	CommentsPerHour   float64 `json:"comments_per_hour,string"`
	CommentsPerDay    float64 `json:"comments_per_day"`
	Link              string  `json:"link"`
	Name              string  `json:"name"`
	Points            int     `json:"Points"`
}

type RequestCompletionCallback

type RequestCompletionCallback func(*http.Request, *http.Response)

type Response

type Response struct {
	*http.Response

	Monitor string
}

type SimilarItem

type SimilarItem struct {
	Id            int    `json:"Id"`
	Name          string `json:"Name"`
	FullName      string `json:"FullName"`
	ImageUrl      string `json:"ImageUrl"`
	Url           string `json:"Url"`
	FollowingType int    `json:"FollowingType"`
}

type SocialStats

type SocialStats struct {
	General        General        `json:"General"`
	CryptoCompare  CryptoCompare  `json:"CryptoCompare"`
	Twitter        Twitter        `json:"Twitter"`
	Reddit         Reddit         `json:"Reddit"`
	Facebook       Facebook       `json:"Facebook"`
	CodeRepository CodeRepository `json:"CodeRepository"`
}

type SocialStatsService

type SocialStatsService interface {
	Get(context.Context, int) (*SocialStats, *Response, error)
}

type SocialStatsServiceOp

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

func (*SocialStatsServiceOp) Get

func (s *SocialStatsServiceOp) Get(ctx context.Context, coinExchangeId int) (*SocialStats, *Response, error)

type Source

type Source struct {
	Name       string `json:"Name"`
	Url        string `json:"Url"`
	InternalId int    `json:"InternalId"`
}

type Twitter

type Twitter struct {
	Followers       int    `json:"followers"`
	Following       string `json:"following"`
	Lists           int    `json:"lists"`
	Favourites      string `json:"favourites"`
	Statuses        int    `json:"statuses"`
	AccountCreation string `json:"account_creation"`
	Name            string `json:"name"`
	Link            string `json:"link"`
	Points          int    `json:"Points"`
}

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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