Why Coinbase API doesn't return the sell price for XRP? - coinbase-api

For various cryptocurrencies, the API returns a valid response with a sell price or spot price. Just like in this example:
❯ curl 'https://api.coinbase.com/v2/prices/XLM-EUR/sell'
{"data":{"base":"XLM","currency":"EUR","amount":"0.32"}}
But for XRP, it returns an error. Why? 'm guessing that it may be related to the fact that Coinbase has suspended buying XRP, but selling it is still possible so getting the rate may be required.
❯ curl 'https://api.coinbase.com/v2/prices/XRP-EUR/sell'
{"errors":[{"id":"not_found","message":"Invalid base currency"}]}

I'm having the same problem using the wallet client with the code below.
coinbase.wallet.client.Client(
my_key, my_secret, api_version=my_version,
).get_spot_price(currency_pair='XRP-USD')
It would be great to see this resolved.

Related

Mint a NFT with React, Error: cannot estimate gas; transaction may fail or may require manual gas limit

I created a smart contract based on “Build your own Ethereum NFT Collection” tutorial, in buildspace, using the Goerli Testnet.
That contract successfully worked and I confirmed that it was minted on Goerli Etherscan and the Opensea Testnet.
However, when I used the same code to deploy the smart contract to the Ethereum Mainnet, the smart contract did not go through.The console of Chrome DevTools printed the following error:
Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See:
https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT
] (reason=“execution reverted”, method=“estimateGas”, transaction= … (…)
The code I wrote following the tutorial is at this Github repository:
https://github.com/miu-null/smartcontract/
and my mint page is here:
https://miu-null.github.io/mint/
Could it be that there is an issue with my contract code? or just something wrong in my React code? I would be grateful if I could get any help. As you may know, I just completed the tutorial and I’m having trouble understanding this error. Thank you in advance for your response.
I tried to edit to add estimate gasPrice in my React code,
`for example :
const gasPrice = await provider.getGasPrice();
const gasPriceInGwei = ethers.utils.formatUnits(gasPrice, "gwei");
const currGas = setGasPrice(gasPriceInGwei);
`
and then..
honestly I'm not sure that currGas(it means gasPrice) is connected to my contract.

How can I set a deposit tag for XRP transactions using the Coinbase API?

I am playing with the Coinbase API and am attempting to send XRP from my Coinbase wallet to another account (outside of Coinbase). The Coinbase send API (https://developers.coinbase.com/api/v2#send-money) allows me to set the destination address but there is no means of setting the destination tag, which is required for XRP transfers.
How can I set the destination tag?
The Coinbase Pro API has documentation for their platform that hints at a possible solution (https://docs.pro.coinbase.com/?r=1#crypto). Two parameters of interest are destination_tag and no_destination_tag. So if you want to send XRP using Python, you might say the following:
client.send_money(account_id = <account-id>,
to = <destination-address>,
amount = <amount>,
currency = 'XRP',
destination_tag = <destination-tag>,
no_destination_tag = False)
If you don't want to use the destination tag, you can just omit the destination_tag parameter and set no_destination_tag to True.
Extremely late to this but figured it'll be useful for someone else stumbling onto this thread.
I've just tested putting deposit_tag into the POST request to Coinbase's API (not Coinbase Pro) and it successfully puts the deposit tag through.
Coinbase also doesn't allow you to send XRP if you don't specify a deposit tag, which is handy.

How to get seller name from Seller Id using Amazon MWS API

I got the PriceChangedNotification by http://docs.developer.amazonservices.com/en_US/subscriptions/Subscriptions_NotificationType.html.
It returns Seller ID of new offer per ASIN.
I need to get the Seller's name by Seller ID.
How can I do that?
What we did is took a list of the sellerID's and did a scrape using a URL like this: https://www.amazon.com/sp?seller=xxxxxxxxxxx for each seller id. Then pull the seller name out of the resulting html (look for id=sellerName) and stored that in a table. Then when I get a PriceChangedNotification, I join to my sellers table to produce my reports, or whatever else I may need.
Keepa has a nice API that can get this for you and lots of other things that MWS won't. It's not free, but it might be worth it if you have a bunch of things you want to get from Amazon and don't want to scrape everything yourself. Unfortunately, it seems MWS keeps becoming more restrictive.
https://keepa.com/#!discuss/t/request-seller-information/790?u=keepa
The rabbit hole brought me here. Considering I spent an hour googling and testing, here it is so the next one may save some time.
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
seller_id = ""
s = requests.Session()
url = f"https://www.amazon.co.uk/sp?seller={seller_id}"
headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0',
"Cookie":'i18n-prefs=GBP;' # won't work without this cookie
}
r = s.get(url, headers=headers)
# >> print(r) --> response 200
soup = BeautifulSoup(r.text, "html.parser")
soup.find("h1", {"id": "sellerName"}).text
important things to note: Amazon blocks scrapers, you'll need to simulate a http request. Use postman to ping the particular URL you are interested in and look at what headers it sends, in particular what cookies it sends. In this case my request wouldn't work without the i18n-prefs cookie.

How to fix memory leak in my application?

In my GAE app I add rows to Google Spreadsheet.
taskqueue.add(url='/tabletask?u=%s' % (user_id),
retry_options=taskqueue.TaskRetryOptions(task_retry_limit=0),
method='GET')
class TableTaskHandler(webapp2.RequestHandler):
def get(self):
user_id = self.request.get('u')
if user_id:
try:
tables.add_row(
user_id
)
except Exception, error_message:
pass
def get_google_api_service(scope='https://www.googleapis.com/auth/spreadsheets', api='sheets', version='v4'):
''' Login to Google API with service account and get the service
'''
service = None
try:
credentials = AppAssertionCredentials(scope=scope)
http = credentials.authorize(httplib2.Http(memcache))
service = build(api, version, http=http)
except Exception, error_message:
logging.exception('Failed to get Google API service, exception happened - %s' % error_message)
return service
def add_row(user_id, user_name, project_id, question, answer, ss_id=SPREADSHEET_ID):
service = get_google_api_service()
if service:
values = [
[
user_id, user_name, project_id, question, answer # 'test1', 'test2'
],
# Additional rows ...
]
body = {
'values': values
}
# https://developers.google.com/sheets/api/guides/values#appending_values
response = service.spreadsheets().values().append(
spreadsheetId=ss_id,
range='A1:E1000',
valueInputOption='RAW',
body=body).execute()
I add many tasks with different row values.
In result I get critical errors 'Exceeded soft private limit of 128 Mb with 158 Mb' after servicing 5 requests in total.
What could be wrong here?
At first glance there’s nothing special in your code that might lead to a memory leak.
I don’t think anybody can locate it unless he’s very deeply familiar with the 3rd party libraries used and their existing bugs. So I’d approach the problem as follows:
First lets find out where exactly memory is leaking and whether it’s leaking at all.
Refer to tracemalloc, memory_profiler, heapy or whatever else you’re familiar with. Most profilers available are listed here Which Python memory profiler is recommended?
Expected outcome: you clearly know where exactly the memory is leaking, up to a code line / python expression
If the problem is in a 3rd party code, try to dig deeper into its code and figure out what’s up there
Depending on p.2 outcome
a. Post another SO question like ‘why this python code excerpt leads to a memory leak’ - ideally it should be a standalone code snippet that leads to a weird behavior free of any third party libraries and reproducible locally. Environment specification - at least python version, is appreciated
b. If the problem is in a 3rd party library and you’ve located the problem, open a bug report on github/anywhere the target project is hosted
c. If the problem is clearly in a 3rd party library and you’re unable to find the cause, open a ticket describing the case with the profiler's report attached
It seems to be that you are running instance class B1 or F1, which has a memory limit of 128 MB.
A possible solution would be to use a higher instance class. But please keep in mind that choosing a different instance class will have impact on your pricing and quotas.

API : Ticker info

The Coinbase Exchange API: ticker GET /products/<product-id>/ticker only provides the last close. In order to place a market order, I need the best ask and bid (based on the side) price. Almost all exchanges provide this with their ticker API, so I am little surprised coinbase doesn't.
What am I missing? Is there any way I can get that information.
You can use the Order Book endpoint: GET /products/<product-id>/book to get that information. Further details are available here.
Doing it with rest template, java. The end point to hit is:
$ while true ; do curl http://api.pro.coinbase.com/products/BTC-USD/ticker ; echo ; done
Make sure, you use https. http will return nothing
while true ; do curl http://api.pro.coinbase.com/products/BTC-USD/ticker ; echo ; done

Resources