bitkub-connector

module
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: MIT

README

Bitkub Connector

This is the Bitkub connector that updated to Bitkub's official specs as of October 11, 2021.

Bitkub official website https://www.bitkub.com

Bitkub official API documentation https://api.bitkub.com

Usage

For example, you need to get report of your history order.

package main

import (
    "encoding/json"
    "log"

    bitkubconnector "github.com/dewwed/bitkub-connector/v1"
)

func main() {
    bitkub, err := bitkubconnector.New(bitkubconnector.Config{
        // Required
        ApiKey:    "YOUR_API_KEY",
        ApiSecret: "YOUR_API_SECRET",

        // Optional
        UserAgent: "...",
    })
    if err != nil {
        panic(fmt.Sprintf("Cannot create new bitkubconnector instance: %s", err))
    }

    sym := "THB_BTC"
    page := 1
    limit := 0 // 0, if want to ignore this argument
    start := 0 // 0, if want to ignore this argument
    end := 0   // 0, if want to ignore this argument

    // Get my order history
    myOrderHis, err := bitkub.MarketMyOrderHistory(sym, page, limit, start, end)
    if err != nil {
        log.Fatalf("Cannot get my order history: %s", err)
    }

    // Check response is error
    isRespErr, err := bitkubconnector.IsResponseError(myOrderHis)
    if err != nil {
        log.Fatalf("Cannot check error from response: %s", err)
    }

    // A response is not error
    if !isRespErr {
        myOrderHisResult := new(bitkubconnector.MarketMyOrderHistory)
        json.Unmarshal(myOrderHis.Body, myOrderHisResult)

        log.Printf("myOrderHisResult: %+v\n", myOrderHisResult)
        // myOrderHisResult: &{Error:0 Result:[{TxnID:... OrderID:... Hash:... ...}, {...}] Pagination:{Page:... Last:... Next:... Prev:...}}
    }
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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