5

How to get a transaction fee before sending transaction through coinbase API?

Or how to set a transaction fee for a transaction through coinbase API?

artamonovdev
  • 2,260
  • 1
  • 29
  • 33
  • I don't believe there is any API endpoint for retrieving a transaction's fee. However, Coinbase does keep a consistent fee schedule [here](https://support.coinbase.com/customer/portal/articles/2109597-buy-sell-bank-transfer-fees). I wrote a function that checks the money source I'm using (usually a USD wallet) and then adjusts the calculated fee to make sure it's within the minimum/maximum fee range. – Matthew R. Jan 02 '18 at 22:57
  • @matthew-r I want to find API for getting bitcoin network transaction fee. – artamonovdev Jan 03 '18 at 11:06
  • Do you want the network fee or the Coinbase conversion fee? If you're looking for the network fee (for example, if you were withdrawing from a Coinbase wallet) then I believe Coinbase has a policy that they cover the network fee so you don't need to worry about it. – Matthew R. Jan 03 '18 at 22:25
  • @MatthewR. https://support.coinbase.com/customer/portal/articles/815435 – artamonovdev Jan 04 '18 at 08:38
  • Ah, my mistake. Coinbase charges withdrawal fees. GDAX, however, does not, and it's free to transfer from Coinbase to GDAX. If you want to avoid fees with a little extra work you can transfer from Coinbase to GDAX and then wherever else. From that link it seems Coinbase doesn't provide tx fee data, but you may have some luck estimating it by comparing their fee to the network fees estimated [here](https://bitcoinfees.earn.com/). – Matthew R. Jan 05 '18 at 17:34
  • But how to know size of a transaction (bytes) in coinbase? Here (https://bitcoinfees.earn.com/) is a price (in satoshi) per byte. – artamonovdev Jan 05 '18 at 20:25
  • You may have to estimate it empirically. Transactions are grouped into blocks, and you can find the average block size on the network [here] (https://blockchain.info/charts/avg-block-size). So perhaps you may want to do some testing to see how much Coinbase typically pays in satoshis/byte for each block and then before you send your transaction you check the last block size. Because of the dynamic nature of block size, I'm not sure if you're able to accurately obtain the fee beforehand. – Matthew R. Jan 06 '18 at 22:16

1 Answers1

0

The Coinbase "fee" is the difference between the buy and the sell rate. At the moment It works out to about 1.8%. This is the overall fee, with the miner fees included.

You can query the difference between https://api.coinbase.com/v2/prices/BTC-USD/buy and https://api.coinbase.com/v2/prices/BTC-USD/sell

elliot
  • 772
  • 1
  • 5
  • 14