Documentation ¶
Index ¶
- func PrettyStruct(data interface{}) (string, error)
- type SDK
- func (bksdk *SDK) Balances() (response.Balances, error)
- func (bksdk *SDK) CancelOrder(sym, id, sd, hash string) (response.CancelOrder, error)
- func (bksdk *SDK) CryptoAddresses(page, limit int) (response.CryptoAddresses, error)
- func (bksdk *SDK) CryptoDepositHistory(page, limit int) (response.DepositHistory, error)
- func (bksdk *SDK) CryptoGenerateAddress(symbol string) (response.CryptoGenerateAddress, error)
- func (bksdk *SDK) CryptoInternalWithdraw(currency string, address string, memo string, amount float64) (response.InternalWithdraw, error)
- func (bksdk *SDK) CryptoWithdraw(currency string, address string, memo string, amount float64, network string) (response.CryptoWithdraw, error)
- func (bksdk *SDK) CryptoWithdrawHistory(page, limit int) (response.WithdrawHistory, error)
- func (bksdk *SDK) FiatAccounts(page int, limit int) (response.FiatAccounts, error)
- func (bksdk *SDK) FiatDepositHistory(page, limit int) (response.FiatDepositHistory, error)
- func (bksdk *SDK) FiatWithdraw(id string, amt float64) (response.FiatWithdraw, error)
- func (bksdk *SDK) FiatWithdrawHistory(page, limit int) (response.FiatWithdrawHistory, error)
- func (bksdk *SDK) GetAsks(sym string, limit int) (response.MarketAsks, error)
- func (bksdk *SDK) GetBids(sym string, limit int) (response.MarketBids, error)
- func (bksdk *SDK) GetBooks(sym string, limit int) (response.MarketBooks, error)
- func (bksdk *SDK) GetDepth(sym string, limit int) (response.MarketDepth, error)
- func (bksdk *SDK) GetHistory(symbol string, resolution string, from int, to int) (response.TradingviewHistory, error)
- func (bksdk *SDK) GetServerTime() (string, error)
- func (bksdk *SDK) GetStatus() (response.Status, error)
- func (bksdk *SDK) GetSymbols() (response.MarketSymbols, error)
- func (bksdk *SDK) GetTicker(sym string) (response.MarketTicker, error)
- func (bksdk *SDK) GetTrade(sym string, limit int) (response.MarketTrades, error)
- func (bksdk *SDK) Limits() (response.Limits, error)
- func (bksdk *SDK) MyOpenOrder(sym string) (response.MyOpenOrder, error)
- func (bksdk *SDK) MyOrderHistory(sym string, page, limit, start, end int) (response.MyOrderHistory, error)
- func (bksdk *SDK) OrderInfo(sym, orderId, side string) (response.OrderInfo, error)
- func (bksdk *SDK) OrderInfoByHash(hash string) (response.OrderInfo, error)
- func (bksdk *SDK) PlaceAsk(sym string, amt, rat float64, typ, client_id string) (response.PlaceAsk, error)
- func (bksdk *SDK) PlaceBid(sym string, amt, rat float64, typ, client_id string) (response.PlaceBid, error)
- func (bksdk *SDK) TradingCredit() (response.TradingCredit, error)
- func (bksdk *SDK) Wallet() (response.Wallet, error)
- func (bksdk *SDK) WsToken() (response.WsToken, error)
- type SDKEndpoints
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrettyStruct ¶
PrettyStruct prints a pretty JSON representation of a struct. It takes in a `data` interface{} parameter and returns a string representation of the JSON. If there is an error during the marshaling process, it returns an empty string and the error.
Types ¶
type SDK ¶
type SDK struct {
// contains filtered or unexported fields
}
func (*SDK) Balances ¶ added in v1.2.0
Balance returns the balances information, including both available and reserved balances.
Endpoint: /api/v3/market/balances Method: POST Parameter: N/A
func (*SDK) CancelOrder ¶
func (bksdk *SDK) CancelOrder(sym, id, sd, hash string) (response.CancelOrder, error)
Endpoint: /api/v3/market/cancel-order Method: POST Desc: Cancel an open order Parameters: - sym string The symbol. Please note that the current endpoint requires the symbol thb_btc. However, it will be changed to btc_thb soon and you will need to update the configurations accordingly for uninterrupted API functionality. - id string Order id you wish to cancel - sd string Order side: buy or sell - hash string Cancel an order with order hash (optional). You don't need to specify sym, id, and sd when you specify order hash.
func (*SDK) CryptoAddresses ¶ added in v1.2.0
func (bksdk *SDK) CryptoAddresses(page, limit int) (response.CryptoAddresses, error)
Addresses is a function that lists all crypto addresses. It sends a POST request to the /api/v3/crypto/addresses endpoint with optional pagination parameters (page and limit). It returns a response containing the crypto addresses and an error, if any.
func (*SDK) CryptoDepositHistory ¶ added in v1.2.0
func (bksdk *SDK) CryptoDepositHistory(page, limit int) (response.DepositHistory, error)
DepositHistory returns a list of crypto deposit history. It sends a POST request to the /api/v3/crypto/deposit-history endpoint. Parameters: - page: int, optional page number - limit: int, optional limit per page Returns: - response.DepositHistory: the deposit history response - error: any error that occurred during the request
func (*SDK) CryptoGenerateAddress ¶ added in v1.2.0
func (bksdk *SDK) CryptoGenerateAddress(symbol string) (response.CryptoGenerateAddress, error)
GenerateAddress generates a new crypto address for the given symbol. The previous address can still be used to receive funds. It makes a POST request to the /api/v3/crypto/generate-address endpoint.
Parameters: - symbol: The symbol for which to generate the address (e.g. THB_BTC, THB_ETH, etc.)
Returns: - response: The generated address and other relevant information. - error: An error if the request fails or if there is an issue parsing the response.
func (*SDK) CryptoInternalWithdraw ¶ added in v1.2.0
func (bksdk *SDK) CryptoInternalWithdraw(currency string, address string, memo string, amount float64) (response.InternalWithdraw, error)
InternalWithdraw makes a withdrawal to an internal address. The destination address does not need to be a trusted address. This API is not enabled by default. Only KYB users can request this feature by contacting us via support@bitkub.com.
func (*SDK) CryptoWithdraw ¶ added in v1.2.0
func (bksdk *SDK) CryptoWithdraw(currency string, address string, memo string, amount float64, network string) (response.CryptoWithdraw, error)
Withdraw makes a withdrawal to a trusted address. Endpoint: /api/v3/crypto/withdraw Method: POST Parameters:
- currency: Currency for withdrawal (e.g. BTC, ETH)
- amount: Amount you want to withdraw
- address: Address to which you want to withdraw
- memo: (Optional) Memo or destination tag to which you want to withdraw
- network: Cryptocurrency network to withdraw No default value of this field. Please find the available network from the link as follows. https://www.bitkub.com/fee/cryptocurrency For example ETH refers to ERC-20. For request on ERC-20, please assign the network value as ETH. For request on BEP-20, please assign the network value as BSC. For request on KAP-20, please assign the network value as BKC.
Returns: - response: The response body with the withdrawal details - error: An error if the withdrawal request fails
func (*SDK) CryptoWithdrawHistory ¶ added in v1.2.0
func (bksdk *SDK) CryptoWithdrawHistory(page, limit int) (response.WithdrawHistory, error)
WithdrawHistory returns a list of crypto withdraw history. It sends a POST request to the /api/v3/crypto/withdraw-history endpoint. Parameters: - page: int, optional page number - limit: int, optional limit per page Returns: - response.WithdrawHistory: the withdraw history response - error: any error that occurred during the request
func (*SDK) FiatAccounts ¶ added in v1.2.0
Accounts lists all approved bank accounts.
Parameters: - page: int, Page number (optional) - limit: int, Limit number of results (optional)
Returns: - response.FiatAccounts: List of approved bank accounts - error: Error if any occurs
func (*SDK) FiatDepositHistory ¶ added in v1.2.0
func (bksdk *SDK) FiatDepositHistory(page, limit int) (response.FiatDepositHistory, error)
Endpoint: /api/v3/fiat/deposit-history Method: POST Desc: List fiat deposit history Parameters: - p int Page (optional) - lmt int Limit (optional) Function: FiatDepositHistory retrieves the fiat deposit history using the specified page and limit. It returns a response object containing the deposit history and an error if any.
func (*SDK) FiatWithdraw ¶ added in v1.2.0
FiatWithdraw makes a withdrawal to an approved bank account. It sends a POST request to the /api/v3/fiat/withdraw endpoint. Parameters: - id: string, the bank account id - amt: float64, the amount to withdraw Returns: - response.FiatWithdraw: the response body - error: any error that occurred during the request
func (*SDK) FiatWithdrawHistory ¶ added in v1.2.0
func (bksdk *SDK) FiatWithdrawHistory(page, limit int) (response.FiatWithdrawHistory, error)
FiatWithdrawHistory retrieves the list of fiat withdrawal history.
Parameters: - page: Page number (optional) - limit: Limit number (optional)
Returns: - response.FiatWithdrawHistory: The response body containing the fiat withdrawal history - error: Any error that occurred during the API request
func (*SDK) GetAsks ¶
GetAsks retrieves a list of open sell orders for a given symbol with a specified limit. It makes a GET request to the /api/market/asks endpoint. Returns the response body as a MarketAsks struct and any error encountered.
func (*SDK) GetBids ¶
GetBids queries the /api/market/bids endpoint with the GET method and returns the response body containing the market bids.
Parameters: - sym: The symbol (e.g. thb_btc) - limit: The number of limit to query open buy orders
Returns: - response.MarketBids: The response body containing the market bids - error: An error if any occurred during the request or response handling
func (*SDK) GetBooks ¶
GetBooks retrieves market books for a given symbol and limit Endpoint: /api/market/books Method: GET
Query Parameters:
sym string - The symbol (e.g. thb_btc) lmt int - Number of limit to query open sell orders
func (*SDK) GetDepth ¶
GetDepth queries the /api/market/books endpoint using the GET method to retrieve market depth information.
Parameters: - sym: The symbol (e.g. thb_btc) - limit: The number of orders to query
Returns: - response.MarketDepth: The market depth response - error: Any error that occurred during the request
func (*SDK) GetHistory ¶
func (bksdk *SDK) GetHistory(symbol string, resolution string, from int, to int) (response.TradingviewHistory, error)
GetHistory retrieves trading view history for a given symbol
Endpoint: /tradingview/history Method: GET
Parameters: - symbol: string - The symbol (e.g. BTC_THB) - resolution: string - Chart resolution (1, 5, 15, 60, 240, 1D) - from: int - Timestamp of the starting time (e.g. 1633424427) - to: int - Timestamp of the ending time (e.g. 1633427427)
Returns: - response.TradingviewHistory: the trading view history - error: if there was an error retrieving the history
func (*SDK) GetServerTime ¶
GetServerTime retrieves the server time from the API. Endpoint: /api/servertime Method: GET
func (*SDK) GetSymbols ¶
func (bksdk *SDK) GetSymbols() (response.MarketSymbols, error)
GetSymbols retrieves the market symbols from the API. Endpoint: /api/market/symbols Method: GET
func (*SDK) GetTicker ¶
func (bksdk *SDK) GetTicker(sym string) (response.MarketTicker, error)
GetTicker retrieves the market ticker for a given symbol. It makes a GET request to the "/api/market/ticker" endpoint. If a symbol is provided, it is included as a query parameter. The response body is unmarshalled into a response.MarketTicker struct. If the request is successful, the response body is returned along with nil error. If any error occurs during the request or unmarshalling, the response body is empty and the error is returned.
func (*SDK) GetTrade ¶
GetTrade retrieves recent trades from the API. It makes a GET request to the /api/market/trades endpoint. Parameters: - sym: The symbol (e.g. thb_btc) - limit: No. of limit to query recent trades Returns: - response.MarketTrades: The response body containing the recent trades - error: An error if the request fails or if the response body cannot be parsed
func (*SDK) MyOpenOrder ¶
func (bksdk *SDK) MyOpenOrder(sym string) (response.MyOpenOrder, error)
MyOpenOrder retrieves a list of all open orders for a given symbol. Endpoint: /api/v3/market/my-open-orders Method: GET Parameters: - sym string: The symbol (e.g. btc_thb) Returns: - response.MyOpenOrder: The response body containing the list of open orders - error: Any error that occurred during the API call
func (*SDK) MyOrderHistory ¶
func (bksdk *SDK) MyOrderHistory(sym string, page, limit, start, end int) (response.MyOrderHistory, error)
MyOrderHistory retrieves a list of orders that have already matched.
Endpoint: /api/v3/market/my-order-history Method: GET
Parameters:
- sym: string (required) - The symbol (e.g. btc_thb)
- page: int (optional) - Page number
- limit: int (optional) - Limit per page
- start: int (optional) - Start timestamp
- end: int (optional) - End timestamp
Returns:
- response.MyOrderHistory: The response body containing the order history
- error: An error if the request fails
func (*SDK) OrderInfo ¶
OrderInfo returns information regarding the specified order. It makes a GET request to the endpoint /api/v3/market/order-info. The function takes three parameters: - sym: the symbol of the order (e.g. btc_thb) - orderId: the ID of the order - side: the side of the order: buy or sell It returns an instance of response.OrderInfo and an error, if any.
func (*SDK) OrderInfoByHash ¶
OrderInfoByHash retrieves information about the specified order. It sends a GET request to the /api/v3/market/order-info endpoint. The order is identified by its hash.
Parameters:
- hash: The hash of the order to retrieve information about.
Returns:
- response.OrderInfo: The information about the order.
- error: An error if the request fails or if there is an issue with parsing the response.
func (*SDK) PlaceAsk ¶
func (bksdk *SDK) PlaceAsk(sym string, amt, rat float64, typ, client_id string) (response.PlaceAsk, error)
PlaceAsk creates a sell order. Endpoint: /api/v3/market/place-ask Method: POST Parameters: - sym: string - The symbol you want to trade (e.g. btc_thb). - amt: float64 - Amount you want to spend with no trailing zero (e.g. 1000.00 is invalid, 1000 is ok). - rat: float64 - Rate you want for the order with no trailing zero (e.g. 1000.00 is invalid, 1000 is ok). - typ: string - Order type: limit or market (for market order, please specify rat as 0). - client_id: string - Your id for reference (not required). It returns the response body and an error (if any).
func (*SDK) PlaceBid ¶
func (bksdk *SDK) PlaceBid(sym string, amt, rat float64, typ, client_id string) (response.PlaceBid, error)
PlaceBid creates a buy order by sending a POST request to the /api/v3/market/place-bid endpoint. It takes the following parameters: - sym: string - The symbol you want to trade (e.g. btc_thb). - amt: float64 - Amount you want to spend with no trailing zero (e.g. 1000.00 is invalid, 1000 is ok). - rat: float64 - Rate you want for the order with no trailing zero (e.g. 1000.00 is invalid, 1000 is ok). - typ: string - Order type: limit or market (for market order, please specify rat as 0). - client_id: string - Your id for reference (not required).
func (*SDK) TradingCredit ¶
func (bksdk *SDK) TradingCredit() (response.TradingCredit, error)
TradingCredit retrieves the trading credit balance.
func (*SDK) Wallet ¶
Wallet retrieves the user's available balances, including both available and reserved balances. It makes a POST request to the /api/v3/market/wallet endpoint. It returns the user's wallet information and any error that occurred during the API call.
type SDKEndpoints ¶
type SDKEndpoints interface { // public endpoints GetStatus() (response.Status, error) GetServerTime() (string, error) GetSymbols() (response.MarketSymbols, error) GetTicker(sym string) (response.MarketTicker, error) GetTrade(sym string, limit int) (response.MarketTrades, error) GetBids(sym string, limit int) (response.MarketBids, error) GetAsks(sym string, limit int) (response.MarketAsks, error) GetBooks(sym string, limit int) (response.MarketBooks, error) GetDepth(sym string, limit int) (response.MarketDepth, error) GetHistory(symbol string, resolution string, from int, to int) (response.TradingviewHistory, error) // User secure endpoints TradingCredit() (response.TradingCredit, error) Limits() (response.Limits, error) // Market secure endpoints Wallet() (response.Wallet, error) Balances() (response.Balances, error) PlaceBid(sym string, amt, rat float64, typ, client_id string) (response.PlaceBid, error) PlaceAsk(sym string, amt, rat float64, typ, client_id string) (response.PlaceAsk, error) CancelOrder(sym, id, sd, hash string) (response.CancelOrder, error) WsToken() (response.WsToken, error) MyOpenOrder(sym string) (response.MyOpenOrder, error) MyOrderHistory(sym string, page, limit, start, end int) (response.MyOrderHistory, error) OrderInfo(sym, orderId, side string) (response.OrderInfo, error) OrderInfoByHash(hash string) (response.OrderInfo, error) // Crypto secure endpoints CryptoInternalWithdraw(currency string, address string, memo string, amount float64) (response.InternalWithdraw, error) CryptoAddresses(page, limit int) (response.CryptoAddresses, error) CryptoWithdraw(currency string, address string, memo string, amount float64, network string) (response.CryptoWithdraw, error) CryptoDepositHistory(page, limit int) (response.DepositHistory, error) CryptoWithdrawHistory(page, limit int) (response.WithdrawHistory, error) CryptoGenerateAddress(symbol string) (response.CryptoGenerateAddress, error) // Fiat secure endpoints FiatAccounts(page int, limit int) (response.FiatAccounts, error) FiatWithdraw(id string, amt float64) (response.FiatWithdraw, error) FiatDepositHistory(page, limit int) (response.FiatDepositHistory, error) FiatWithdrawHistory(page, limit int) (response.FiatWithdrawHistory, error) }
func New ¶
func New(apiKey, apiSecret string) SDKEndpoints
New creates a new SDK instance with the provided apiKey and apiSecret. It initializes the gorequest super agent and sets the API host URL.