Package: buttercoin
Official Python Client of theButtercoin API.Buttercoinis a trading platform that makes
buying and sellingbitcoineasy.InstallationInstall viapip$pipinstallbuttercoinInstall from source$gitclonegit@github.com:buttercoin/buttercoin-python.git$cdbuttercoin-python$pythonsetup.pyinstallUsageHMAC-SHA256 AuthenticationYou need anAPI key and secretto useHMAC.SettingProperty NameDescriptionAPI Keyapi_keyYour Buttercoin API KeyAPI Secretapi_secretYour Buttercoin API SecretModemodeYour development environment (default:'production', set to'sandbox'to test with testnet bitcoins)frombuttercoin.clientimportButtercoinClientclient=ButtercoinClient(api_key='<BUTTERCOIN_API_KEY>',api_secret='<BUTTERCOIN_API_SECRET>',mode='<BUTTERCOIN_MODE>'# production or sandbox)TipsA note on thetimestampparam sent to all client methods: This param
must always be increasing, and within 5 minutes of Buttercoin server
times (GMT). This is to prevent replay attacks on your data.Because of this, if you need your API calls to run in a certain order,
you must chain together callbacks to ensure synchronous responses to
your requests.Additionally, for convenience, if you don’t include the timestamp
parameter, it will default to the current timestamp.timestamp = unicode(int(round(time.time() * 1000)))
client.get_key(timestamp=timestamp)

# or default to current timestamp

client.get_key()Get DataKey PermissionsReturnsarrayof permissions associated with this key.client.get_key()BalancesReturnsdictof balances for this account.client.get_balances()Deposit AddressReturns bitcoin addressstringto deposit your funds into the Buttercoin platform.client.get_deposit_address()Get OrdersReturnsarrayofdictobjects containing information about buy and sell orders.NameParamDescriptionStatusstatusenum:['opened','partial-filled','filled', 'canceled']Sidesideenum:['buy', 'sell']Order TypeorderTypeenum:['market', 'limit']Date MindateMinformat: ISO-8601, e.g.'2014-05-06T13:15:30Z'Date MaxdateMaxformat: ISO-8601, e.g.'2014-05-06T13:15:30Z'# query for multiple ordersbody={'status':'canceled'}client.get_orders(body=body)# single order by idclient.get_order_by_id('<order_id>');# single order by urlclient.get_order_by_url('http://api.buttercoin.com/v1/orders/b9fa58e6-a441-48ca-afbb-14827fca2f7a')Get TransactionsReturnsarrayofdictobjects containing information about deposit and withdraw action.NameParamDescriptionStatusstatusenum:['pending', 'processing', 'funded', 'canceled', 'failed']Transaction TypetransactionTypeenum:['deposit', 'withdrawal']Date MindateMinformat: ISO-8601, e.g.'2014-05-06T13:15:30Z'Date MaxdateMaxformat: ISO-8601, e.g.'2014-05-06T13:15:30Z'# query for multiple transactionsbody={'status':'pending'}client.get_transactions(body=body)# single transaction by idclient.get_transaction_by_id('<transaction_id>');# single transaction by urlclient.get_transaction_by_url('http://api.buttercoin.com/v1/transactions/53db06ee7400007700f4c561')});Unauthenticated RequestsGet Order BookReturn adictobject of current orders in the Buttercoin order book.client.get_order_book()Get TickerReturn the current bid, ask, and last sell prices on the Buttercoin platform.client.get_ticker()Get Trade HistoryReturn the last 100 trades.client.get_trade_history()Create New ActionsCreate OrderValid order params include:NameParamDescriptionInstrumentinstrumentenum:['BTC_USD, USD_BTC']Sidesideenum:['buy', 'sell'], requiredtrueOrder TypeorderTypeenum:['limit', 'market'], requiredtruePricepricestring, requiredfalseQuantityquantitystring, requiredfalse# create a JSON object with the following paramsorder={"instrument":"BTC_USD","side":"buy","orderType":"limit","price":"600","quantity":"0.2346"}client.create_order(body=order)# http://api.buttercoin.com/v1/orders/b9fa58e6-a441-48ca-afbb-14827fca2f7aCreate TransactionPlease contact Buttercoin support before creating a USD deposit using the API.Deposit transaction params include:NameParamDescriptionMethodmethodenum:['wire'], requiredtrueCurrencycurrencyenum:['USD'], requiredtrueAmountamountstring, requiredtrue# create deposittxn={"method":"wire","currency":"USD","amount":"500"}client.create_deposit(body=txn)# https://api.buttercoin.com/v1/transactions/53db06ee7400007700f4c561Withdrawal transaction params include:NameParamDescriptionMethodmethodenum:['check'], requiredtrueCurrencycurrencyenum:['USD'], requiredtrueAmountamountstring, requiredtrueIf you have the security setting requiring confirmation of dollar withdrawals, you will see a 201 status.# create withdrawaltxn={"currency":"USD","amount":"3020.30","method":"check"}json=client.create_withdrawal(body=txn)# https://api.buttercoin.com/v1/transactions/53db06ee7400007700f4c561Send bitcoin transaction params include:NameParamDescriptionCurrencycurrency['USD'], requiredtrueAmountamountstring, requiredtrueDestinationdestinationaddress to which to send currencystring, requiredtrueIf you have the security setting requiring confirmation of bitcoin
withdrawals, you will see a 201 status# send bitcoins to an addresstxn={"currency":"BTC","amount":"0.30","destination":"msj42CCGruhRsFrGATiUuh25dtxYtnpbTx"}json=client.send_bitcoin(body=txn)# https://api.buttercoin.com/v1/transactions/53db06ee7400007700f4c561Cancel ActionsAll successful cancel calls to the API return a response status of204with a human readable success messageCancel OrderCancel a pending buy or sell orderclient.cancel_order('<order_id>')Cancel TransactionCancel a pending deposit or withdraw actionclient.cancel_transaction('<transaction_id>')Further ReadingButtercoin - WebsiteButtercoin API DocumentationLicenseLicensed under the MIT license.Copyright 2015Buttercoin Inc. All Rights Reserved.