Skip to content

Commit

Permalink
updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed Mar 24, 2017
1 parent 4c0b88e commit 7f880ca
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions keepaAPI/Interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import sys
import urllib
if sys.version_info[0] == 2:
quote = urllib.quote
quote_plus = urllib.quote
else:
quote = urllib.parse.quote
quote_plus = urllib.parse.quote


# Request limit
Expand Down Expand Up @@ -612,7 +612,10 @@ def BestSellersQuery(self, category, domain='US'):
r = requests.get('https://api.keepa.com/bestsellers/?', params=payload)
response = r.json()

return response['bestSellersList']['asinList']
if 'bestSellersList' in response:
return response['bestSellersList']['asinList']
else:
logging.info('Best sellers search results not yet available')


def SearchForCategories(self, searchterm, domain='US'):
Expand Down Expand Up @@ -645,8 +648,18 @@ def SearchForCategories(self, searchterm, domain='US'):
payload = {'key': self.accesskey,
'domain': dcodes.index(domain),
'type': 'category',
'term': quote(searchterm)}
'term': searchterm}

r = requests.get('https://api.keepa.com/search/?', params=payload)
return r.json()['categories']
response = r.json()

if response['categories'] == {}:
logging.info('Categories search results not yet available')
else:
return response['categories']


def GetAvailableTokens(self):
""" Returns available tokens """
return self.user.RemainingTokens()

0 comments on commit 7f880ca

Please sign in to comment.