How to import conversions in coinbase api?

时光怂恿深爱的人放手 提交于 2021-01-29 11:01:29

问题


Right now coinbase supports so called "conversions" that allow to convert from one currency to another. For example, you can convert some of your BTC to XRP.

In CSV they return both buy & sell amount in Notes field: Notes | Converted 0.27235696 BTC to 3,731.323138 XRP.

However, they only return buy amount of that conversion in apy /transactions endpoint:

{"id":"b...8","type":"trade","status":"completed",
"amount":{"amount":"3731.323138","currency":"XRP"},
"native_amount":{"amount":"1790.76","currency":"CAD"},
"description":null,
"...,
"instant_exchange":false,
"trade":{"id":"34...2",
    "resource":"trade","resource_path":"\/v2\/accounts\/e...\/trades\/..,."},
"details":{"title":"Converted to XRP","subtitle":"Using BTC Wallet","payment_method_name":"BTC Wallet"}};

I can't find any way to find how much bitcoin was sold for such conversion using api endpoints. There is also reference to account/id/trades endpoint, but it returns 404 to me


回答1:


I have the same problem and found a way to do it. Every transaction that is a trade has "trade" property which has "id" property. If you converted USDC into XRP, in the XRP transactions of the specific user you will have transaction which has "trade" property with "id" that is the same as the "id" from one of the USDC transactions "trade" property's "id".

trade:
id: "0dfc2e63-21e7-5b25-99d9-49863eb37887"
resource: "trade"
resource_path: "/v2/accounts/a4b1dc86-a813-572b-9978-d1f9c9ba53bc/trades/0dfc2e63-21e7-5b25-99d9-49863eb37887"
__proto__: Object
details:
title: "Converted from USD Coin"
subtitle: "Using USDC Wallet"
payment_method_name: "USDC Wallet"
trade:
id: "0dfc2e63-21e7-5b25-99d9-49863eb37887"
resource: "trade"
resource_path: "/v2/accounts/a4b1dc86-a813-572b-9978-d1f9c9ba53bc/trades/0dfc2e63-21e7-5b25-99d9-49863eb37887"
__proto__: Object
details:
title: "Converted to XRP"
subtitle: "Using USDC Wallet"
payment_method_name: "USDC Wallet"

Look at the trade id of the two transactions. They are the same. Hope this helps.



来源:https://stackoverflow.com/questions/56622382/how-to-import-conversions-in-coinbase-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!