Giter Site home page Giter Site logo

max-exchange-api-go's Introduction

License GoDoc Go Report Card

max-exchange-api-go

MAX (Maicoin Assets eXchange) Go SDK

Examples

See the examples directory.

Documentation for API Endpoints

Notes

Private APIs require authentication. Pass your API tokens by AuthToken() or WSAuthToken() before using them.

RESTful APIs

All URIs are relative to https://max-api.maicoin.com

Class Go Method HTTP request Description
Public Currencies GET /api/v2/currencies
Public Depth GET /api/v2/depth
Public K GET /api/v2/k
Public Markets GET /api/v2/markets
Public OrderBook GET /api/v2/order_book
Public Tickers GET /api/v2/tickers
Public Ticker GET /api/v2/tickers/{market}
Public Timestamp GET /api/v2/timestamp
Public Trades GET /api/v2/trades
Class Go Method HTTP request Description
Private Deposit GET /api/v2/deposit
Private DepositAddress GET /api/v2/deposit_address Deprecated
Private CreateDepositAddresses POST /api/v2/deposit_addresses create deposit addresses
Private DepositAddresses GET /api/v2/deposit_addresses where to deposit
Private Deposits GET /api/v2/deposits
Private Me GET /api/v2/members/me
Private Order GET /api/v2/order
Private Orders GET /api/v2/orders
Private MyTrades GET /api/v2/trades/my
Private Withdrawal GET /api/v2/withdrawal
Private Withdrawals GET /api/v2/withdrawals
Private CancelOrder POST /api/v2/order/delete
Private CancelOrders POST /api/v2/orders/clear
Private CreateOrder POST /api/v2/orders
Private CreateOrders POST /api/v2/orders/multi create multiple sell/buy orders

Websocket APIs (Beta)

Class Go Method Description
Public SubscribeTicker Subscribe the realtime price information
Public SubscribeOrderBook Subscribe the realtime changes on order books
Public SubscribeTrade Subscribe the realtime trades information
Class Go Method Description
Private SubscribeAccount Subscribe the accounts changes for an user

API Reference

See MAX RESTful API List and MAX Websocket API List (Beta).

max-exchange-api-go's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

max-exchange-api-go's Issues

How to use client.K(context.Context, string, ...CallOption) ([]*models.Candle, error)

HI, how to use client.K function?
I try the variables below:

results, err := client.K(context.Background(), market, max.Timestamp(1537026026), max.Period(1), max.Limit(1))

But will get:
struct{0001-01-01 00:00:00 +0000 UTC 0 0 0 0 0}

The source code below, thanks:

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"log"

	"github.com/maicoin/max-exchange-api-go/models"
	max "github.com/maicoin/max-exchange-api-go"
)

func main() {
	ethtwdK, _ := GetK("ethtwd", 1537026026)
	fmt.Println(ethtwdK)
}

func GetK(market string, timestamp int32) (k models.Candle, err error) {
	client := max.NewClient()
	defer client.Close()

	results, err := client.K(context.Background(), market, max.Timestamp(timestamp), max.Period(1), max.Limit(1))
	if err != nil {
		log.Fatal(err)
		return models.Candle{}, err
	}
	resultBytes, err := json.MarshalIndent(results, "", "\t")
	if err != nil {
		log.Fatal(err)
		return models.Candle{}, err
	}
	json.Unmarshal(resultBytes, &k)
	return k, err
}

run websocket example of orderbook, got error

when run websock example of orderbook, i got below:

2019/12/11 10:26:26 ["ticker",{"market":"btcusdt"}] subscribed
2019/12/11 10:26:26 ["orderbook",{"market":"btcusdt"}] subscribed
2019/12/11 10:26:26 ["trade",{"market":"btcusdt"}] subscribed
2019/12/11 10:26:28 Failed to decode orderbook response <nil>, json: cannot unmarshal string into Go struct field OrderBookEvent.volume of type float64
2019/12/11 10:26:29 Failed to decode orderbook response <nil>, json: cannot unmarshal string into Go struct field OrderBookEvent.volume of type float64

the websocket return ,are not number type for price and volume
can fix ws server return for fit type

or

adjust the type with stirng Embellish, like below

Volume    types.Volume    `json:"volume,omitempty"`
Price     types.Price     `json:"price,omitempty"`

to

Volume    types.Volume    `json:"volume,omitempty,string"`
Price     types.Price     `json:"price,omitempty,string"`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.