If i give my API right to all the accounts, it seems to only find certain ones, ETH for example, is not one of them. If i give my API the right to only access my ETH account it finds it fine. Thankful for any help!
Update:
When API accesses all accounts, programm seems to just find the ones i have never touched, meaning they have no transaction history. Here is the code i am trying to use.
import requests
from bs4 import BeautifulSoup
import urllib.request, urllib.parse, urllib.error
from coinbase.wallet.client import Client
from sec import api_key, api_sec
client = Client(api_key, api_sec)
acounts = client.get_accounts()
print(acounts)
for x in acounts.data:
print(x.balance.currency)
ids= []
for wallet in acounts.data:
if len(wallet.get('id'))<10:
continue
id = wallet.get('id')
ids.append(id)
#print(ids)
#print(ids)
for id in ids:
# user = client.get_addresses(id)
# print(user)
txs = client.get_transactions(id)
for tx in txs.data:
print(tx, '\n\n\n')
if float(tx.amount.amount)!=0:
print(tx.amount.currency)
print(tx.amount.amount)
# print(tx.created_at)
print('\n\n\n\n\n')
#break
Hello @Kaur! Thank you for taking an interest in trying out Coinbase APIs. For the details regarding your concern, we will check on this for you with our team. We will get back to you once we have more information. Keep in touch!
Hi @Kaur! In order for us to further investigate the case, can we confirm what Coinbase Cloud API are you trying to use?
We appreciate your patience as we continue to resolve this issue. Thank you!
Hi!
I am trying to use the query client.get_accounts(), where the api i am using is the one i generated in my coinbase account. The response only gives the following accounts: GFI, REP, CRV, BADGER, COMP, CTSI, FOX, ALCX, USDT, DDX, BLZ, FX, TRAC, BAL, IMX, JASMY, SNX, IDEX, SUSHI, PAX, POWR, MIR, BNT, POLS, COVAl. I donât have a transaction history with any of these. On the other hand, with currencies such as ETH and BTC, which I do have a history with, the query doesnât seem to find those. All this happens when my API has access to all the accounts. If given access to just a few, only ETH and BTC for example, it finds those two with ease.
Thank you for your time.
Hi @Kaur, weâve already notified our team about this. We will get back to you once we have more information. Thank you for your patience and understanding.
Hi @kaur! Thank you for your patience as we continue to resolve your issue.
The reason why youâre not seeing BTC and ETH when selecting all wallets is due to your GET request getting paginated. By default, order is set desc and limit is set to 25. BTC and ETH wallets are the first wallets to be added by default. This must be the reason why, when you select all wallets, the response list only contains the wallets that are lastly added.
Adding pagination parameters will solve your issue as it can increase the limit up to 100. Additionally, you may opt to change the order to ascending from the default value of returning the entries in descending order. You may learn more about pagination here.
We hope this helps.
Thanks a lot! Got all those problems solved. I do however wonder how one would get more than a 100 responses, but that isnât really important, as i am only interested in the most popular currencies.
I thought i would let you know, that if I make the get request .get_spot_price, the response is always the following:
"amount": "20252.63", "base": "BTC", "currency": "USD"
the âcurrencyâ stays âUSDâ, even if i input currency = âEURâ, but the value does change to the currency i ask for.
Again thanks a lot for your response, would have never stumbled on paginations myself!
Hi @Kaur! Weâre always happy to help! Please reach out in the future if you need anything else.
With regards to your concern on making a request to the Get Spot Price Endpoint, turns out our team was able to hit this endpoint, and weâve got a valid response. It appears that the endpoint is working as expected.
You may attempt to make a request once again. If the issue still persists, weâll need you to provide us with a screenshot showing the issue as this will be helpful to further investigate your concern.
Thank you for your continued support with Coinbase APIs.
Hi @Anonymouse! Thanks for responding. I am happy to provide more information.
When running the following code you get two different outputs for the .get requests, however they should be the same.
from coinbase.wallet.client import Client
from sec import api_key, api_sec
client = Client(api_key, api_sec)
faulty = client.get_spot_price(currency = 'EUR')
working = client.get_spot_price(currency_pair = 'BTC-EUR')
print(faulty)
print(working)
The output of this code is the following:
{
"amount": "20402.98",
"base": "BTC",
"currency": "USD"
}
{
"amount": "20018.19",
"base": "BTC",
"currency": "EUR"
}
The problems seems to occur when using the parameter âcurrency =â , but if you use âcurrency_pairâ = then it works fine. In my previous post i mentioned, that the price did change accordingly, but that doesnât seem to actually be the case. As seen from the output the prices are different, although i requested them both in âEURâ.
Thanks a lot!
Hi @Kaur! You are correct, the problem seems to occur when using the parameter currency
. This is because the function get_spot_price
has the parameter currency_pair
by definition. This has a default argument/value of BTC-USD
. This means that if you call the function without passing through any arguments, you will be able to successfully call the API and get the spot price of BTC
in terms of USD
.
And so, if you want to query for BTC-EUR
, you will need to use the currency_pair
parameter, instead of currency
.
Itâll look like: client.get_spot_price(currency_pair = 'BTC-EUR')
Consequently, you can also just input EUR
alone as the argument for the currency_pair
parameter for the API to return all supported currencies that can convert to/from EUR
.
This will then look like: client.get_spot_price('EUR')
.
Hope this helps. Thank you!