southxchange

package module
v0.0.0-...-7a5b64d Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 13 Imported by: 3

README

go-southxchange

go-southxchange is an implementation of the SouthXchange API (public and private) in Golang.

Import

import "github.com/bitbandi/go-southxchange"

Usage

In order to use the client with go's default http client settings you can do:

package main

import (
	"fmt"
	"github.com/bitbandi/go-southxchange"
)

const (
	API_KEY    = "YOUR_API_KEY"
	API_SECRET = "YOUR_API_SECRET"
)

func main() {
	// southxchange client
	southxchange := southxchange.New(API_KEY, API_SECRET, "user-agent")

	// Get balances
	balances, err := southxchange.GetBalances()
	fmt.Println(err, balances)
}

In order to use custom settings for the http client do:

package main

import (
	"fmt"
	"net/http"
	"time"
	"github.com/bitbandi/go-southxchange"
)

const (
	API_KEY    = "YOUR_API_KEY"
	API_SECRET = "YOUR_API_SECRET"
)

func main() {
	httpClient := &http.Client{
		Timeout: time.Second * 10,
	}

	// southxchange client
	bc := southxchange.NewWithCustomHttpClient(API_KEY, API_SECRET, "user-agent", httpClient)

	// Get balances
	balances, err := southxchange.GetBalances()
	fmt.Println(err, balances)
}

See "Examples" folder for more... examples

Documentation

Overview

Package SouthXchange is an implementation of the SouthXchange API in Golang.

Index

Constants

View Source
const (
	API_BASE = "https://www.southxchange.com/api" // SouthXchange API endpoint
)

Variables

This section is empty.

Functions

func DecodeData

func DecodeData(body []byte, indexes []int) (ret []byte, err error)

func NewClient

func NewClient(apiKey, apiSecret, userAgent string) (c *client)

NewClient return a new SouthXchange HTTP client

func NewClientWithCustomHttpConfig

func NewClientWithCustomHttpConfig(apiKey, apiSecret, userAgent string, httpClient *http.Client) (c *client)

NewClientWithCustomHttpConfig returns a new SouthXchange HTTP client using the predefined http client

func NewClientWithCustomTimeout

func NewClientWithCustomTimeout(apiKey, apiSecret, userAgent string, timeout time.Duration) (c *client)

NewClient returns a new SouthXchange HTTP client with custom timeout

Types

type Balance

type Balance struct {
	Currency    string
	Deposited   float64
	Available   float64
	Unconfirmed float64
}

type MarketSummary

type MarketSummary struct {
	Coin string `json:"Coin"`
	Base string `json:"Base"`
}

func (*MarketSummary) UnmarshalJSON

func (n *MarketSummary) UnmarshalJSON(buf []byte) error

type Order

type Order struct {
	Code              string
	Type              string
	Amount            float64
	OriginalAmount    float64
	LimitPrice        float64
	ListingCurrency   string
	ReferenceCurrency string
}

type PayloadData

type PayloadData map[string]interface{}

type SouthXchange

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

SouthXchange represent a SouthXchange client

func New

func New(apiKey, apiSecret, userAgent string) *SouthXchange

New returns an instantiated SouthXchange struct

func NewWithCustomHttpClient

func NewWithCustomHttpClient(apiKey, apiSecret, userAgent string, httpClient *http.Client) *SouthXchange

NewWithCustomHttpClient returns an instantiated SouthXchange struct with custom http client

func NewWithCustomTimeout

func NewWithCustomTimeout(apiKey, apiSecret, userAgent string, timeout time.Duration) *SouthXchange

NewWithCustomTimeout returns an instantiated SouthXchange struct with custom timeout

func (*SouthXchange) GetBalances

func (o *SouthXchange) GetBalances() (balances []Balance, err error)

GetBalances is used to retrieve all balances from your account

func (*SouthXchange) GetDepositAddress

func (b *SouthXchange) GetDepositAddress(currency string) (address string, err error)

GetDepositAddress is sed to generate or retrieve an address for a specific currency. currency a string literal for the currency (ie. BTC)

func (*SouthXchange) GetMarketSummaries

func (b *SouthXchange) GetMarketSummaries() (marketSummaries []MarketSummary, err error)

GetMarketSummaries is used to get the last 24 hour summary of all active exchanges

func (*SouthXchange) GetOpenOrders

func (b *SouthXchange) GetOpenOrders() (openOrders []Order, err error)

GetOpenOrders returns orders that you currently have opened.

func (*SouthXchange) GetTransactions

func (b *SouthXchange) GetTransactions(start uint64, limit uint32, sort string, desc bool) (transactions []Transaction, err error)

GetTransactions is used to retrieve your transaction history

func (*SouthXchange) SetDebug

func (o *SouthXchange) SetDebug(enable bool)

set enable/disable http request/response dump

func (*SouthXchange) Withdraw

func (o *SouthXchange) Withdraw(address string, currency string, quantity float64) (withdraw WithdrawalInfo, err error)

Withdraw is used to withdraw funds from your account. address string the address where to send the funds. currency string literal for the currency (ie. BTC) quantity float the quantity of coins to withdraw fee float the quantity of coins to withdraw

type Timestamp

type Timestamp time.Time

func (Timestamp) Diff

func (t Timestamp) Diff(u Timestamp) time.Duration

func (Timestamp) Format

func (t Timestamp) Format(layout string) string

func (Timestamp) MarshalJSON

func (t Timestamp) MarshalJSON() ([]byte, error)

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(body []byte) (err error)

type Transaction

type Transaction struct {
	Date          Timestamp
	Type          string
	Amount        float64
	TotalBalance  float64
	Price         float64
	OtherAmount   float64
	OtherCurrency string
	OrderCode     string
	Status        string
	Address       string
	Hash          string
}

type WithdrawalInfo

type WithdrawalInfo struct {
	Status   string
	Max      float64
	MaxDaily float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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