Documentation
¶
Overview ¶
Package wazirx provides a client for using the Wazirx's Public Rest API. You can read the API server documentation at https://github.com/WazirX/wazirx-api
Usage:
create a new instance of Client, then use the various methods on the client to access different parts of the API. For demonstration:
package main import ( "context" "fmt" "log" "github.com/itsksaurabh/go-wazirx" ) func main() { client := wazirx.Client{} ctx := context.Background() data, err := client.MarketStatus(ctx) if err != nil { log.Fatal("request failed:", err) } fmt.Println(data) }
Notes: * Using the [https://godoc.org/context](https://godoc.org/context) package for passing context. * Look at tests(*_test.go) files for more sample usage.
Index ¶
- Constants
- func WithCtx(ctx context.Context, req *http.Request) *http.Request
- type Asset
- type Client
- func (c Client) Do(req *http.Request, target interface{}) error
- func (c Client) MarketDepth(ctx context.Context, market string) (data MarketDepth, err error)
- func (c Client) MarketStatus(ctx context.Context) (data MarketStatus, err error)
- func (c Client) MarketTicker(ctx context.Context) (data map[string]TickerData, err error)
- func (c Client) MarketTrade(ctx context.Context, market string) (data []MarketTrade, err error)
- type ErrAPI
- type Fee
- type MakerTaker
- type Market
- type MarketDepth
- type MarketStatus
- type MarketTrade
- type PriceVolume
- type TickerData
Constants ¶
const (
// DefaultBaseURL is the default server URL.
DefaultBaseURL = "https://api.wazirx.com"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Asset ¶
type Asset struct { // asset code Type string `json:"type"` // Display name of asset Name string `json:"name"` // Denotes whether deposit is enabled or disabled Deposit string `json:"deposit"` // Denotes whether withdrawal is enabled or disabled Withdrawal string `json:"withdrawal"` ListingType string `json:"listingType"` Category string `json:"category"` // Withdrawal fee of asset WithdrawFee float64 `json:"withdrawFee,omitempty"` // Minimum withdrawal amount in a single transaction MinWithdrawAmount float64 `json:"minWithdrawAmount,omitempty"` // Maximum withdrawal amount in a single transaction MaxWithdrawAmount float64 `json:"maxWithdrawAmount,omitempty"` // This is the min Deposit amount that will be accepted as deposit MinDepositAmount float64 `json:"minDepositAmount,omitempty"` // Is the min number of block height needed to confirm a block chain deposit transaction. Confirmations int `json:"confirmations,omitempty"` }
Asset holds asset related data
type Client ¶
type Client struct { // HTTPClient is a reusable http client instance. HTTP *http.Client // BaseURL is the REST endpoints URL of the api server BaseURL *url.URL }
Client for accessing different endpoints of the API
func (Client) MarketDepth ¶
MarketDepth returs orderbook of any market. Pass any market to get the desired order book.
func (Client) MarketStatus ¶
func (c Client) MarketStatus(ctx context.Context) (data MarketStatus, err error)
MarketStatus returs overview of markets and assets
func (Client) MarketTicker ¶
MarketTicker returs the latest market heart-beat for all the markets for the last 24hrs.
func (Client) MarketTrade ¶
MarketTrade returs trade history of a market. Pass any market to get the desired trade history.
type Fee ¶
type Fee struct { Bid MakerTaker `json:"bid"` Ask MakerTaker `json:"ask"` }
Fee holds bid and ask order's maker-taker fee percentage
func (*Fee) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Since `Fee` is returned as an map so it converts it into struct for better access
type MakerTaker ¶
MakerTaker holds order's maker-taker
type Market ¶
type Market struct { // Ticker code of base asset BaseMarket string `json:"baseMarket"` // Ticker code of quote asset QuoteMarket string `json:"quoteMarket"` // Minimum buy amount of base asset MinBuyAmount float64 `json:"minBuyAmount,omitempty"` // Minumum sell amount of base asset MinSellAmount float64 `json:"minSellAmount,omitempty"` // Maximum precision of base asset, this the decimal point. BasePrecision int `json:"basePrecision,omitempty"` // Maximum precision of quote asset QuotePrecision int `json:"quotePrecision,omitempty"` // This defines the current state of the market. This can be active or suspended Status string `json:"status"` // JSON Object consists of bid and ask order's maker-taker fee percentage Fee Fee `json:"fee,omitempty"` // 24 hrs lowest price of base asset Low float64 `json:"low,omitempty"` // 24 hrs highest price of base asset High float64 `json:"high,omitempty"` // Last traded price in current market Last float64 `json:"last,omitempty"` // This defines the type of market, currently we have SPOT and P2P Type string `json:"type"` // Market Open price 24hrs ago Open float64 `json:"open,omitempty"` // Last 24hrs traded volume Volume float64 `json:"volume,omitempty"` // Top ask order price Sell float64 `json:"sell,omitempty"` // Top bid order price Buy float64 `json:"buy,omitempty"` At time.Time `json:"at,omitempty"` MaxBuyAmount float64 `json:"maxBuyAmount,omitempty"` MinBuyVolume float64 `json:"minBuyVolume,omitempty"` MaxBuyVolume float64 `json:"maxBuyVolume,omitempty"` FeePercentOnProfit float64 `json:"feePercentOnProfit,omitempty"` }
Market holds market related data
func (*Market) UnmarshalJSON ¶ added in v1.1.1
UnmarshalJSON implements the json.Unmarshaler interface. coverts some string type numeric to numeric type coverts Timestamp from `int` to unix timestamp
type MarketDepth ¶
type MarketDepth struct { Timestamp time.Time `json:"timestamp"` // list order's asks Asks []PriceVolume `json:"asks"` // list order's bids Bids []PriceVolume `json:"bids"` }
MarketDepth holds orderbook data of a perticular market
func (*MarketDepth) UnmarshalJSON ¶
func (d *MarketDepth) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. converts slices into struct for better access and coverts Timestamp from `int` to unix timestamp
type MarketStatus ¶
MarketStatus holds the response from endpoint /api/v2/market-status
type MarketTrade ¶
type MarketTrade struct { ID int64 `json:"id"` Price float64 `json:"price"` Volume float64 `json:"volume"` Funds float64 `json:"funds"` Market string `json:"market"` CreatedAt time.Time `json:"created_at"` Side interface{} `json:"side"` }
MarketTrade holds trade history of a perticular market
func (*MarketTrade) UnmarshalJSON ¶ added in v1.1.2
func (t *MarketTrade) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. It coverts some string type numeric to numeric types.
type PriceVolume ¶
PriceVolume holds price and volume
type TickerData ¶
type TickerData struct { // ticker code of base market BaseUnit string `json:"base_unit"` // ticker code of quote asset QuoteUnit string `json:"quote_unit"` // 24 hrs lowest price of base asset Low float64 `json:"low"` // 24 hrs highest price of base asset High float64 `json:"high"` // Last traded price in current market Last float64 `json:"last"` Type string `json:"type"` // Market Open price 24hrs ago Open interface{} `json:"open"` // Last 24hrs traded volume Volume float64 `json:"volume"` // Top ask order price Sell float64 `json:"sell"` // Top bid order price Buy float64 `json:"buy"` // Timestamp when ticker information is fetched At time.Time `json:"at"` // Display text of market Name string `json:"name"` }
TickerData holds active market data with all ticker related values
func (*TickerData) UnmarshalJSON ¶ added in v1.1.1
func (t *TickerData) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. It coverts some string type numeric to numeric type and coverts Timestamp from `int` to unix timestamp