简体   繁体   中英

Convert from one crypto to another using Coinbase API

I was trying to create a python program to convert ETH to 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:

client.get_accounts()

And copy pasted the IDs onto my transfer command. 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. You can try using that, if issues still persists, submit an issue on GitHub repo

I wrote a little script to exchange cryptocurrencies on 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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