mbpy
is an open source python wrapper for Mercado Bitcoin Trade API.
- Mercado Bitcoin Auth (requires API Key)
- View Account Balance
- Buy & Sell cryptocurrencies
- Manage Orders
- Withdraw/Transfer funds
- View Mercado Bitcoin Public Orderbook info
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.
Clone the project repository:
$ git clone github.com/lucianoayres/mbpy.git
Make sure you have the following Python packages installed:
- hashlib
- hmac
- json
- time
- http
- urlib
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.
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')
# 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.
# 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')
Check the source code comments to learn more about the remaining methods:
- listsystemmessages
- getaccountinfo
- getorder
- cancelorder
- listorders
- listorderbook
- withdraw_coin