Skip to content

Commit

Permalink
add number of products to product finder
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Oct 27, 2023
1 parent 0af5971 commit fa8b1db
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/keepa/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ def seller_query(
response = self._request("seller", payload, wait=wait)
return _parse_seller(response["sellers"], to_datetime)

def product_finder(self, product_parms, domain="US", wait=True) -> list:
def product_finder(self, product_parms, domain="US", wait=True, n_products=50) -> list:
"""Query the keepa product database to find products matching criteria.
Almost all product fields can be searched for and sort.
Expand Down Expand Up @@ -2356,6 +2356,9 @@ def product_finder(self, product_parms, domain="US", wait=True) -> list:
wait : bool, default: True
Wait available token before doing effective query.
n_products : int, default 50
Maximum number of matching products returned by keepa.
Returns
-------
list
Expand All @@ -2369,17 +2372,16 @@ def product_finder(self, product_parms, domain="US", wait=True) -> list:
Examples
--------
Query for all of Jim Butcher's books using the synchronous
``keepa.Keepa`` class. Sort by current sales
Query for the first 100 of Jim Butcher's books using the synchronous
``keepa.Keepa`` class. Sort by current sales.
>>> import keepa
>>> api = keepa.Keepa('<ENTER_ACTUAL_KEY_HERE>')
>>> product_parms = {
... 'author': 'jim butcher',
... 'sort': ["current_SALES", "asc"],
... }
>>> asins = api.product_finder(product_parms)
>>> asins = api.product_finder(product_parms, n_products=100)
>>> asins
['B000HRMAR2',
'0578799790',
Expand Down Expand Up @@ -2419,6 +2421,7 @@ def product_finder(self, product_parms, domain="US", wait=True) -> list:
# verify json type
key_type = PRODUCT_REQUEST_KEYS[key]
product_parms[key] = key_type(product_parms[key])
product_parms['perPage'] = n_products

payload = {
"key": self.accesskey,
Expand Down

0 comments on commit fa8b1db

Please sign in to comment.