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

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.

Related

IBMQProvider issue

I successfully installed and ran a couple of circuits on a backend the other day (essex).
Everything was ok, results came up, but the next day, once I wanted more QC, I could not manage to get a provider.
I have looked into my account (active), looked into the package (up-to-date), and a new file in the project. I also already disabled and enabled the account without problems, but I keep having this error.
Code
from qiskit import IBMQ
IBMQ.active_account()
IBMQ.providers()
provider = IBMQ.get_provider(hub='ibm-q', group='open', project='main')
and I get:
>~/my_environment_name/lib/python3.7/site-packages/qiskit/providers/ibmq/ibmqfactory.py in get_provider(self, hub, group, project)
425 raise IBMQProviderError('No provider matches the specified criteria: '
426 'hub = {}, group = {}, project = {}'
--> 427 .format(hub, group, project))
428 if len(providers) > 1:
429 raise IBMQProviderError('More than one provider matches the specified criteria.'
IBMQProviderError: 'No provider matches the specified criteria: hub = ibm-q, group = open, project = main'
I would like to know where I am wrong, I look forward to keep learning thru the backends efficiently.
Thank you in advance
This means that there is no provider that matches all the criteria you specified, so in that hub, group and project. This could be because your account hasn't loaded correctly, so check to see if anything is returned from IBMQ.providers(). If there isn't anything load your account using IBMQ.load_account(). The other issue could be that there are genuinely no backends that meet those criteria, so try running IBMQ.get_provider() instead.
Try to use API token to enable your IBMQ account.
from qiskit import IBMQ
provider = IBMQ.enable_account("your-api-key") # We load our account
provider.backends() # We retrieve the backends to check their status
for b in provider.backends():
print(b.status().to_dict())
Create IBM Quantum account if you don't have one, then use the API token that available in the dashboard as enable_account() method argument to resolve this issue.
For More: https://quantum-computing.ibm.com/lab/docs/iql/manage/account/ibmq
https://quantum-computing.ibm.com/
https://www.ibm.com/account/reg/us-en/signup?formid=urx-19776&target=https%3A%2F%2Flogin.ibm.com%2Foidc%2Fendpoint%2Fdefault%2Fauthorize%3FqsId%3D70b061b4-7c64-4545-a504-a8871f2d414f%26client_id%3DN2UwMWNkYmMtZjc3YS00

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 the Overall Categories, Sub Categories in Amazon MWS?

Hi I'm started the web development in Amazon MWS. I need to integrate the get category list, add product, list product etc in my application. I have referred the documentation, http://docs.developer.amazonservices.com/en_IN/products/Products_Overview.html But, in that document there is no option to get all the categories, sub categories in mws. And also i have referred several sites, they told me to refer the Browse Tree Report in MWS Api. But, there is no section in the report section. Is Amazon MWS have something like "Get Categories" method, or is there any way to do this ?
For simple to use and explore checkout
https://www.browsenodes.com
It also has option to browse the categories for other countries.
Example for India the URL is
https://www.browsenodes.com/amazon.in
You can get the categories for a market place api by requesting Browse tree report. Each browse node( Amazon way of storing categories ) contains a field child_nodes which gives you information about the sub categories.
http://docs.developer.amazonservices.com/en_IN/reports/Reports_ReportType.html#ReportTypeCategories__BrowseTreeReports
If you are looking for the categories of individual product. Please refer
http://docs.developer.amazonservices.com/en_IN/products/Products_GetProductCategoriesForSKU.html
http://docs.developer.amazonservices.com/en_IN/products/Products_GetProductCategoriesForASIN.html
The Browse Tree Guide is an Excel file available for download from the Amazon Seller Central. Once logged in, go to Seller Central Help > Manage Inventory > Reference > Browse Tree Guide
I tried in amazon mws scratchpad and could get category information. (scratchpad website: https://mws.amazonservices.com.au/scratchpad/index.html) .
The process of getting categories:
API section Reports -> RequestReport (report type:_GET_MERCHANT_LISTINGS_DATA_, report option: _GET_XML_BROWSE_TREE_DATA_)
GetReportList(in this list, you may find ReportId related with '_GET_XML_BROWSE_TREE_DATA_' )
GetReport(use this ReportId as input).
Then you can get the tree report for all categories
Amazon does not make it easy to get all the categories, but I think what you are looking for is actually in AWS Browse Nodes.
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/BrowseNodes.html
Maybe it's a little late but i wanted to answer the question so some other ones
find useful. First, you need to make a request to RequestReport action, after that, you will make a request to GetRequest action using previous action's id, this will give you a long list of the categories (for the marketplaces you specified in the query). This is the link to the action & service, and also don't forget to take a look at ReportTypes enums, you must define them correctli.
POST /Reports/2009-01-01 HTTP/1.1
Content-Type: x-www-form-urlencoded
Host: mws.amazonservices.com
User-Agent: <Your User Agent Header>
AWSAccessKeyId=0PB842EXAMPLE7N4ZTR2
&Action=RequestReport
&EndDate=2008-06-26T18%3A12%3A21
&MWSAuthToken=amzn.mws.4ea38b7b-f563-7709-4bae-87aeaEXAMPLE
&Marketplace=ATVPDKIKX0DER
&ReportType=_GET_MERCHANT_LISTINGS_DATA_
&SellerId=A1XEXAMPLE5E6
&SignatureMethod=HmacSHA256
&SignatureVersion=2
&StartDate=2009-01-03T18%3A12%3A21
&Timestamp=2009-02-04T18%3A12%3A21.687Z
&Version=2009-01-01
&Signature=ZQLpf8vEXAMPLE0iC265pf18n0%3D
► Option 1 :
Go To : https://sellercentral.amazon.com/gp/help/help.html/ref=au_1661_cont_help?ie=UTF8&itemID=1661&language=en_US
Log with your Amazon account ( even if you don't have seller user ).
Press on link : "Inventory File Templates and BTG" ( wait few seconds and it will download the file )
Print screen for Option 1
► Option 2 :
if you are looking for a CSV File that contains Amazon departments, categories, sub categories and their links ( based on : https://www.amazon.com/gp/site-directory ) , you may check also in this github repository : https://github.com/postme205/AmzCategoriesSubCategories/ or Here (github.io)

Getting a users mailbox current history Id

I'd like to start syncing a users mailbox going forward so I need the most recent historyId of the users mailbox. There doesn't seem to be a way to get this with one API call.
The gmail.users.history.list endpoint contains a historyId which seems to be what I need, from the docs:
historyId unsigned long The ID of the mailbox's current history record.
However to get a valid response from this endpoint you must provide a startHistoryId as a parameter.
The only alternative I see is to make a request to list the users messages, get the most recent history id from that, then make a request to gmail.users.history.list providing that historyid to get the most recent one.
Other ideas?
Did you check out https://developers.google.com/gmail/api/guides/sync ?
Depending on what your use-case is, to avoid races between your current state and when you start to forward sync, you'll need to provide an appropriate historyId. If there were a "get current history ID" then anything between your previous state and when you got those results would be lost. If you don't have any particular existing state (e.g. only want to get updates and don't care about anything before that) then you can use any historyId returned (e.g. on a message or thread) as you mention.
Small example for C# users (mentioned in comments by #EricDeFriez).
Nuget package Google.Apis.Gmail.v1 must be installed. See also quickstart for .NET developers.
var service = new GmailService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
var req = service.Users.GetProfile("me");
req.Fields = "historyId";
var res = req.Execute();
Console.WriteLine("HistoryId: " + res.HistoryId);
This answer is related to the Java Gmail API Client Library using a service account.
I found that the gmail.users.getprofile() will not work as the object that it returns is of type Class Gmail.Users.GetProfile which does not have an interface to getting a historyId.
com.google.api.services.gmail.model.Profile actually has a getHistoryId() function, but calling service.users().getProfile() will return a Class Gmail.Users.GetProfileobject instead.
To get around this, I use the history.list() function which will always return the latest historyId as part of its response.
Gmail service = createGmailService(userId); //Authenticate
BigInteger startHistoryId = BigInteger.valueOf(historyId);
ListHistoryResponse response = service.users().history().list("me")
.setStartHistoryId(startHistoryId).setMaxResults(Long.valueOf(1)).execute();
I set the max number of results to be 1 to limit the unnecessary data that I get returned back and I will receive a payload that looks like:
{"history":[{"id":"XXX","messages":[{"id":"XXX","threadId":"XXX"}]}],"historyId":"123456","nextPageToken":"XXX"}
The historyId (123456) will be the current historyId of the user. You can grab that historyId using response.getHistoryId()
You can also see that the latest historyId is given in the response if you use the API tester for Users.history: list
https://developers.google.com/gmail/api/v1/reference/users/history/list

Serve multiple PayPal sellers from the same website

I have a website that does ticket sales. This website uses PayPal to process the payments. More specifically, I am using ExpressCheckout to process payments.
I have two sellers right now, and I cannot get them to both work at the same time.
Their sites are:
myapp.appspot.com/SellerA
myapp.appspot.com/SellerB
I have separate PayPal signature credentials for each seller in different config files:
acct1.UserName = sellera_api1.comcast.net
acct1.Password = <passwordA>
acct1.Signature = <signatureA>
acct1.UserName = sellerb_api1.comcast.net
acct1.Password = <passwordB>
acct1.Signature = <signatureB>
Here is the frustrating workflow that I am encountering:
1) Seller A works just fine, Seller B gets this error:
com.paypal.exception.InvalidCredentialException: Invalid userIdsellerb_api1.comcast.net
2) request new signature credentials for seller B and paste them into seller B's config file
3) Seller B works just fine, Seller A gets this error:
com.paypal.exception.InvalidCredentialException: Invalid userIdsellera_api1.comcast.net
4) request new signature credentials for seller A and paste them into seller A's config file
5) back to step 1
Any idea what could be happening here and how to fix this problem?
You might have to set them as two different accounts (like below) so that you make different API calls based on API user.
acct1.Username = sellera_api1.comcast.net
acct2.Username = sellerb_api1.comcast.net
Then you could call
setExpressCheckout(SetExpressCheckoutReq setExpressCheckoutReq, String apiUsername)
This probably not the best way to solve it and so I am very interested to see other solutions.

Resources