Skip to content

Unofficial Python wrapper for Mercado Bitcoin Trade API.

License

Notifications You must be signed in to change notification settings

lucianoayres/mbpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Unofficial Mercado Bitcoin Trade API Python Wrapper

mbpy is an open source python wrapper for Mercado Bitcoin Trade API.

Features

  • Mercado Bitcoin Auth (requires API Key)
  • View Account Balance
  • Buy & Sell cryptocurrencies
  • Manage Orders
  • Withdraw/Transfer funds
  • View Mercado Bitcoin Public Orderbook info

Disclaimer

This a unofficial independent project that makes use of a public API using your user account credentials on Mercado Bitcoin crypto trading platform. It is provided 'as is' without express or implied warranty. Use it at your own risk.

Setup

Step 1

Clone the project repository:

$ git clone github.com/lucianoayres/mbpy.git

Step 2

Make sure you have the following Python packages installed:

  • hashlib
  • hmac
  • json
  • time
  • http
  • urlib

Step 3

mbpy makes use of Mercado Bitcoin´s official Trade API, so log in on their website and generate your API Key (TAPI ID) and Secret (TAPI SECRET) pair.

Step 4

Create a new Python script, import mbpy and create a new instance of it using your TAPI ID and TAPI Secret

from mbpy import mbpy

mbClient = mbpy('YOUR_TAPI_ID', 'YOUR_TAPI_SECRET')

Usage

# Place a Market Buy order of R$ 150 in Bitcoin
response = mbClient.placemarketbuyorder('BRLBTC','150')

if response['status_code'] == 100:
  print('success')
else:
  if response['error_message] != '':
    print(response['error_message'])
  else
    print('Mercado Bitcoin API is temporarily unavailable')

IMPORTANT: Check Mercado Bitcoin Trade API for a complete list of coin IDs and minimum purchase amount per coin category.

Examples

# Place a Buy order of 0.002 Ethereum with a limit price of R$ 700
mbClient.placebuyorder('BRLETH','0.002', '700')
# Place a Market Sell order of 0.005 Bitcoin Cash
mbClient.placemarketsellorder('BRLBCH','0.005')
# Place a Sell order of 0.1 Litecoin with a minimal price of R$ 1.800,50
mbClient.placesellorder('BRLLTC', '0.1', '1800.50')

Additional Methods

Check the source code comments to learn more about the remaining methods:

  • listsystemmessages
  • getaccountinfo
  • getorder
  • cancelorder
  • listorders
  • listorderbook
  • withdraw_coin

Reference

License

MIT License

Releases

No releases published

Packages

No packages published

Languages