makarworld / pymexc

Unofficial python library for interacting with the MEXC crypto exchange
https://pypi.org/project/pymexc/
MIT License
34 stars 15 forks source link

spot_client.ticker_price() doesn't work #5

Closed KaiserPygit closed 10 months ago

KaiserPygit commented 10 months ago

Hi,

I'm simply trying the following to get used to this library :

from pymexc import spot

api_key = 'abc'
api_secret = 'def'

spot_client = spot.HTTP(api_key = api_key, api_secret = api_secret)

print(spot_client.account_information())

print(spot_client.ticker_price())

Everything works fine until the last line. I have 2 problems here :

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/init.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pymexc/spot.py", line 290, in ticker_price return self.call("GET", "/api/v3/ticker/price", ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pymexc/base.py", line 100, in call return response.json() ^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

What's wrong ?

makarworld commented 10 months ago

Fixed. Seems like when request sent to public endpoint with sign it return zero-content response.

KaiserPygit commented 10 months ago

Thanks, it works now :) However I'm still struggling to pass the argument for a specific ticker. For example I tried spot_client.ticker_price('symbol': 'BTCUSDT') but it says invalid syntax and if I try spot_client.ticker_price({'symbol': 'BTCUSDT'}) it says invalid symbol. What's the syntax to use ? I also tried using '=' instead of ':' but nothing works.

EDIT : nevermind I found it, it's spot_client.ticker_price(symbol = 'BTCUSDT'), I was a bit stupid on this one