client

package
v0.1.73 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseURL               = "https://api.bybit.com"
	TestnetBaseURL        = "https://api-testnet.bybit.com"
	ApiVersion            = "v5"
	GET            Method = "GET"
	POST           Method = "POST"
)

Variables

This section is empty.

Functions

func GetCurrentTime added in v0.0.8

func GetCurrentTime() int64

Types

type Client

type Client struct {
	IsTestNet bool

	QueryParams url.Values
	// contains filtered or unexported fields
}

Client struct holds information needed for API interaction

func NewClient

func NewClient(key, secretKey string, isTestnet bool) *Client

NewClient creates a new client instance with API key, secret key, and testnet setting

func (*Client) Get

func (c *Client) Get(path string, params Params) (Response, error)

Get method performs a GET request to the specified API path with params

func (*Client) Post

func (c *Client) Post(path string, params Params) (Response, error)

Post method performs a POST request to the specified API path with params

type EndpointRateLimiter added in v0.0.10

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

func NewEndpointRateLimiter added in v0.0.10

func NewEndpointRateLimiter() *EndpointRateLimiter

func (*EndpointRateLimiter) GetLimiter added in v0.0.10

func (e *EndpointRateLimiter) GetLimiter(endpointKey string) *rate.Limiter

GetLimiter retrieves an existing rate limiter for an endpoint, returning nil if not found

func (*EndpointRateLimiter) SetLimiter added in v0.0.10

func (e *EndpointRateLimiter) SetLimiter(endpointKey string, limiter *rate.Limiter)

SetLimiter updates or creates a rate limiter for a specific endpoint

type Method

type Method string

Define HTTP method types as strings

type Params

type Params map[string]interface{}

Params represents parameters for the API request

type Request

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

Request struct represents an HTTP request with method, path, and params

type Requester

type Requester interface {
	Get(path string, params Params) (Response, error)
	Post(path string, params Params) (Response, error)
}

Requester interface defines methods for making HTTP GET and POST requests

type Response

type Response interface {
	Unmarshal(v interface{}) error
	Data() []byte
	Status() string
	StatusCode() int
	Error() error
}

func NewResponse

func NewResponse(response *http.Response) Response

type ResponseImpl

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

func (*ResponseImpl) Data

func (r *ResponseImpl) Data() []byte

func (*ResponseImpl) Error

func (r *ResponseImpl) Error() error

func (*ResponseImpl) Status

func (r *ResponseImpl) Status() string

func (*ResponseImpl) StatusCode

func (r *ResponseImpl) StatusCode() int

func (*ResponseImpl) Unmarshal

func (r *ResponseImpl) Unmarshal(v interface{}) error

Jump to

Keyboard shortcuts

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