Documentation ¶
Index ¶
- Constants
- Variables
- func IntToString(i int64) string
- func ToJsonString(v interface{}) string
- type ApiResponse
- type HTTPRequest
- type HTTPResponse
- type KucoinClient
- func (k *KucoinClient) GenSignature(req HTTPRequest) (map[string]string, error)
- func (k *KucoinClient) GetBaseURL() string
- func (k *KucoinClient) GetDebug() bool
- func (k *KucoinClient) GetHeaders() (map[string]string, error)
- func (k *KucoinClient) GetKey() string
- func (k *KucoinClient) GetPassphrase() string
- func (k *KucoinClient) GetSecret() string
- func (s *KucoinClient) SendHTTPRequest(ctx context.Context, req HTTPRequest) (*HTTPResponse, error)
- type KucoinClientCfg
- type PaginationModel
- type PaginationParam
Constants ¶
const ApiKeyVersionV1 = "1"
ApiKeyVersionV1 is v1 api key version
const ApiKeyVersionV2 = "2"
ApiKeyVersionV2 is v2 api key version
const (
ApiSuccess = "200000"
)
The predefined API codes
Variables ¶
var ( SpotBaseURL = "https://api.kucoin.com" FuturesBaseURL = "https://api-futures.kucoin.com" )
var NIL = "<nil>"
Functions ¶
func ToJsonString ¶
func ToJsonString(v interface{}) string
ToJsonString converts any value to JSON string.
Types ¶
type ApiResponse ¶
type ApiResponse struct { Resp *HTTPResponse Code string `json:"code"` RawData json.RawMessage `json:"data"` // delay parsing Message string `json:"msg"` }
An ApiResponse represents a API response wrapped Response.
func (*ApiResponse) ApiSuccessful ¶
func (ar *ApiResponse) ApiSuccessful() bool
ApiSuccessful judges the success of API.
func (*ApiResponse) HttpSuccessful ¶
func (ar *ApiResponse) HttpSuccessful() bool
HttpSuccessful judges the success of http.
func (*ApiResponse) ReadData ¶
func (ar *ApiResponse) ReadData(v interface{}) error
ReadData read the api response `data` as JSON into v.
func (*ApiResponse) ReadPaginationData ¶
func (ar *ApiResponse) ReadPaginationData(v interface{}) (*PaginationModel, error)
ReadPaginationData read the data `items` as JSON into v, and returns *PaginationModel.
type HTTPRequest ¶
type HTTPRequest struct { BaseURL string Path string Method string Headers map[string]string Query any Body any }
func (*HTTPRequest) RequestBody ¶
func (h *HTTPRequest) RequestBody() (string, error)
func (*HTTPRequest) RequestURI ¶
func (h *HTTPRequest) RequestURI() (string, error)
RequestURI returns the request uri.
type HTTPResponse ¶
type HTTPResponse struct { Req *HTTPRequest Resp *http.Response Body []byte }
A HTTPResponse represents a HTTP response.
func NewResponse ¶
func NewResponse( request *HTTPRequest, response *http.Response, body []byte, ) *HTTPResponse
NewResponse Creates a new Response
func (*HTTPResponse) Error ¶
func (r *HTTPResponse) Error() string
func (*HTTPResponse) ReadBody ¶
func (r *HTTPResponse) ReadBody() ([]byte, error)
ReadBody read the response data, then return it.
func (*HTTPResponse) ReadJsonBody ¶
func (r *HTTPResponse) ReadJsonBody(v interface{}) error
ReadJsonBody read the response data as JSON into v.
type KucoinClient ¶
type KucoinClient struct {
// contains filtered or unexported fields
}
func NewKucoinRestClient ¶
func NewKucoinRestClient(cfg *KucoinClientCfg) (*KucoinClient, error)
func (*KucoinClient) GenSignature ¶
func (k *KucoinClient) GenSignature(req HTTPRequest) (map[string]string, error)
func (*KucoinClient) GetBaseURL ¶
func (k *KucoinClient) GetBaseURL() string
func (*KucoinClient) GetDebug ¶
func (k *KucoinClient) GetDebug() bool
func (*KucoinClient) GetHeaders ¶
func (k *KucoinClient) GetHeaders() (map[string]string, error)
func (*KucoinClient) GetKey ¶
func (k *KucoinClient) GetKey() string
func (*KucoinClient) GetPassphrase ¶
func (k *KucoinClient) GetPassphrase() string
func (*KucoinClient) GetSecret ¶
func (k *KucoinClient) GetSecret() string
func (*KucoinClient) SendHTTPRequest ¶
func (s *KucoinClient) SendHTTPRequest(ctx context.Context, req HTTPRequest) (*HTTPResponse, error)
type KucoinClientCfg ¶
type PaginationModel ¶
type PaginationModel struct { CurrentPage int64 `json:"currentPage"` PageSize int64 `json:"pageSize"` TotalNum int64 `json:"totalNum"` TotalPage int64 `json:"totalPage"` RawItems json.RawMessage `json:"items"` // delay parsing }
A PaginationModel represents the pagination in a response.
func (*PaginationModel) ReadItems ¶
func (p *PaginationModel) ReadItems(v interface{}) error
ReadItems read the `items` into v.
type PaginationParam ¶
A PaginationParam represents the pagination parameters `currentPage` `pageSize` in a request .
func (*PaginationParam) ReadParam ¶
func (p *PaginationParam) ReadParam(params map[string]string)
ReadParam read pagination parameters into params.