Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion binance/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ async def _handle_response(self, response: aiohttp.ClientResponse):
"""
if not str(response.status).startswith("2"):
raise BinanceAPIException(response, response.status, await response.text())

if response.text == "":
return {}

try:
return await response.json()
except ValueError:
Expand Down Expand Up @@ -306,9 +310,12 @@ async def get_all_tickers(
params = {}
if symbol:
params["symbol"] = symbol
return await self._get(
response = await self._get(
"ticker/price", version=self.PRIVATE_API_VERSION, data=params
)
if isinstance(response, list) and all(isinstance(item, dict) for item in response):
return response
raise TypeError("Expected a list of dictionaries")

get_all_tickers.__doc__ = Client.get_all_tickers.__doc__

Expand Down
9 changes: 8 additions & 1 deletion binance/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ def _handle_response(response: requests.Response):
"""
if not (200 <= response.status_code < 300):
raise BinanceAPIException(response, response.status_code, response.text)

if response.text == "":
return {}

try:
return response.json()
except ValueError:
Expand Down Expand Up @@ -382,7 +386,10 @@ def get_all_tickers(self) -> List[Dict[str, str]]:
:raises: BinanceRequestException, BinanceAPIException

"""
return self._get("ticker/price", version=self.PRIVATE_API_VERSION)
response = self._get("ticker/price", version=self.PRIVATE_API_VERSION)
if isinstance(response, list) and all(isinstance(item, dict) for item in response):
return response
raise TypeError("Expected a list of dictionaries")

def get_orderbook_tickers(self, **params) -> Dict:
"""Best price/qty on the order book for all symbols.
Expand Down
Loading