2

From Coinbase API can you convert from Bitcoin to, for example, USDC? I cannot see any reference but I have this feature on the app. I wonder if API supports (or expects support for) this operation, or it just that I'm missing something.

Pataquer
  • 283
  • 1
  • 14

3 Answers3

1

Looking at the Coinbase API PRO Documentation you can create a conversion by:

HTTP REQUEST
POST /conversions

API KEY PERMISSIONS
This endpoint requires the “trade” permission.

Request

{
"from": "USD",
"to": "USDC",
"amount": "10000.00"
}

PARAMETERS

from: A valid currency id
to: A valid currency id
amount: Amount of from to convert to to

Probably more of a question of what the valid currencies are

McNline
  • 178
  • 1
  • 10
1

Without using CoinbasePro API but only Coinbase API from webapp that are the endpoints you need to call:

  1. Have to know base_id of crypto that you want to sell and base_id of crypto want to buy. You can know it by call GET "https://api.coinbase.com/v2/ /assets/prices?base=USD&filter=holdable&resolution=latest" and get from response the "base_id" of your currencies.

  2. Make an order by calling POST "https://api.coinbase.com/v2/trade" with a request body in json like this:

    { 'amount': [amount that you want to convert], 'amount_asset': [currency of amount that you want to convert], 'amount_from': 'input', 'source_asset': ["base_id" of crypto that you want to sell], 'target_asset': ["base_id" of crypto that you want to buy] }

  3. If previous POST "/trade" response code is 201, you have to get the "id" value of response's json and do a commit of your order by calling POST "https://api.coinbase.com/v2/trades/[id of json response of previous https://api.coinbase.com/v2/trade POST"]/commit". If the response code of this POST commit is 201, your exchange is started and if there are not error in coinbase, your conversion is done!

paggio86
  • 21
  • 2
0

There is a reference for this in the Coinbase API documentation: https://developers.coinbase.com/api/v2#transfer-money-between-accounts

But as I stated in my question, it unfortunately doesn't seem to work: Coinbase transfer between accounts returns "Not found"

StingerID4
  • 21
  • 2