Git Product home page Git Product logo

bitopro-api-go's Introduction

BitoPro API Client for Go

Requirement

Requires minimum of Go 1.11.

Installation

$ go get github.com/bitoex/bitopro-api-go

Limitations

Rate Limit

There is rate limits applied to each API, please check API documentation for more detail.

Precisions

Both price and amount are subject to decimal restrictions, please check official settings for more detail.

Minimum order amount

Checkout the official settings of minimum amount.

Getting Started

Public API

Methods for public APIs are packaged in PubAPI struct which can be created through GetPubClient.

import "github.com/bitoex/bitopro-api-go/pkg/bitopro"

pubClient := bitopro.GetPubClient()

Authenticated API

Methods for authenticated APIs are packaged in AuthAPI struct which can be created in various ways through GetAuthClient depends on how you setup your authenticate information. To use the authenticated APIs, you need the following information, API Key, API Secret, Identity (Account Email). You can create an API key here.

Basic
import "github.com/bitoex/bitopro-api-go/pkg/bitopro"

authClient := bitopro.GetAuthClient("your identity (email)", "your key", "your secret")
From Viper
# secret.yml
identity: <<your email>>
key: <<your key>>
secret: <<your secret>>
import (
  "github.com/spf13/viper"
  
  "github.com/bitoex/bitopro-api-go/pkg/bitopro"
)

viper.AddConfigPath(".")
viper.SetConfigName("secret")
viper.ReadInConfig()

authAPI := GetAuthClient(viper.GetString("identity"), viper.GetString("key"), viper.GetString("secret"))

Public REST Endpoints

GetOrderBook

example

pubClient.GetOrderBook("btc_twd")
//or
authClient.GetOrderBook("btc_twd")
JSON Response
{
  "bids": [
    {
      "price": "180500",
      "amount": "0.12817687",
      "count": 1,
      "total": "0.12817687"
    },
    {
      "price": "180010",
      "amount": "0.32292",
      "count": 2,
      "total": "0.45109687"
    },
    {
      "price": "180000",
      "amount": "0.24236",
      "count": 3,
      "total": "0.69345687"
    }
  ],
  "asks": [
    {
      "price": "180599",
      "amount": "0.00326056",
      "count": 1,
      "total": "0.00326056"
    },
    {
      "price": "180600",
      "amount": "0.04202575",
      "count": 1,
      "total": "0.04528631"
    }
  ]
}

GetTicker

example

pubClient.GetTicker("btc_twd")
//or
authClient.GetTicker("btc_twd")
JSON Response
{
  "data": {
    "pair": "btc_twd",
    "lastPrice": "0.00010800",
    "isBuyer": false,
    "priceChange24hr": "0",
    "volume24hr": "0.00000000",
    "high24hr": "0.00010800",
    "low24hr": "0.00010800"
  }
}

GetTickers

example

pubClient.GetTickers()
//or
authClient.GetTickers()
JSON Response
{
  "data": [
    {
      "pair": "xem_btc",
      "lastPrice": "0.00000098",
      "isBuyer": false,
      "priceChange24hr": "0",
      "volume24hr": "0.00000000",
      "high24hr": "0.00000098",
      "low24hr": "0.00000098"
    },
    {
      "pair": "bch_eth",
      "lastPrice": "0.60010000",
      "isBuyer": false,
      "priceChange24hr": "0",
      "volume24hr": "0.00000000",
      "high24hr": "0.60010000",
      "low24hr": "0.60010000"
    },
    {
      "pair": "eth_usdt",
      "lastPrice": "179.22000000",
      "isBuyer": true,
      "priceChange24hr": "10.85",
      "volume24hr": "925.14654180",
      "high24hr": "182.30000000",
      "low24hr": "159.94000000"
    }
  ]
}

GetTrades

example

pubClient.GetTrades("btc_twd")
//or
authClient.GetTrades("btc_twd")
JSON Response
{
  "data": [
    {
      "timestamp": 1557203407,
      "price": "180500.00000000",
      "amount": "0.07717687",
      "isBuyer": false
    },
    {
      "timestamp": 1557203187,
      "price": "180500.00000000",
      "amount": "0.05100000",
      "isBuyer": false
    },
    {
      "timestamp": 1557203053,
      "price": "180500.00000000",
      "amount": "0.01860000",
      "isBuyer": false
    },
    {
      "timestamp": 1557202804,
      "price": "180500.00000000",
      "amount": "0.04781533",
      "isBuyer": false
    },
    {
      "timestamp": 1557202804,
      "price": "180500.00000000",
      "amount": "0.06000000",
      "isBuyer": false
    }
  ]
}

Authenticated REST Endpoints

GetAccountBalance

