How can I get the contents of an Amazon shopping cart? - amazon-product-api

I've been investigating whether it's possible to get a list of the saved items in my Amazon shopping basket programmatically.
Their Product Advertising API has methods for getting wishlists described here and working with remote shopping carts described here.
But the shopping cart of items stored while on the Amazon web site is treated as a local shopping cart, and therefore is not accessible through the Product Advertising API.
According to the last link:
The opposite of a remote shopping cart is a local shopping cart, which is the shopping cart customers use while shopping on www.amazon.com. It is considered local because Amazon hosts the shopping web pages as well as the shopping cart. Product Advertising API operations work solely with remote shopping carts.
Has anyone found a way of getting the contents of the "local" cart, apart from scraping the HTML?

I know this is a 10 year old question, but here is a way to do it using python3.
import browser_cookie3
import requests
cookies = browser_cookie3.chrome(domain_name='.amazon.com')
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36'
}
with requests.session() as s:
s.cookies = cookies
s.headers = headers
url = 'https://www.amazon.com/gp/cart/view.html?ref_=nav_cart'
resp = s.get(url)
print('resp text contains shopping cart data')
You can use something like BeautifulSoup to parse response text. In order for this to work the user must be signed into Amazon in Chrome. browser_cookie3 can be set to use other browsers as well.

It appears that Amazon does not offer this in their API. However, depending on what your environment is it may be possible to do this without using the API by having the user sign in and doing a page scrape of the shopping cart page.
This link may be useful: http://bililite.com/blog/2010/10/31/hacking-my-way-to-an-amazon-wishlist-widget/

Related

Intermittent cookieless requests with Sec-Fetch-Mode=cors

I'm trying to track down a problem in our Java, SpringMVC/WebFlow web application, that seems to occur whenever some extra, unexpected requests arrive from Firefox, with no session cookie attached, and with some Sec-Fetch headers different from the requests before and after them:
Sec-Fetch-Dest=empty;Sec-Fetch-Mode=cors;Sec-Fetch-Site=same-origin
These requests do not appear in the Firefox developer panel's network tab, even with all requests selected.
But both the HTTP access log and a custom "log everything" filter show the above, with the same Firefox User Agent, no cookies, and no Referer header.
e.g.
9:13:12,426 DEBUG RequestLogFilter:GET->http://localhost:9080/payment/pos?execution=e1s1 (null/false), headers:Host=localhost:9080;User-Agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/107.0;Accept=/;Accept-Language=en-US,en;q=0.8,es-MX;q=0.5,es;q=0.3;Accept-Encoding=gzip, deflate, br;DNT=1;Connection=keep-alive;Sec-Fetch-Dest=empty;Sec-Fetch-Mode=cors;Sec-Fetch-Site=same-origin;, cookies:
(Where "null/false" is the HttpServletRequest.getRequestedSessionId and isRequestedSessionIdValid().)
I can run the same sequence of web requests dozens or more times without seeing these extra requests appear, it's quite unpredictable. With or without fresh/private/incognito, cleared cookies, etc.
I'm looking for any ideas why Firefox is sending these requests. And, no, I don't think this is specific to Firefox. We've seen log evidence that Chrome at least seems be doing something similar in our production environment, but I haven't yet been able to duplicate it under Chrome (107) locally, where I have all this additional logging enabled.

Read Amazon Shopping Cart

I am Developing an application(on Mobile) and one of the features needs to read the shopping cart a user has made on amazon.
The user opens amazon from any browser
the user opens my app
logins with amazon user and pass
after that i need the app to read the card and only display the items
is this possible ?
Thanks
Check out the amazon product advertising API. Be sure to read the full documentation.
The API has many methods that can be used to search, look up created and modify shopping cart.
Link:
https://docs.aws.amazon.com/AWSECommerceService/latest/DG/Welcome.html

RESTful API how to check that sevarel items exists

I am using the mobile application to work with Yii2 RESTful API. In my mobile app I do have a shopping cart with items. So the idea is where user is opening a shopping cart to check that products are still available and have not been sold. So I was thinking to get list of product's id and send a request to RESTful API to check that all of them is fine. If some of them sold I should get back a changed list od products. So far I request my items using this link https://api.website.com/products?product_id=969
What is the good approach to solve this issue? Or in my mobile app I have to create a loop to check each product by one?
A usual practice for use use case you describe is to create an endpoint that accepts a list of IDs, separated by some character (comma, semicolon, etc). For example:
https://api.website.com/products?product_ids=969,970,971
In that action you'd loop over each individual ID in product_ids.

POST/PUT request to append row using Google Spreadsheet API returns 404 error

POST/PUT request to append a new row using Google Spreadsheet API returns 404 error.
Here is the API reference doc for append method in Google Spreadsheet API https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
Below is the request & response. If the ':append' in the url path is removed, then the request works fine. But the new data overrides the existing row. Any idea what's wrong with this append request to add a new rows in the sheet
Request URL:https://sheets.googleapis.com/v4/spreadsheets/1gpa0ByqgiDbGawyStfsJit8SdJfgi0rQsAAlzWkU7uM/values/**A2:append**?valueInputOption=RAW&alt=json
Request Method:PUT
Status Code:**404**
Response Headers
status:404
Request Headers
Provisional headers are shown
Authorization:Bearer xxxxxxx
Content-Type:application/json
Origin:chrome-extension://xxxxxxx
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
Request Payload
view source
{values: []}
values:[]
Follow this tutorial on how to insert data to a google spreadsheet via POST or GET. You may also try the workaround given in this link.
Clear the cache and cookies.
Try an incognito or private window.
Try another browser or operating system. (Here is a list of supported configurations.)
Disable browser plugins or extensions. (Chrome, Firefox, Internet Explorer, and Safari instructions.)
Hope this helps.

display amazon website under subdomain like cashbasha

How are you all ?
How can cashbasha.com display amazon store under "cashbasha" subdomain ?
Here is an example to understand what I mean:
http://en-jo.alpha-secure.shop.cashbasha.com
I searched over stackoverflow for same issue, i found this link:
How to embed an external webpage without using iframe?
But answers for that question is not useful anymore ! Cashbasha is a trusted Jordanian company and let user buying thorught amazon by the best easy way.
The user goes to cashbasha.com, browsing products and categories from amazon, then the user can add products to his cart in amazon, and checkout on cashbasha.
Let me return to the main question: How can cashbasha integrate amazon ?
After searching alot, I found that they are using Amazon API along with amazon professional seller account.
When you create amazon professional seller account, they give you an access to much more API functions rather than regular affiliate account.