bitcoin api curl

Jump to: , Contents 1 2 3 4 5 6 7 8 9 C Run bitcoind or bitcoin-qt -server.You can control it via the command-line bitcoin-cli utility or by HTTP JSON-RPC commands.You must create a bitcoin.conf configuration file setting an rpcuser and rpcpassword; see Running Bitcoin for details.A list of RPC calls will be shown.If you are learning the API, it is a very good idea to use the test network (run bitcoind -testnet and bitcoin-cli -testnet).Running Bitcoin with the -server argument (or running bitcoind) tells it to function as a HTTP JSON-RPC server, but Basic access authentication must be used when communicating with it, and, for security, by default, the server only accepts connections from other processes on the same machine.If your HTTP or JSON library requires you to specify which 'realm' is authenticated, use 'jsonrpc'.Bitcoin supports SSL (https) JSON-RPC connections beginning with version 0.3.14.See the rpcssl wiki page for setup instructions and a list of all bitcoin.conf configuration options.
Allowing arbitrary machines to access the JSON-RPC port (using the rpcallowip configuration option) is dangerous and strongly discouraged-- access should be strictly limited to trusted machines.To access the server you should find a suitable library for your language.See the proper money handling page for notes on avoiding rounding errors when handling bitcoin values.python-jsonrpc is the official JSON-RPC implementation for Python.It automatically generates Python methods for RPC calls.However, due to its design for supporting old versions of Python, it is also rather inefficient.jgarzik has forked it as Python-BitcoinRPC and optimized it for current versions.Generally, this version is recommended.While BitcoinRPC lacks a few obscure features from jsonrpc, software using only the ServiceProxy class can be written the same to work with either version the user might choose to install: The latest version of python-bitcoinrpc has a new syntax.By default the client will use the configuration in $HOME/.bitcoin/bitcoin.conf or you can instead specify a URI like this: Here is a usage example: The JSON-RPC PHP library also makes it very easy to connect to Bitcoin.
For example: Note: The jsonRPCClient library uses fopen() and will throw an exception saying "Unable to connect" if it receives a 404 or 500 error from bitcoind.litecoin news ukThis prevents you from being able to see error messages generated by bitcoind (as they are sent with status 404 or 500).bitcoin port routerThe EasyBitcoin-PHP library is similar in function to JSON-RPC PHP but does not have this issue.ethereum rallyThe easiest way to tell Java to use HTTP Basic authentication is to set a default Authenticator: Once that is done, any JSON-RPC library for Java (or ordinary URL POSTs) may be used to communicate with the Bitcoin server.ethereum investment calculator
Instead of writing your own implementation, consider using one of the existing wrappers like BitcoindClient4J, btcd-cli4j or Bitcoin-JSON-RPC-Client instead.bitcoin indonesia-1stThe JSON::RPC package from CPAN can be used to communicate with Bitcoin.bitcoin ebay ceoYou must set the client's credentials; for example: The btcrpcclient package can be used to communicate with Bitcoin.bitcoin core change walletYou must provide credentials to match the client you are communicating with.bitcoin india allianceThe communication with the RPC service can be achieved using the standard http request/response objects.ubuntu bitcoin usb
A library for serializing and deserializing Json will make your life a lot easier: /json ) is a high performance JSON package for .NET.It is also available via NuGet from the package manager console ( Install-Package Newtonsoft.Json ).The following example uses Json.NET: There is also a wrapper for Json.NET called Bitnet (https://sourceforge.net/projects/bitnet) implementing Bitcoin API in more convenient way: /GeorgeKimionis/BitcoinLib) which is also available via NuGet from the package manager console (Install-Package BitcoinLib).Querying the daemon with BitcoinLib is as simple as: You can also send commands and see results using cURL or some other command-line HTTP-fetching utility; for example: You will be prompted for your rpcpassword, and then will see something like: clj-btc is a Clojure wrapper for the bitcoin API.The C API for processing JSON is Jansson.C applications like libblkmaker use cURL for making the calls and Jansson for interpreting the JSON that cURL fetches.
For example basic usage (which can be easily modified for Bitcoin RPC), see the Jansson example github_commits.c and the associated tutorial.The following does with libcurl what the does:This output can be parsed with Jansson, the Jansson tutorial linked to above.QJsonRpc is a Qt/C++ implementation of the JSON-RPC protocol.It integrates nicely with Qt, leveraging Qt's meta object system in order to provide services over the JSON-RPC protocol.QJsonRpc is licensed under the LGPLv2.1./iuezwGRZ /fbkheaRb /dMX7mZE0 The best way to get public data updates on markets is via the push API, which pushes live ticker, order book, trade, and Trollbox updates over WebSockets using the WAMP protocol. and subscribe to the desired feed.In order to receive ticker updates, subscribe to "ticker".Updates will be in the following format: Appropriate labels for these data are, in order: currencyPair, last, lowestAsk, highestBid, percentChange, baseVolume, quoteVolume, isFrozen, 24hrHigh, 24hrLow To receive order book and trade updates, subscribe to the desired currencyPair, e.g.
There are two types of order book updates: [{data: {rate: '0.00300888', type: 'bid', amount: '3.32349029'},type: 'orderBookModify'}] [{data: {rate: '0.00311164', type: 'ask' },type: 'orderBookRemove'}] Updates of type orderBookModify can be either additions to the order book or changes to existing entries.The value of 'amount' indicates the new total amount on the books at the given rate — in other words, it replaces any previous value, rather than indicates an adjustment to a previous value.Trade history updates are provided in the following format: [{data: {tradeID: '364476',rate: '0.00300888',amount: '0.03580906',date: '2014-10-07 21:51:20',total: '0.00010775',type: 'sell'},type: 'newTrade'}] The dictionary portion of each market message ("kwargs" in the Node.js example) will contain a sequence number with the key "seq".In order to keep your order book consistent, you will need to ensure that messages are applied in the order of their sequence numbers, even if they arrive out of order.
In some markets, if there is no update for more than 1 second, a heartbeat message consisting of an empty argument list and the latest sequence number will be sent.These will go out once per second, but if there is no update for more than 60 seconds, the heartbeat interval will be reduced to 8 seconds until the next update.Several order book and trade history updates will often arrive in a single message.Be sure to loop through the entire array, otherwise you will miss some updates.In order to receive new Trollbox messages, subscribe to "trollbox".Messages will be given in the following format: Appropriate labels for these data are, in order: type, messageNumber, username, message, reputation Please note that making more than 6 calls per second to the public API, or repeatedly and needlessly fetching excessive amounts of data, can result in your IP being banned.There are six public methods, all of which take HTTP GET requests and return output in JSON format: returnTicker Returns the ticker for all markets.
Sample output: {"BTC_LTC":{"last":"0.0251","lowestAsk":"0.02589999","highestBid":"0.0251","percentChange":"0.02390438", "baseVolume":"6.16485315","quoteVolume":"245.82513926"},"BTC_NXT":{"last":"0.00005730","lowestAsk":"0.00005710", "highestBid":"0.00004903","percentChange":"0.16701570","baseVolume":"0.45347489","quoteVolume":"9094"}, ... } /public?command=returnTicker return24Volume Returns the 24-hour volume for all markets, plus totals for primary currencies.Sample output: {"BTC_LTC":{"BTC":"2.23248854","LTC":"87.10381314"},"BTC_NXT":{"BTC":"0.981616","NXT":"14145"}, ... "totalBTC":"81.89657704","totalLTC":"78.52083806"} /public?command=return24hVolume returnOrderBook Returns the order book for a given market, as well as a sequence number for use with the Push API and an indicator specifying whether the market is frozen.You may set currencyPair to "all" to get the order books of all markets.Sample output: {"asks":[[0.00007600,1164],[0.00007620,1300], ... ], "bids":[[0.00006901,200],[0.00006900,408], ... ], "isFrozen": 0, "seq": 18849} {"BTC_NXT":{"asks":[[0.00007600,1164],[0.00007620,1300], ... ], "bids":[[0.00006901,200],[0.00006900,408], ... ], "isFrozen": 0, "seq": 149},"BTC_XMR":...} /public?command=returnOrderBook¤cyPair=BTC_NXT&depth=10 returnTradeHistory Returns the past 200 trades for a given market, or up to 50,000 trades between a range specified in UNIX timestamps by the "start" and "end" GET parameters.
Sample output: [{"date":"2014-02-10 04:23:23","type":"buy","rate":"0.00007600","amount":"140","total":"0.01064"},{"date":"2014-02-10 01:19:37","type":"buy","rate":"0.00007600","amount":"655","total":"0.04978"}, ... ] /public?command=returnTradeHistory¤cyPair=BTC_NXT&start=1410158341&end=1410499372 returnChartData Returns candlestick chart data.Required GET parameters are "currencyPair", "period" (candlestick period in seconds; valid values are 300, 900, 1800, 7200, 14400, and 86400), "start", and "end"."Start" and "end" are given in UNIX timestamp format and used to specify the date range for the data returned.Sample output: [{"date":1405699200,"high":0.0045388,"low":0.00403001,"open":0.00404545,"close":0.00427592,"volume":44.11655644, "quoteVolume":10259.29079097,"weightedAverage":0.00430015}, ...] /public?command=returnChartData¤cyPair=BTC_XMR&start=1405699200&end=9999999999&period=14400 returnCurrencies Returns information about currencies.
Sample output: {"1CR":{"maxDailyWithdrawal":10000,"txFee":0.01,"minConf":3,"disabled":0},"ABY":{"maxDailyWithdrawal":10000000,"txFee":0.01,"minConf":8,"disabled":0}, ... } /public?command=returnCurrencies returnLoanOrders Returns the list of loan offers and demands for a given currency, specified by the "currency" GET parameter.Sample output: {"offers":[{"rate":"0.00200000","amount":"64.66305732","rangeMin":2,"rangeMax":8}, ... ],"demands":[{"rate":"0.00170000","amount":"26.54848841","rangeMin":2,"rangeMax":2}, ... ]} /public?command=returnLoanOrders¤cy=BTC To use the trading API, you will need to create an API key.Please note that there is a default limit of 6 calls per second.If you require more than this, please consider optimizing your application using the push API, the "moveOrder" command, or the "all" parameter where appropriate.If this is still insufficient, please contact support to discuss a limit raise./tradingApi and must contain the following headers: Additionally, all queries must include a "nonce" POST parameter.
The nonce parameter is an integer which must always be greater than the previous nonce used.All responses from the trading API are in JSON format.In the event of an error, the response will always be of the following format: There are several methods accepted by the trading API, each of which is specified by the "command" POST parameter: returnBalances Returns all of your available balances.Sample output: {"BTC":"0.59098578","LTC":"3.31117268", ... } returnCompleteBalances Returns all of your balances, including available balance, balance on orders, and the estimated BTC value of your balance.By default, this call is limited to your exchange account; set the "account" POST parameter to "all" to include your margin and lending accounts.Sample output: {"LTC":{"available":"5.015","onOrders":"1.0025","btcValue":"0.078"},"NXT:{...} ... } returnDepositAddresses Returns all of your deposit addresses.Sample output: {"BTC":"19YqztHmspv2egyD6jQM3yn81x5t5krVdJ","LTC":"LPgf9kjv9H1Vuh4XSaKhzBe8JHdou1WgUB", ... "ITC":"Press Generate.."
... } generateNewAddress Generates a new deposit address for the currency specified by the "currency" POST parameter.Sample output: {"success":1,"response":"CKXbbs8FAVbtEa397gJHSutmrdrBrhUMxe"} Only one address per currency per day may be generated, and a new address may not be generated before the previously-generated one has been used.returnDepositsWithdrawals Returns your deposit and withdrawal history within a range, specified by the "start" and "end" POST parameters, both of which should be given as UNIX timestamps."txid":"7acb90965b252e55a894b535ef0b0b65f45821f2899e4a379d3e43799604695c","timestamp":1399245916,"status":"COMPLETE"}], "withdrawals":[{"withdrawalNumber":134933,"currency":"BTC","address":"1N2i5n8DwTGzUq2Vmn9TUL8J1vdr1XBDFg","amount":"5.00010000", "timestamp":1399267904,"status":"COMPLETE: 36e483efa6aff9fd53a235177579d98451c4eb237c210e66cd2b9a2d4a988f8e","ipAddress":"..."}]}returnOpenOrders Returns your open orders for a given market, specified by the "currencyPair" POST parameter, e.g.
Set "currencyPair" to "all" to return open orders for all markets.Sample output for single market: [{"orderNumber":"120466","type":"sell","rate":"0.025","amount":"100","total":"2.5"},{"orderNumber":"120467","type":"sell","rate":"0.04","amount":"100","total":"4"}, ... ] {"BTC_1CR":[],"BTC_AC":[{"orderNumber":"120466","type":"sell","rate":"0.025","amount":"100","total":"2.5"},{"orderNumber":"120467","type":"sell","rate":"0.04","amount":"100","total":"4"}], ... } returnTradeHistory Returns your trade history for a given market, specified by the "currencyPair" POST parameter.You may specify "all" as the currencyPair to receive your trade history for all markets.You may optionally specify a range via "start" and/or "end" POST parameters, given in UNIX timestamp format; if you do not specify a range, it will be limited to one day.Sample output: [{ "globalTradeID": 25129732, "tradeID": "6325758", "date": "2016-04-05 08:08:40", "rate": "0.02565498", "amount": "0.10000000", "total": "0.00256549", "fee": "0.00200000", "orderNumber": "34225313575", "type": "sell", "category": "exchange" }, { "globalTradeID": 25129628, "tradeID": "6325741", "date": "2016-04-05 08:07:55", "rate": "0.02565499", "amount": "0.10000000", "total": "0.00256549", "fee": "0.00200000", "orderNumber": "34225195693", "type": "buy", "category": "exchange" }, ... ] {"BTC_MAID": [ { "globalTradeID": 29251512, "tradeID": "1385888", "date": "2016-05-03 01:29:55", "rate": "0.00014243", "amount": "353.74692925", "total": "0.05038417", "fee": "0.00200000", "orderNumber": "12603322113", "type": "buy", "category": "settlement" }, { "globalTradeID": 29251511, "tradeID": "1385887", "date": "2016-05-03 01:29:55", "rate": "0.00014111", "amount": "311.24262497", "total": "0.04391944", "fee": "0.00200000", "orderNumber": "12603319116", "type": "sell", "category": "marginTrade" }, ... ],"BTC_LTC":[ ... ] ... } returnOrderTrades Returns all trades involving a given order, specified by the "orderNumber" POST parameter.
If no trades for the order have occurred or you specify an order that does not belong to you, you will receive an error.Sample output: [{"globalTradeID": 20825863, "tradeID": 147142, "currencyPair": "BTC_XVC", "type": "buy", "rate": "0.00018500", "amount": "455.34206390", "total": "0.08423828", "fee": "0.00200000", "date": "2016-03-14 01:04:36"}, ...] buy Places a limit buy order in a given market.Required POST parameters are "currencyPair", "rate", and "amount".If successful, the method will return the order number.Sample output: {"orderNumber":31226040,"resultingTrades":[{"amount":"338.8732","date":"2014-10-18 23:03:21","rate":"0.00000173","total":"0.00058625","tradeID":"16164","type":"buy"}]} You may optionally set "fillOrKill", "immediateOrCancel", "postOnly" to 1.A fill-or-kill order will either fill in its entirety or be completely aborted.An immediate-or-cancel order can be partially or completely filled, but any portion of the order that cannot be filled immediately will be canceled rather than left on the order book.
A post-only order will only be placed if no portion of it fills immediately; this guarantees you will never pay the taker fee on any part of the order that fills.sell Places a sell order in a given market.Parameters and output are the same as for the buy method.cancelOrder Cancels an order you have placed in a given market.Required POST parameter is "orderNumber".If successful, the method will return: moveOrder Cancels an order and places a new one of the same type in a single atomic transaction, meaning either both operations will succeed or both will fail.Required POST parameters are "orderNumber" and "rate"; you may optionally specify "amount" if you wish to change the amount of the new order."postOnly" or "immediateOrCancel" may be specified for exchange orders, but will have no effect on margin orders.Sample output: {"success":1,"orderNumber":"239574176","resultingTrades":{"BTC_BTS":[]}} withdraw Immediately places a withdrawal for a given currency, with no email confirmation.
In order to use this method, the withdrawal privilege must be enabled for your API key.Required POST parameters are "currency", "amount", and "address".For XMR withdrawals, you may optionally specify "paymentId".Sample output: {"response":"Withdrew 2398 NXT."}returnFeeInfo If you are enrolled in the maker-taker fee schedule, returns your current trading fees and trailing 30-day volume in BTC.This information is updated once every 24 hours.{"makerFee": "0.00140000", "takerFee": "0.00240000", "thirtyDayVolume": "612.00248891", "nextTier": "1200.00000000"} returnAvailableAccountBalances Returns your balances sorted by account.You may optionally specify the "account" POST parameter if you wish to fetch only the balances of one account.Please note that balances in your margin account may not be accessible if you have any open margin positions or orders.Sample output: {"exchange":{"BTC":"1.19042859","BTM":"386.52379392","CHA":"0.50000000","DASH":"120.00000000","STR":"3205.32958001", "VNL":"9673.22570147"},"margin":{"BTC":"3.90015637","DASH":"250.00238240","XMR":"497.12028113"},"lending":{"DASH":"0.01174765","LTC":"11.99936230"}} returnTradableBalances Returns your current tradable balances for each currency in each market for which margin trading is enabled.
Please note that these balances may vary continually with market conditions.Sample output: {"BTC_DASH":{"BTC":"8.50274777","DASH":"654.05752077"},"BTC_LTC":{"BTC":"8.50274777","LTC":"1214.67825290"},"BTC_XMR":{"BTC":"8.50274777","XMR":"3696.84685650"}} transferBalance Transfers funds from one account to another (e.g.from your exchange account to your margin account).Required POST parameters are "currency", "amount", "fromAccount", and "toAccount".Sample output: {"success":1,"message":"Transferred 2 BTC from exchange to margin account."}returnMarginAccountSummary Returns a summary of your entire margin account.This is the same information you will find in the Margin Account section of the Margin Trading page, under the Markets list.Sample output: {"totalValue": "0.00346561","pl": "-0.00001220","lendingFees": "0.00000000","netValue": "0.00345341","totalBorrowedValue": "0.00123220","currentMargin": "2.80263755"} marginBuy Places a margin buy order in a given market.
You may optionally specify a maximum lending rate using the "lendingRate" parameter.If successful, the method will return the order number and any trades immediately resulting from your order.Sample output: {"success":1,"message":"Margin order placed.","orderNumber":"154407998","resultingTrades":{"BTC_DASH":[{"amount":"1.00000000","date":"2015-05-1022:47:05","rate":"0.01383692","total":"0.01383692","tradeID":"1213556","type":"buy"}]}} marginSell Places a margin sell order in a given market.Parameters and output are the same as for the marginBuy method.getMarginPosition Returns information about your margin position in a given market, specified by the "currencyPair" POST parameter.You may set "currencyPair" to "all" if you wish to fetch all of your margin positions at once.If you have no margin position in the specified market, "type" will be set to "none"."liquidationPrice" is an estimate, and does not necessarily represent the price at which an actual forced liquidation will occur.
If you have no liquidation price, the value will be -1.Sample output: {"amount":"40.94717831","total":"-0.09671314",""basePrice":"0.00236190","liquidationPrice":-1,"pl":"-0.00058655", "lendingFees":"-0.00000038","type":"long"} closeMarginPosition Closes your margin position in a given market (specified by the "currencyPair" POST parameter) using a market order.This call will also return success if you do not have an open position in the specified market.Sample output: {"success":1,"message":"Successfully closed margin position.","resultingTrades":{"BTC_XMR":[{"amount":"7.09215901","date":"2015-05-1022:38:49","rate":"0.00235337","total":"0.01669047","tradeID":"1213346","type":"sell"},{"amount":"24.00289920","date":"2015-05-10 22:38:49","rate":"0.00235321","total":"0.05648386","tradeID":"1213347","type":"sell"}]}} createLoanOffer Creates a loan offer for a given currency.Required POST parameters are "currency", "amount", "duration", "autoRenew" (0 or 1), and "lendingRate".
Sample output: {"success":1,"message":"Loan order placed.","orderID":10590}cancelLoanOffer Cancels a loan offer specified by the "orderNumber" POST parameter.Sample output: {"success":1,"message":"Loan offer canceled."}returnOpenLoanOffers Returns your open loan offers for each currency.Sample output: {"BTC":[{"id":10595,"rate":"0.00020000","amount":"3.00000000","duration":2,"autoRenew":1,"date":"2015-05-10 23:33:50"}],"LTC":[{"id":10598,"rate":"0.00002100","amount":"10.00000000","duration":2,"autoRenew":1,"date":"2015-05-10 23:34:35"}]} returnActiveLoans Returns your active loans for each currency.Sample output: {"provided":[{"id":75073,"currency":"LTC","rate":"0.00020000","amount":"0.72234880","range":2,"autoRenew":0,"date":"2015-05-10 23:45:05","fees":"0.00006000"},{"id":74961,"currency":"LTC","rate":"0.00002000","amount":"4.43860711","range":2,"autoRenew":0,"date":"2015-05-10 23:45:05","fees":"0.00006000"}],"used":[{"id":75238,"currency":"BTC","rate":"0.00020000","amount":"0.04843834","range":2,"date":"2015-05-10 23:51:12","fees":"-0.00000001"}]} returnLendingHistory Returns your lending history within a time range specified by the "start" and "end" POST parameters as UNIX timestamps.