简体   繁体   English

使用 Coinbase 从一种加密货币转换为另一种加密货币 API

[英]Convert from one crypto to another using Coinbase API

I was trying to create a python program to convert ETH to BTC.我试图创建一个 python 程序来将 ETH 转换为 BTC。 I was using the command:我正在使用命令:

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

I had obtained the account IDs using the command:我使用以下命令获得了帐户 ID:

client.get_accounts()

And copy pasted the IDs onto my transfer command.并将 ID 复制粘贴到我的传输命令中。 However i get this error:但是我收到此错误:

~/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=): 

Would someone be able to isolate what this error is?有人能找出这个错误是什么吗?

The official library is deprecated.官方图书馆已弃用。

There were three errors introduced recently ( which werenot handled since it's deprecated ), I have handled those error in this fork library and published in pypi.最近引入了三个错误由于不推荐使用而未处理),我已经在这个fork 库中处理了这些错误并在 pypi 中发布。 You can try using that, if issues still persists, submit an issue on GitHub repo您可以尝试使用它,如果问题仍然存在,请在GitHub repo上提交问题

I wrote a little script to exchange cryptocurrencies on Coinbase.我写了一个小脚本来在 Coinbase 上交换加密货币。 It's still very messy and not optimized since I'm still a beginner but it does what it should.它仍然非常混乱并且没有优化,因为我还是一个初学者,但它做了它应该做的事情。 https://github.com/Chel-Jessen/coinbase_convert https://github.com/Chel-Jessen/coinbase_convert

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM