Comments (7)
I'm getting the same issue, but have found the solution. In your python library, if you installed via pip, go to /site-packages/coinbase/wallet/client.py:
Change this section:
def get_spot_price(self, **params):
"""https://developers.coinbase.com/api/v2#get-spot-price"""
response = self._get('v2', 'prices', 'spot', data=params)
return self._make_api_object(response, APIObject)
to:
def get_spot_price(self, **params):
"""https://developers.coinbase.com/api/v2#get-spot-price"""
if 'currency_pair' in params:
currency_pair = params['currency_pair']
else:
currency_pair = 'BTC-USD'
response = self._get('v2', 'prices', currency_pair, 'spot', data=params)
return self._make_api_object(response, APIObject)
This will get you the correct results for ETH-USD prices.
The problem now is that, the client.py file in the repo has already been updated to the code above, but has not been pushed for pip installation, so either you install the package from the repo or have to go in and change the settings in Python.
Update:
If you don't like that option above (like messing with the client file), put this in your "own" python file:
def _get_COIN_prices_(price_option, coin_option, currency):
""" Gets the prices of coins with "coin_option"
"coin_options" = BTC, ETH, LTC
"price_options" = buy, sell, spot
"currency" = USD, EUR, etc
Base API endpoint = "https://api.coinbase.com/v2/prices/
Currently using version 2, if you want to use version 1, switch to:
Base API endpoint = "https://api.coinbase.com/v1/prices/
"""
url = "https://api.coinbase.com/v2/prices/" + coin_option + "-" + currency + "/" + price_option
header = ({'Accept': 'application/json',
'Content-Type': 'application/json',
'User-Agent': 'coinbase/python/2.0'})
response = requests.get(url, headers=header)
jsonData = json.loads(response.content)
return jsonData
Then in your main method do:
coin_price = _get_COIN_prices_("buy", "ETH", "USD")
ETH_price = coin_price['data']['amount']
print ETH_price
from coinbase-python.
Same issue.
from coinbase-python.
Take a look at my comment here . It might be that you have not updated your api version.
from coinbase-python.
I'm on 2.0.6 and getting the issue. I don't think this is a version thing.
from coinbase-python.
I chose to modify the client.py directly. Thanks
from coinbase-python.
This may be a silly question. I installed coinbase via pip(3). The package I got includes the old version of client where the 'currency_pair' isn't used. Will we get a new release or it is recommended to install from source?
from coinbase-python.
Just to update, if anyone is using the code above, changing
price = client.get_spot_price(currency_code = 'ETH-USD')
to
price = client.get_spot_price(currency_pair = 'ETH-USD')
makes the code work as intended.
from coinbase-python.
Related Issues (20)
- Assistance with basic beginner question HOT 2
- from test.helpers import mock_response ImportError: No module named helpers HOT 2
- InternalServerError when calling get_notifications HOT 1
- Switch from pycrypto to PyCryptodome HOT 3
- always getting error HOT 2
- [Improvement} Creating Accounts HOT 1
- coinbase.wallet.error.ParamRequiredError: APIError(id=param_required): Required parameter missing: to HOT 1
- commerce support? HOT 1
- Random "invalid signature" errors when more than one parameter HOT 2
- client.sell(account_id, amount='1', currency='BTC') HOT 1
- get historic spot price returns current price HOT 1
- No resource_path returned in API calls to resource collections. HOT 1
- Provide exchange_code method to exchange temporary code with access token HOT 1
- Invalid signature HOT 1
- Why am I Getting a βtradeβ Transaction Type from Coinbase API? HOT 1
- Coinbase provides key, but no secret HOT 2
- Various Intermittent Request Errors: ('Connection aborted.', OSError("(104, 'ECONNRESET')",)) HOT 3
- send_money's idempotence parameter stopped working HOT 1
- get_address_transactions not working for ethereum and litecoin HOT 2
- Coinbase account.transferMoney returning "Not Found" (NodeJS lib)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coinbase-python.