client

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

README

cryptodatapi-go-sdk logo

cryptodatapi-go-sdk

Crypto API SDK for Golang.

Release Go Report Card Go Reference License


Getting Started

import "github.com/horisystems/cryptodatapi-go-sdk"

Dependence

Testing

Run the following command to test the package.

USER=<username> PASS=<password> go test -v

Implementation

c: = client.New()
token,ok := c.Auth("<username>", "<password>")

// For example, call an endpoint such as LivePrice
live_price := c.LivePrice()
  
// Retrieve All LivePrice Data
j, err := live_price.GetAll()

// Retrieve LivePrice Data By ID
j, err := live_price.GetById("<id>")

// Retrieve LivePrice Data By Symbol
j, err := live_price.GetBySymbol("<symbol>")

// Get API result (see simplejson)
j.Get("Code").String()
j.Get("Message").String()
j.Get("Document").Array()

Below are all the available endpoints.

c.LivePrice()
c.TopGainers()
c.TopLosers()
c.History(2021)
c.History(2022)
c.History(2023)
c.Derivatives()
c.Dex()
c.Lending()
c.Spot()
c.News()

All the endpoints listed above have five methods.

- GetAll()
- GetById(id int)
- Create(data map[string]interface{})
- UpdateById(id int, data map[string]interface{})
- DeleteById(id int)

License

This project is licensed under the BSD 3-Clause License - see the file for details.

(c) 2020 - 2023 Hori Systems Limited.

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 New

func New() *Client

func (*Client) Auth

func (c *Client) Auth(username, password string) (string, bool)

func (*Client) Derivatives

func (c *Client) Derivatives() *Resource

func (*Client) Dex

func (c *Client) Dex() *Resource

func (*Client) History

func (c *Client) History(year int) *HistoryResource

func (*Client) Lending

func (c *Client) Lending() *Resource

func (*Client) LivePrice

func (c *Client) LivePrice() *PriceResource

func (*Client) News

func (c *Client) News() *Resource

func (*Client) Spot

func (c *Client) Spot() *Resource

func (*Client) TopGainers

func (c *Client) TopGainers() *Resource

func (*Client) TopLosers

func (c *Client) TopLosers() *Resource

type HistoryResource

type HistoryResource struct {
	Resource
}

func NewHistoryResource

func NewHistoryResource(year int) *HistoryResource

func (*HistoryResource) GetBySymbol

func (r *HistoryResource) GetBySymbol(symbol string) (*simplejson.Json, error)

type HttpClient

type HttpClient struct {
	BaseURL *url.URL

	Token string
	// contains filtered or unexported fields
}

type PriceResource

type PriceResource struct {
	Resource
}

func NewPriceResource

func NewPriceResource() *PriceResource

func (*PriceResource) GetBySymbol

func (r *PriceResource) GetBySymbol(symbol string) (*simplejson.Json, error)

type Resource

type Resource struct {
	Name string
	Path string
}

func NewResource

func NewResource(name, path string) *Resource

func (*Resource) Create

func (r *Resource) Create(data map[string]interface{})

func (*Resource) DeleteById

func (r *Resource) DeleteById(id string)

func (*Resource) GetAll

func (r *Resource) GetAll() (*simplejson.Json, error)

func (*Resource) GetById

func (r *Resource) GetById(id string) (*simplejson.Json, error)

func (*Resource) UpdateById

func (r *Resource) UpdateById(id string, data map[string]interface{})

Jump to

Keyboard shortcuts

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