A Python3 wrapper for the Txbit API
This is an unofficial wrapper with no affiliation with Txbit, use at your own risk.
Note: requests are limited to 10 per second per IP address
pip3 install txbit
Methods in the txbit package retrun a TxbitReponse
object containing three attributes aligning with txbit API response (success, message, result).
import txbit
txbit = txbit.Txbit() # initalize the object
request = txbit.getMarkets() # use one of the object's methods to make an API call
request.success # returns True
request.message # returns ''
request.result # returns a list of market dictionaries
The Txbit API is split into three groups (Public, Market, and Account). The Public group provides information about markets and does not require authentication with an API Key and Secret. An exception will be raised if trying to use the non-public methods without supplying a APIKey and Secret.
txbit = txbit.Txbit() # no API Key and Secret supplied if only using public methods
Methods of the PublicClient class, and related documentation, below:
txbit.getMarkets()
- https://apidocs.txbit.io/#public-getmarketstxbit.getCurrencies()
- https://apidocs.txbit.io/#public-getcurrenciestxbit.getTicker(market)
- https://apidocs.txbit.io/#public-gettickertxbit.getMarketSummaries()
- https://apidocs.txbit.io/#public-getmarketsummariestxbit.getMarketSummary(market)
- https://apidocs.txbit.io/#public-getmarketsummarytxbit.getOrderBook(market, bookType='both')
- https://apidocs.txbit.io/#public-getorderbooktxbit.getMarketHistory(market)
- https://apidocs.txbit.io/#public-getmarkethistorytxbit.getSystemStatus()
- https://apidocs.txbit.io/#public-getsystemstatustxbit.getCurrencyInformation(currency)
- https://apidocs.txbit.io/#public-getcurrencyinformationtxbit.getCurrencyBalanceSheet(currency)
- https://apidocs.txbit.io/#public-getcurrencybalancesheet
The other two groups (Market and Account) require authentication for access/use.
- Market - Used for setting and canceling orders. The ALLOW TRADING permission must be set up on the key(s) being used.
- Acount - Used for account related functions such as balances, withdrawals and deposit addresses. The ALLOW READING permission must be set up on the key(s) being used.
This wrapper handles most of the authentication process, so the only thing that needs to be supplied is an API Key and Secret with proper permissions. We recommend saving your key and secret as variables (APIKEY = XXX
and SECRET=XXX
) in a separate python file named secrets.py
and importing it such as the example below.
To create and manage your API keys go to Profile > Settings > API Keys on the Txbit.io site.
from secrets import APIKEY, SECRET # import api key and secret
txbit = txbit.Txbit(APIKEY, SECRET) # this time supplying a API Key and Secret
Methods of the Authenticated Client class, and related documentation, below:
txbit.buyLimit(market, quantity, rate)
- https://apidocs.txbit.io/#market-buylimittxbit.sellLimit(market, quantity, rate)
- https://apidocs.txbit.io/#market-selllimittxbit.cancel(uuid)
- https://apidocs.txbit.io/#market-canceltxbit.getOpenOrders(market=None)
- https://apidocs.txbit.io/#market-getopenorders
txbit.getBalances()
- https://apidocs.txbit.io/#account-getbalancestxbit.getBalance(currency)
- https://apidocs.txbit.io/#account-getbalancetxbit.getDepositAddress(currency)
- https://apidocs.txbit.io/#account-getdepositaddresstxbit.withdraw(currency, quantity, address, paymentid=None)
- https://apidocs.txbit.io/#account-withdrawtxbit.getOrder(uuid)
- https://apidocs.txbit.io/#account-getordertxbit.getOrderHistory(market=None)
- https://apidocs.txbit.io/#account-getorderhistoryauthClient.getWithdrawlHistory(currency=None)
- https://apidocs.txbit.io/#account-getwithdrawalhistoryauthClient.getDepositHistory(currency=None)
- https://apidocs.txbit.io/#account-getdeposithistory
For any help or questions, please open an issue on GitHub.