How to convert via the Coinbase API - coinbase-api

Within the Coinbase app one can convert digital currencies (see the image below).
But does one convert via the Coinbase or Coinbase Pro API?

Watching API from coinbase webapp i see what endpoint you need to call:
Have to know base_id of crypto that you want to sell and base_id of crypto want to buy. You can know it by call GET "https://api.coinbase.com/v2/
/assets/prices?base=USD&filter=holdable&resolution=latest" and get from response the "base_id" of your currencies.
Make an order by calling POST "https://api.coinbase.com/v2/trade" with a request body in json like this:
{
'amount': [amount that you want to convert],
'amount_asset': [currency of amount that you want to convert],
'amount_from': 'input',
'source_asset': ["base_id" of crypto that you want to sell],
'target_asset': ["base_id" of crypto that you want to buy]
}
If previous POST "/trade" response code is 201, you have to get the "id" value of response's json and do a commit of your order by calling POST "https://api.coinbase.com/v2/trades/[id of json response of previous https://api.coinbase.com/v2/trade POST"]/commit". If the response code of this POST commit is 201, your exchange is started and if there are not error in coinbase, your conversion is done!

Related

Selling Partner API Feeds API

I am using the Feeds API to update inventory using the this link. I am able to perform the Step 1 :- Create a feed document response is
{
"payload":{"encryptionDetails":
{
"standard":"AES","initializationVector":"vHLW3sNN41sEQp1e9wjNSg==",
"key":"oQvgdrwiBbBO3SLf4p81zQuIgROkTDA9Yikv6DvMIcg="
},
"feedDocumentId":"amzn1.tortuga.3.11ef10ee-e839-4a0b-b7a4-dcfbe78900ae.T1OWK0QMT4NDF7",
"url":"https://tortuga-prod-eu.s3-eu-west-1.amazonaws.com/%2FNinetyDays/amzn1.tortuga.3.11ef10ee-e839-4a0b-b7a4-dcfbe78900ae.T1OWK0QMT4NDF7?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20210117T190852Z&X-Amz-SignedHeaders=&X-Amz-Expires=300&X-Amz-Credential=&X-Amz-Signature="
}
}
At Step 2 Encrypt and upload the feed data Response :-
SignatureDoesNotMatch
The request signature we calculated does not match the signature you provided. Check your key and signing method.XXXXXXXXXXXXXXXXXXXXAWS4-HMAC-SHA256 20210117T190852Z 20210117/eu-west-1/s3/aws4_request 6efdf3105b88a49723fed6068792a6f1a5858196f957e3a52f76e4cee2ccb07e9197ea9212ce444f640080a3df1d628de0bc26d9a0cafea9577fd23d2c1b3fc6 BYTESPUT //NinetyDays/amzn1.tortuga.3.11ef10ee-e839-4a0b-b7a4-dcfbe78900ae.T1OWK0QMT4NDF7 X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=CREDENTIAL&X-Amz-Date=20210117T190852Z&X-Amz-Expires=300&X-Amz-SignedHeaders=content-type%3Bhost content-type:application/json host:tortuga-prod-eu.s3-eu-west-1.amazonaws.com content-type;host UNSIGNED-PAYLOADBYTESEA417EC74F012746CpSqzu64eIWZv0Y7JWoylN5rrCAJzort9+7EGhH0KqaSHknlV+ZYuX76zqv2shr+yFDksDntFNI=
Anybody facing the same problem or any ideas where the problem is

Converting from BTC to another currency

From Coinbase API can you convert from Bitcoin to, for example, USDC? I cannot see any reference but I have this feature on the app. I wonder if API supports (or expects support for) this operation, or it just that I'm missing something.
Looking at the Coinbase API PRO Documentation you can create a conversion by:
HTTP REQUEST
POST /conversions
API KEY PERMISSIONS
This endpoint requires the “trade” permission.
Request
{
"from": "USD",
"to": "USDC",
"amount": "10000.00"}
PARAMETERS
from: A valid currency id
to: A valid currency id
amount: Amount of from to convert to to
Probably more of a question of what the valid currencies are
There is a reference for this in the Coinbase API documentation:
https://developers.coinbase.com/api/v2#transfer-money-between-accounts
But as I stated in my question, it unfortunately doesn't seem to work:
Coinbase transfer between accounts returns "Not found"
Without using CoinbasePro API but only Coinbase API from webapp that are the endpoints you need to call:
Have to know base_id of crypto that you want to sell and base_id of
crypto want to buy. You can know it by call GET
"https://api.coinbase.com/v2/
/assets/prices?base=USD&filter=holdable&resolution=latest" and get
from response the "base_id" of your currencies.
Make an order by calling POST "https://api.coinbase.com/v2/trade"
with a request body in json like this:
{ 'amount': [amount that you want to convert], 'amount_asset':
[currency of amount that you want to convert], 'amount_from':
'input', 'source_asset': ["base_id" of crypto that you want to
sell], 'target_asset': ["base_id" of crypto that you want to buy] }
If previous POST "/trade" response code is 201, you have to get the
"id" value of response's json and do a commit of your order by
calling POST "https://api.coinbase.com/v2/trades/[id of json
response of previous https://api.coinbase.com/v2/trade POST"]/commit". If
the response code of this POST commit is 201, your exchange is
started and if there are not error in coinbase, your conversion is
done!

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.

GetFeedSubmissionResult is not Giving data in response

I have tried to call GetFeedSubmissionResult api of Amazon MWS Feed submission. i have one Feedsubmissionid which is successfully gives response in "Amazon MWS Scratchpad"
but
In this when i am passing the feedsubmissionid into this api it gives below response,
Service Response=============================================================================
GetFeedSubmissionResultResponse
GetFeedSubmissionResult ContentMd5 YQtHphFPLIcA4vEOn2guCQ==
ResponseMetadata
RequestId
4f715dcf-9e89-4ad5-b721-5bb1ba6bbafa
ResponseHeaderMetadata: RequestId: 4f715dcf-9e89-4ad5-b721-5bb1ba6bbafa, ResponseContext : H5F8Si8GvjCkIIlV+vqovD1zOzXDQ+i7/xRZB46IM/XgePQAAliUi6NzK7tCrVsHM/fZFLhjQkM 0Tvk46V5dJCSmZr22uad,2LvooKOfZwPK75jMl3gDmvuK1oCUt3JWf9UvVTFfXSIhrMpIxkcjQp/ekS0I2neiRcoh0X14RWs0 na0j6cY9ZQ==, Timestamp: 2016-03-09T06:55:38.418Z
Please provide solution as soon as possible.
I get the result in correct format using CURL. I have call API using CURL and i am getting the response in XML format which is actual response.

Resources