bybit-exchange / pybit

Official Python3 API connector for Bybit's HTTP and WebSockets APIs.
Other
385 stars 129 forks source link

API not responding since today #148

Closed rharteve closed 1 year ago

rharteve commented 1 year ago

Since this morning, I get back:

COIN="XRP" PAIR="XRPUSD"

session = HTTP( endpoint='https://api.bybit.com', api_key=config.myapi_key, api_secret=config.myapi_secret )

BALANCE

balance=(session.get_wallet_balance()) result = round(float(balance['result'][COIN]['equity']),8) print(COIN, "balance=", result)

Traceback (most recent call last): File "allintel.py", line 17, in balance=(session.get_wallet_balance()) File "/home/ec2-user/.local/lib/python3.7/site-packages/pybit/init.py", line 1427, in get_wallet_balance auth=True File "/home/ec2-user/.local/lib/python3.7/site-packages/pybit/init.py", line 1828, in _submit_request s_json = s.json() File "/home/ec2-user/.local/lib/python3.7/site-packages/requests/models.py", line 910, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib64/python3.7/site-packages/simplejson/init.py", line 488, in loads return _default_decoder.decode(s) File "/usr/lib64/python3.7/site-packages/simplejson/decoder.py", line 374, in decode obj, end = self.raw_decode(s) File "/usr/lib64/python3.7/site-packages/simplejson/decoder.py", line 393, in raw_decode return self.scan_once(s, idx=_w(s, idx).end()) simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

What did change?

dextertd commented 1 year ago

This looks like an old version of pybit, and it may not be checking the HTTP status code correctly. Most likely, the API returned a non-200 response and sent no JSON with it, so you are getting a JSONDecodeError. It is hard to diagnose the issue and find the exact reason based on this old version of pybit.

rharteve commented 1 year ago

That is correct. Actually, I have found out tonight that I get a 403 error (non-200). Which is a rate limit failure.

Apparently a while loop until you have a valid price wasn't a good idea last night....

dextertd commented 1 year ago

Haha, I respect your honesty! If this is your first violation, it should wear off shortly. If not, switch to another IP.