@@ -15,7 +15,7 @@ def __init__(self, url="https://bpsapi.rajtech.me/v1/"):
1515 raise ConnectionError ("Invalid API Response. API says there are no categories." )
1616
1717 # /latest endpoint
18- def latest (self , category : str or int , cached : bool = False ) -> dict or None :
18+ def latest (self , category : str or int ) -> dict or None :
1919 """The `/latest` endpoint returns the latest circular from a particular category"""
2020 if type (category ) == int :
2121 category = int (category )
@@ -27,9 +27,8 @@ def latest(self, category: str or int, cached: bool = False) -> dict or None:
2727 raise ValueError ("Invalid category Name" )
2828
2929 params = {'category' : category }
30- endpoint = "latest" if not cached else "cached-latest"
3130
32- request = requests .get (self .url + endpoint , params = params )
31+ request = requests .get (self .url + "latest" , params = params )
3332 json = request .json ()
3433 try :
3534 json ['http_status' ]
@@ -64,14 +63,14 @@ def list(self, category: str or int, amount: int = -1) -> list or None:
6463 if json ['http_status' ] == 200 :
6564 return json ['data' ] if amount == - 1 else json ['data' ][:amount ]
6665
67- def search (self , query : str or int ) -> dict or None :
66+ def search (self , query : str or int , amount : int = 1 ) -> dict or None :
6867 """The `/search` endpoint lets you search for a circular by its name or ID"""
69- if type ( query ) == int :
68+ if query . isdigit () and len ( query ) == 4 :
7069 query = int (query )
7170 elif type (query ) != str :
7271 raise ValueError ("Invalid Query" )
7372
74- params = {'title' : query }
73+ params = {'title' : query , 'amount' : amount }
7574
7675 request = requests .get (self .url + "search" , params = params )
7776 json = request .json ()
@@ -119,7 +118,6 @@ def __init__(self, category, url: str = "https://bpsapi.rajtech.me/v1/", cache_m
119118 else :
120119 raise ConnectionError ("Invalid API Response. API says there are no categories." )
121120
122-
123121 if debug :
124122 self .set_cache = self ._set_cache
125123 self .refresh_cache = self ._refresh_cache
@@ -131,7 +129,6 @@ def __init__(self, category, url: str = "https://bpsapi.rajtech.me/v1/", cache_m
131129
132130 else :
133131 if category not in self .categories :
134- print (category )
135132 raise ValueError ("Invalid category Name" )
136133
137134 self ._params = {'category' : category }
0 commit comments