example

authClient.GetAccountBalance()
JSON Response
{
  "data": [
    {
      "amount": "10001",
      "available": "1.0",
      "currency": "bito",
      "stake": "10000"
    },
    {
      "amount": "0.0",
      "available": "1.0",
      "currency": "btc",
      "stake": "0"
    },
    {
      "amount": "3.0",
      "available": "0.01",
      "currency": "eth",
      "stake": "0"
    },
    {
      "amount": "30000",
      "available": "2500",
      "currency": "twd",
      "stake": "0"
    }
  ]
}

GetOrderHistory

example

authClient.GetOrderHistory()
JSON Response
{
  "data": [
    {
      "action": "buy",
      "avgExecutionPrice": "100000.00000000",
      "bitoFee": "0.00000000",
      "executedAmount": "1.00000000",
      "fee": "0.00100000",
      "feeSymbol": "BTC",
      "id": "123",
      "originalAmount": "1.00000000",
      "pair": "btc_twd",
      "price": "100000.00000000",
      "remainingAmount": "0.00000000",
      "status": 2,
      "timestamp": 1508753757000,
      "type": "limit"
    },
    {
      "action": "buy",
      "avgExecutionPrice": "100000.00000000",
      "bitoFee": "0.00000000",
      "executedAmount": "1.00000000",
      "fee": "0.00200000",
      "feeSymbol": "BTC",
      "id": "456",
      "originalAmount": "1.00000000",
      "pair": "btc_twd",
      "price": "100000.00000000",
      "remainingAmount": "0.00000000",
      "status": 2,
      "timestamp": 1508753787000,
      "type": "limit"
    }
  ]
}

GetOrderList

example

authClient.GetOrderList("btc_twd", false, 1)
JSON Response
{
  "data": [
    {
      "action": "buy",
      "avgExecutionPrice": "100000.00000000",
      "bitoFee": "0.00000000",
      "executedAmount": "1.00000000",
      "fee": "0.00100000",
      "feeSymbol": "BTC",
      "id": "123",
      "originalAmount": "1.00000000",
      "pair": "btc_twd",
      "price": "100000.00000000",
      "remainingAmount": "0.00000000",
      "status": 2,
      "timestamp": 1508753757000,
      "type": "limit"
    },
    {
      "action": "buy",
      "avgExecutionPrice": "100000.00000000",
      "bitoFee": "0.00000000",
      "executedAmount": "1.00000000",
      "fee": "0.00200000",
      "feeSymbol": "BTC",
      "id": "456",
      "originalAmount": "1.00000000",
      "pair": "btc_twd",
      "price": "100000.00000000",
      "remainingAmount": "0.00000000",
      "status": 2,
      "timestamp": 1508753787000,
      "type": "limit"
    }
  ],
  "page": 1,
  "totalPages": 10
}

CreateOrderLimitBuy/CreateOrderLimitSell/CreateOrderMarketBuy/CreateOrderMarketSell

example

// create limit buy order
authClient.CreateOrderLimitBuy("eth_twd", "0.1", "1")
// create limit sell order
authClient.CreateOrderLimitSell("eth_twd", "0.1", "1")
// create market buy order
authClient.CreateOrderMarketBuy("eth_twd", "1")
// create market sell order
authClient.CreateOrderMarketSell("eth_twd", "1")
JSON Response
{
  "action": "buy",
  "amount": "0.235",
  "orderId": "11233456",
  "price": "1.0",
  "timestamp": 1504262258000
}

CancelOrder

example

authClient.CancelOrder("eth_twd", 7517762903)
JSON Response
{
  "action": "buy",
  "amount": 2.3,
  "orderId": "7517762903",
  "price": 1.2,
  "timestamp": 1504262258000
}

GetOrder

example

authClient.GetOrder("btc_twd", 2640904509)
JSON Response
{
  "action": "sell",
  "avgExecutionPrice": "112000.00000000",
  "bitoFee": "103.70370360",
  "executedAmount": "1.00000000",
  "fee": "0.00000000",
  "feeSymbol": "TWD",
  "id": "2640904509",
  "originalAmount": "1.00000000",
  "pair": "btc_twd",
  "price": "112000.00000000",
  "remainingAmount": "0.00000000",
  "status": 2,
  "timestamp": 1508753757000,
  "type": "limit"
}

Contributing

Bug reports and pull requests are welcome on GitHub at bitopro-api-go and this project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

  1. Fork it.
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Added some feature').
  4. Push to the branch (git push origin my-new-feature).
  5. Create new Pull Request.

License

The SDK is available as open source under the terms of the MIT License.

bitopro-api-go's People

Contributors

howard0401 avatar

Stargazers

 avatar

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.