Closed juanguirago closed 3 years ago
I don't understand your question. The way to query for product data is like you said:
items = ['0439064872', '1426208081']
client = Keepa(access_key)
response = client.query(items)
Thank you for the quick response!
Yes, but:
products = api.query(asins) product = products[0]
If I then try to do something like:
sales = product["data"]["SALES"]
Since I can't put a string as "product", it returns the first ASIN of the string. Otherwise I get the " TypeError: list indices must be integers or slices, not str" error.
I bet I must be missing something basic but I'm not sure what is. Also, I do not see the last line of your code referenced in the documentation.
sales = product["data"]["SALES"]
Should be
sales = product[0]["data"]["SALES"]
Each product is in the product
list.
That would use the first product of the string, not all of them. What I did is:
`asins = np.asarray(['111', '222', '333']) products = api.query(asins)
first = True for pr in products: df_new = pr['data']['df_NEW'] # Raw dataframe from keepa df_new['Date'] = df_new.index # Create new column "Date" (datetime info is originally in the index, not in a column) df_new.columns = ['Price', 'Date'] # Rename the column "value" to "price`
And then continue creating the dataset.
Yes, you must iterate over the response and process each item's data individually
Yes! I got it now. It was a bit confusing since the documentation says it's for querying more than one ASIN, but a for loop is necessary.
Hi!
I'm new to using this query for fetching data and creating dataframes. I have a quick question: The documentations mentions this is the way to get queries for more than 1 ASIN:
>>> products = api.query(['0439064872', '1426208081'])
But, this means I still have to query each ASIN since the list indices can't be strings. So my question is, am I missing something when assigning the index? Or do you make a for loop for ASINs that are into that string? How do you fetch data for more than 1 ASIN?
Thanks!