【发布时间】:2018-06-27 17:07:46
【问题描述】:
根据文档,我应该可以使用 coinbase API 购买 ETH(参见 Place buy order)。
现在,看起来我正在获得 BTC。
private static void placeNonCommitBuy(String paymentMethod) {
if (sAccountID != null) {
String url = String.format("https://api.coinbase.com/v2/accounts/%s/buys", sAccountID);
try {
JSONObject params = new JSONObject();
params.put("amount", "0.001");
params.put("currency", "ETH");
params.put("payment_method", paymentMethod);
params.put("agree_btc_amount_varies", true);
params.put("commit", false);
params.put("quote", true);
doPost(url, params, sJustPrint);
} catch (JSONException ex) {
Assert.fail();
}
}
}
我得到了确认:
{
"data": {
"id": <...snip...>,
"status": "created",
"payment_method": {
"id": <...snip...>,
"resource": "payment_method",
"resource_path": <...snip...>
},
"transaction": null,
"user_reference": <...snip...>,
"created_at": "2018-01-18T01:37:15Z",
"updated_at": "2018-01-18T01:37:16Z",
"resource": "buy",
"resource_path": <...snip...>,
"fee": {
"amount": "0.99",
"currency": "USD"
},
"amount": {
"amount": "0.00008968",
"currency": "BTC"
},
"total": {
"amount": "2.02",
"currency": "USD"
},
"subtotal": {
"amount": "1.03",
"currency": "USD"
},
"committed": true,
"payout_at": "2018-01-18T01:37:14Z",
"instant": true,
"requires_completion_step": false
}
}
在网站上,我看到我现在有一些 BTC(价值约 1 美元),但没有 ETH。
我需要使用缺少/未记录的参数吗?还是我的请求有误?
【问题讨论】:
-
你试过
params.put("amount", "0.001 ETH");吗? -
@AdamKipnis 好主意,但不起作用:(
标签: ethereum coinbase-api