From 7f880ca4e1b52f14ea1693047328791163796764 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Fri, 24 Mar 2017 10:55:53 +0100 Subject: [PATCH] updated documentation --- keepaAPI/Interface.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/keepaAPI/Interface.py b/keepaAPI/Interface.py index d0ab953..d087c33 100644 --- a/keepaAPI/Interface.py +++ b/keepaAPI/Interface.py @@ -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 @@ -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'): @@ -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() \ No newline at end of file