bitkubsdk

package module
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: MIT Imports: 14 Imported by: 1

README

Bitkub-SDK

Bitkub-SDK is bitkub public api wrapper. Bitkub public API official document here.. this lib. support all functions in Bitkub public-API and is easy to use.

Bitkub-SDK Develop from GoLang.

Usage

package main

import (
	"github.com/naruebaet/bitkubsdk"
	"log"
)

func main() {
	// init bitkub sdk and set watch currency for websocket.
	bksdk := bitkubsdk.NewBitkub("xxx", "xxx", "THB_BTC", "THB_ETH")
	resp, err := bksdk.GetSymbols()
	if err != nil {
		log.Fatal(err)
	}

	log.Println(resp)
}

Websocket connection

package main

import (
	"context"
	"fmt"
	"github.com/gorilla/websocket"
	"github.com/naruebaet/bitkubsdk"
	"log"
	"time"
)

const ColorRed = "\033[31m"
const ColorYellow = "\033[33m"

func main() {
	bksdk := bitkubsdk.NewBitkub("xxx", "xxx", "THB_BTC", "THB_ETH")

	ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
	bksdk.WatchTicker(ctx, func(conn *websocket.Conn) { // WatchTicker will stream data from symbols. 
		defer conn.Close()
		for {
			_, msg, err := conn.ReadMessage()
			if err != nil {
				log.Println(ColorRed, "read : ", err)
				return
			}

			fmt.Println(ColorYellow, string(msg))
		}
	})
}

Convert error code to message

func main() {
	// init bitkub sdk and set watch currency for websocket.
	bksdk := bitkubsdk.NewBitkub("xxx", "xxx", "THB_BTC", "THB_ETH")
	resp, err := bksdk.GetSymbols()
	if err != nil {
		log.Fatal(err)
	}

	log.Println(bitkubsdk.ErrorText(resp.Error)) // will response error message. example: Invalid API key
}

Public function

  • GetServerStatus
  • GetServerTime
  • GetSymbols
  • GetTicker
  • GetTrades
  • GetBids
  • GetAsks
  • GetBooks
  • GetTradingview
  • GetDepth

Authorize function

  • Wallet
  • Balance
  • PlaceBid
  • PlaceAsk
  • PlaceAskByFiat
  • CancelOrder
  • MyOpenOrder
  • MyOrderHistory
  • OrderInfo
  • Addresses
  • Withdraw
  • DepositHistory
  • WithDrawHistory
  • GenerateAddress
  • FiatAccounts
  • FiatWithdraw
  • FiatDepositHistory
  • FiatWithdrawHistory
  • WsToken
  • UserLimit
  • TradingCredit

websocket function

  • WatchTicker
  • WatchTrade

free for all.

  • have fun with my sdk.

Our team website

Geek7Stack

Buy me coffee...

if you like it plaese support me with your XRP xrp-address

Documentation

Index

Constants

View Source
const (
	NoError                    = 0
	InvalidJson                = 1
	MissingApiKey              = 2
	InvalidApiKey              = 3
	ApiPendingActive           = 4
	IPNotAllowed               = 5
	MissingOrInvalidSignature  = 6
	MissingTimestamp           = 7
	InvalidTimestamp           = 8
	InvalidUser                = 9
	InvalidParameter           = 10
	InvalidSymbol              = 11
	InvalidAmount              = 12
	InvalidRate                = 13
	ImproperRate               = 14
	AmountTooLow               = 15
	FailedToGetBalance         = 16
	WalletIsEmpty              = 17
	InsufficientBalance        = 18
	FailedToInsertOrder        = 19
	FailedToDeductBalance      = 20
	InvalidOrderForCancel      = 21
	InvalidSide                = 22
	FailedToUpdateOrder        = 23
	InvalidOrderForLookup      = 24
	KycRequire                 = 25
	LimitExceeds               = 30
	PendingWithdraw            = 40
	InvalidCurrency            = 41
	AddressNotWhitelist        = 42
	FailedToDeductCrypto       = 43
	FailedToCreateWithdraw     = 44
	NonceHasToBeNumeric        = 45
	InvalidNonce               = 46
	WithdrawalLimitExceeds     = 47
	InvalidBankAccount         = 48
	BankLimitExceeds           = 49
	PendingWithdrawal          = 50
	WithdrawalUnderMaintenance = 51
	InvalidPermission          = 52
	InvalidInternalAddress     = 53
	AddressDeprecated          = 54
	ServerError                = 90
)
View Source
const ApiHost = "https://api.bitkub.com"

Variables

This section is empty.

Functions

func ErrorText

func ErrorText(code int) string

ErrorText : get bkerr text from bkerr code

func NewBitkub

func NewBitkub(apiKey string, apiSecret string, symbols ...string) repository.Client

Types

This section is empty.

Directories

Path Synopsis
src

Jump to

Keyboard shortcuts

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