Documentation ¶
Overview ¶
Package indodax provide a library for accesing Indodax API (see https://indodax.com/downloads/BITCOINCOID-API-DOCUMENTATION.pdf for HTTP API documentation).
Indodax provide public and private APIs. The public APIs can be accessed directly by creating new client with empty token and secret parameters. The private APIs can only be accessed by using token and secret keys (API credential).
An API credential can be retrieved manually by logging in into your Indodax Exchange account (https://indodax.com/market) and open the "Trade API" menu section or https://indodax.com/trade_api.
Please keep these credentials safe and do not reveal to any external party.
Beside passing the token and secret to NewClient or Authenticate, this library also read token and secret values from environment variables "INDODAX_KEY" for token and "INDODAX_SECRET" for secret.
Index ¶
- Constants
- Variables
- func SetDebug(active bool) string
- type CancelOrder
- type Client
- func (cl *Client) AllOpenOrders() (allOpenOrders map[string][]OpenOrders, err error)
- func (cl *Client) CancelOrderBuy(pairName string, orderId int64) (cancelOrder *CancelOrder, err error)
- func (cl *Client) CancelOrderSell(pairName string, orderId int64) (cancelOrder *CancelOrder, err error)
- func (cl *Client) GetInfo() (usrInfo *UserInfo, err error)
- func (cl *Client) GetListTrades(pairName string) (listTrade []*ListTrade, err error)
- func (cl *Client) GetOrder(pairName string, orderId int64) (getOrder *GetOrder, err error)
- func (cl *Client) GetOrderBook(pairName string) (orderBook *OrderBook, err error)
- func (cl *Client) GetSummaries() (summaries *Summary, err error)
- func (cl *Client) GetTicker(pairName string) (ticker *Ticker, err error)
- func (cl *Client) OpenOrders(pairName string) (openOrders []OpenOrders, err error)
- func (cl *Client) OrderHistory(pairName string, count, from int64) (openOrders []OrderHistory, err error)
- func (cl *Client) TestAuthentication() (err error)
- func (cl *Client) TradeBuy(pairName string, price, amount float64) (trade *Trade, err error)
- func (cl *Client) TradeHitory(pairName string, count, startTradeID, endTradeID int64, sortOrder string, ...) (openOrders []TradeHistory, err error)
- func (cl *Client) TradeSell(pairName string, price, amount float64) (trade *Trade, err error)
- func (cl *Client) TransHistory() (transHistory *TransHistory, err error)
- type GetOrder
- type ListTrade
- type OpenOrders
- type Order
- type OrderBook
- type OrderHistory
- type Summary
- type Ticker
- type Trade
- type TradeHistory
- type TransDeposit
- type TransHistory
- type TransWithdraw
- type UserInfo
Constants ¶
const ( // UrlPublic is url to open data for public. It doesn't need an API key to call these methods. You can call // simple GET request or open it directly from the browser. UrlPublic = "https://indodax.com/api" // UrlPrivate : To use Private API first you need to obtain your API credentials by logging into your indodax.com // account and open https://indodax.com/trade_api. These credentials contain "API Key" and "Secret // Key". Please keep these credentials safe. UrlPrivate = "https://indodax.com/tapi" )
Variables ¶
var ( // ErrUnauthenticated define an error when user did not provide token // and secret keys when accessing private APIs. ErrUnauthenticated = fmt.Errorf("unauthenticated connection") // ErrInvalidPairName define an error if user call API with empty, // invalid or unknown pair's name. ErrInvalidPairName = fmt.Errorf("invalid or empty pair name") ErrInvalidOrderID = fmt.Errorf("Empty order ID") ErrInvalidPrice = fmt.Errorf("Empty price") ErrInvalidAmount = fmt.Errorf("Empty amount") ErrInvalidAssetName = fmt.Errorf("Empty asset name") )
Functions ¶
Types ¶
type CancelOrder ¶
CancelOrder contains a success response from calling a "cancelOrder" method.
func (*CancelOrder) UnmarshalJSON ¶
func (cancelOrder *CancelOrder) UnmarshalJSON(b []byte) (err error)
type Client ¶
type Client struct { Info *UserInfo // contains filtered or unexported fields }
Client represent common fields and environment Trading API
func NewClient ¶
NewClient create and initialize new Indodax client.
The token and secret parameters are used to authenticate the client when accessing private API.
By default, the key and secret is read from environment variables "INDODAX_KEY" and "INDODAX_SECRET", the parameters will override the default value, if its set. If both environment variables and the parameters are empty, the client can only access the public API.
func (*Client) AllOpenOrders ¶
func (cl *Client) AllOpenOrders() (allOpenOrders map[string][]OpenOrders, err error)
This method gives the list of current open orders (buy and sell) all pair.
func (*Client) CancelOrderBuy ¶
func (cl *Client) CancelOrderBuy( pairName string, orderId int64, ) (cancelOrder *CancelOrder, err error)
This method is for canceling an existing open buy order.
func (*Client) CancelOrderSell ¶
func (cl *Client) CancelOrderSell( pairName string, orderId int64, ) (cancelOrder *CancelOrder, err error)
This method is for canceling an existing open sell order.
func (*Client) GetInfo ¶
This method gives user balances, user wallet, user id, username, profile picture and server's timestamp.
func (*Client) GetListTrades ¶
GetListTrades containts the historical trade of an individual pair.
func (*Client) GetOrderBook ¶
GetOrderBook containts the order book buy and sell of an individual pair.
func (*Client) GetSummaries ¶
GetSummaries containts the price summary like volume, last price, open buy, open sell of all pair.
func (*Client) GetTicker ¶
GetTicker containts the price summary like volume, last price, open buy, open sell of an individual pair.
func (*Client) OpenOrders ¶
func (cl *Client) OpenOrders(pairName string) (openOrders []OpenOrders, err error)
This method gives the list of current open orders (buy and sell) by pair.
func (*Client) OrderHistory ¶
func (cl *Client) OrderHistory( pairName string, count, from int64, ) (openOrders []OrderHistory, err error)
This method gives the list of order history (buy and sell).
func (*Client) TestAuthentication ¶
TestAuthenticate is function to test connection the current client's using token and secret keys.
func (*Client) TradeHitory ¶
func (cl *Client) TradeHitory( pairName string, count, startTradeID, endTradeID int64, sortOrder string, sinceTime *time.Time, endTime *time.Time, ) (openOrders []TradeHistory, err error)
This method gives information about transaction in buying and selling history
func (*Client) TransHistory ¶
func (cl *Client) TransHistory() (transHistory *TransHistory, err error)
This method gives list of deposits and withdrawals of all currencies
type GetOrder ¶
type GetOrder struct { OrderID int64 Price float64 Type string OrderAmount float64 RemainAmount float64 SubmitTime time.Time FinishTime time.Time Status string AssetName string }
Get Order containt a status from order placed of user
func (*GetOrder) UnmarshalJSON ¶
type OpenOrders ¶
type OpenOrders struct { ID int64 SubmitTime time.Time Price float64 OrderAmount float64 RemainAmount float64 Type string AssetName string }
Open Orders containt all order book from user
func (*OpenOrders) UnmarshalJSON ¶
func (openOrders *OpenOrders) UnmarshalJSON(b []byte) (err error)
type Order ¶
Order contains the number of amount asset and price of open order
func (*Order) UnmarshalJSON ¶
type OrderHistory ¶
type OrderHistory struct { ID int64 Type string Price float64 SubmitTime time.Time FinishTime time.Time Status string OrderAmount float64 RemainAmount float64 AssetName string }
Order History containt all order book from user
func (*OrderHistory) UnmarshalJSON ¶
func (orderHistory *OrderHistory) UnmarshalJSON(b []byte) (err error)
type Summary ¶
type Summary struct { Tickers map[string]*Ticker Prices24h map[string]float64 Prices7d map[string]float64 }
Summary containts all tickers, prices24h, and prices 7d status of all pairs.
func (*Summary) UnmarshalJSON ¶
type Ticker ¶
type Ticker struct { PairName string High float64 Low float64 AssetVolume float64 BaseVolume float64 Last float64 Buy float64 Sell float64 }
Ticker containts High price 24h, Low price24h, Volume asset Volume Base, Last price, Open buy, and Open Sell
type Trade ¶
type Trade struct { Receive float64 ReceiveAssetName string Spend float64 SpendAssetName string Sold float64 SoldAssetName string Remain float64 RemainAssetName string Fee float64 OrderID int64 Balance map[string]float64 }
Trade containt status of order placed by user like recive asset, spend asset, sold asset, remain asset, fee, order id placed, and last balance after trade.
func (*Trade) UnmarshalJSON ¶
type TradeHistory ¶
type TradeHistory struct { TradeID int64 OrderID int64 Type string AssetName string Amount float64 Price float64 Fee float64 TradeTime time.Time }
Trade History containt trade id, order id, type of trade match(buy/sell), AssetName, amount, price, and fee.
func (*TradeHistory) UnmarshalJSON ¶
func (tradeHistory *TradeHistory) UnmarshalJSON(b []byte) (err error)
type TransDeposit ¶
type TransDeposit struct { Status string Type string Amount float64 Fee float64 SubmitTime time.Time SuccessTime time.Time ID int64 }
func (*TransDeposit) UnmarshalJSON ¶
func (transDeposit *TransDeposit) UnmarshalJSON(b []byte) (err error)
type TransHistory ¶
type TransHistory struct { Withdraw map[string][]TransWithdraw Deposit map[string][]TransDeposit }
Transaction History containt list of Deposit and withdraw.
type TransWithdraw ¶
type TransWithdraw struct { Status string Type string Amount float64 Fee float64 SubmitTime time.Time SuccessTime time.Time ID int64 }
func (*TransWithdraw) UnmarshalJSON ¶
func (transWithdraw *TransWithdraw) UnmarshalJSON(b []byte) (err error)
type UserInfo ¶
type UserInfo struct { Balance map[string]float64 BalanceHold map[string]float64 WalletAddress map[string]string UserId int ProfilePicture string UserName string ServerTime time.Time Email string }
User Info containt balance info, wallet address, user id, profile picture, username, and email of user.