【问题标题】:Convert from one crypto to another using Coinbase API使用 Coinbase API 从一种加密货币转换为另一种加密货币
【发布时间】:2020-11-22 14:36:33
【问题描述】:

我试图创建一个 python 程序来将 ETH 转换为 BTC。我正在使用命令:

client.transfer_money("ETH Account ID ", to="BTC Account ID", amount="0.1", currency=:"ETH")

我已使用以下命令获取帐户 ID:

client.get_accounts()

然后将 ID 复制粘贴到我的传输命令中。但是我得到了这个错误:

~/opt/anaconda3/envs/Coinbase/lib/python3.8/site-packages/coinbase/wallet/client.py in transfer_money(self, account_id, **params)
    338     params['type'] = 'transfer'
    339     response = self._post('v2', 'accounts', account_id, 'transactions', data=params)
--> 340     return self._make_api_object(response, Transaction)
    341 
    342   def request_money(self, account_id, **params):

~/opt/anaconda3/envs/Coinbase/lib/python3.8/site-packages/coinbase/wallet/client.py in _make_api_object(self, response, model_type)
    143     # All valid responses have a "data" key.
    144     if data is None:
--> 145       raise build_api_error(response, blob)
    146     # Warn the user about each warning that was returned.
    147     warnings_data = blob.get('warnings', None)

APIError: APIError(id=): 

有人能查出这个错误是什么吗?

【问题讨论】:

  • 你用的是哪个api库?
  • 您是否尝试过使用account.transfer_money() 方法而不是client.transfer_money()
  • @GauthamramRavichandran 我正在使用 coinbase REST API ```developers.coinbase.com/api/v2#send-money
  • @Challe 我正在尝试做与 OP 相同的事情,而 account.transfer_money() 方法会产生与 client.transfer_money() 方法相同的错误

标签: ethereum bitcoin coinbase-api cryptocurrency


【解决方案1】:

官方库已弃用。

最近引入了 三个错误由于已弃用而未处理),我已在 fork library 中处理了这些错误并在 pypi 中发布。您可以尝试使用它,如果问题仍然存在,请在 GitHub repo 上提交问题

【讨论】:

  • 对你的分叉库进行了同样的尝试,得到了同样的错误。 client.transfer_money(btc_id, to=eth_id, amount=btc_amount.amount, currency="BTC")
  • 在 repo 提交问题,包含所有信息,例如您的确切输入以及完整的回溯
  • @GauthamramRavichandran 我遇到了与 OP 相同的错误,但您的分叉存储库中没有问题选项卡供我们提交问题。我尝试运行与 OP 相同的代码,但使用我自己的帐户 ID(仍然来自 client.get_accounts()
  • 对不起。已启用问题,请提交包含我询问的所有相关工件的问题
猜你喜欢
  • 2014-01-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-16
相关资源
最近更新 更多