/go-mbsdk

SDK for API MercadoBitcoin

Primary LanguageGoOtherNOASSERTION

MercadoBitcoin SDK

Easy way to consume the public api informations from MercadoBitcoin

API v4 (new - working in progress)

Endpoints available

  • Authorization
  • Accounts
    • - Get Accounts
    • - Balance List
    • - Position List
  • Trading
    • - Get Order
    • - Order Place
    • - Order Cancel
    • - Order List
    • - Order Cancel All
  • Wallet
    • Wallet Deposit
    • Wallet Withdraw
    • Wallet GetDraw
  • Public data
    • - Get Ticker
    • - Get Orderbook
    • - Get Trades
    • - Get Candles
    • - Get Symbol

Cache

The external cache system is not mandatory, but if you want to use a functions worked with cache for a delayed cli command, you needed use the cache system.

With cache system default (memory)

key := os.Getenv("MB_KEY")
secret := os.Getenv("MB_SECRET")

opts := []api.Options{
	api.OptKey(key),
	api.OptSecret(secret),
	api.OptDebug(true),
}
a, err := api.New(opts...)
if err != nil {
	fmt.Println(err)
}

auth, acc, err := a.Login()
if err != nil {
	fmt.Println(err)
	return
}

With cache system persistent (go-cache)

// not mandatory
optsc := []options.Options{
	options.OptFolder("./settings"),
	options.OptFileName("cache.db"),
	options.OptTTL(3000),
	options.OptLogDebug(true),
	options.OptLogDisable(false),
}

// not mandatory
c, err := cache.NewCache(kind.BUNTDB, optsc...)
if err != nil {
	log.Fatal(err)
}

opts := []api.Options{
	api.OptKey(key),
	api.OptSecret(secret),
	api.OptDebug(true),
	api.OptCache(c), // not mandatory
}

a, err := api.New(opts...)
if err != nil {
	fmt.Println(err)
	return
}

Versioning and license

Our version numbers follow the semantic versioning specification. You can see the available versions by checking the tags on this repository. For more details about our license model, please take a look at the LICENSE file.

2022, thiagozs