bchavez / Coinbase

:moneybag: A .NET/C# implementation of the Coinbase API.

Home Page:https://developers.coinbase.com/api/v2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert Between Coins With API

newbrent opened this issue · comments

Has any api documentation been found that outlines how you can convert between coins? I have only seen this in the web and app interface and can find no API reference.

Hi Brent,

The short answer is there's no Coinbase conversion API. Officially, I don't think there is an API for developers to use for asset conversion. The best place to ask is Coinbase through a support ticket. If they do have an API for asset conversion, please let me know and we can add it to the library.

This could be one way from within the API: I suppose "selling XRP" then using the proceeds to "buy EOS" constitutes a 'conversion' but probably heavy in fees doing it that way.

The long answer is it gets complicated. Converting one asset directly into another asset isn't easy. Coinbase typically uses a "trading backend" (aka market exchange) called Coinbase Pro (also https://github.com/bchavez/Coinbase.Pro for APIs) where the actual trades happen such as swapping USD for BTC. Market prices for various coins constantly fluctuate and depend on the quantity available for sale at a specific price at a specific moment in time. The trading pairs supported by Coinbase Pro are shown here: https://pro.coinbase.com/markets

As an example, suppose you wanted to trade XRP for EOS. The first problem you run into is you need to find someone who is willing to sell you EOS for your XRP (XRP-EOS trading pair). The quantity (or liquidity) market of people who are willing to accept your XRP and sell you EOS directly is probably not that big. Instead, you might find a bigger market of people willing to buy your XRP for USD dollars and conversely, a bigger market of people willing to sell EOS for USD dollars.

So you'd use USD as an intermediary asset for converting XRP to EOS by selling XRP to get dollars and using those dollars to buy EOS. The 'conversion' happens with two trading pairs XRP-USD (a market of those willing to buy/sell XRP for USD) and EOS-USD (a market of those willing to buy/sell EOS for USD).

An alternative approach

If you don't want to deal with the super complexities of managing trades and looking for a simpler solution, you might want to start looking at https://shapeshift.io . Keep in mind, this requires sending crypto outside of Coinbase to a third-party ShapeShift, then ShapeShift uses the market exchanges they are plugged into to find a trade that most cost-effectively executes XRP to EOS, then deposits the EOS into an address (back at Coinbase (hopefully)).

Of course, this carries a bigger risk because now you have to trust a third party to make you whole on that "XRP-EOS" trade. And, they take a small "conversion fee" for the work too.

Hope that helps,
Brian