Convert from one crypto to another using Coinbase API
Asked Answered
M

1

6

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 ?

Missal answered 2/8, 2020 at 8:35 Comment(4)
Which api library are you using?Peeples
Have you tried to use the account.transfer_money() method instead of the client.transfer_money()?Uncharted
@GauthamramRavichandran I am using the coinbase REST API ```developers.coinbase.com/api/v2#send-moneyMissal
@Uncharted I'm attempting to do the same thing as the OP, and the account.transfer_money() method produces the same error as the client.transfer_money() methodCampion
P
0

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

Peeples answered 16/8, 2020 at 3:37 Comment(4)
Tried the same with your forked library and got the same error. client.transfer_money( btc_id, to=eth_id, amount=btc_amount.amount, currency="BTC")Missal
Submit an issue at repo, with all info., like what's your exact input and also the full tracebackPeeples
@GauthamramRavichandran I'm having the same error as the OP, but there is no Issues tab in your forked repo for us to submit an issue. I've attempted to run the same code as the OP but using my own account IDs (still sourced from client.get_accounts())Campion
Sorry for that. Have enabled the Issues, please submit an issue with all the relevant artifacts I askedPeeples

© 2022 - 2024 — McMap. All rights reserved.