wrm3 / PyBittrexAPIv3.py

python examples for bittrex api v3
1 stars 0 forks source link

_private_api_query: Dictionary overwritten #1

Open ligarcia7 opened 4 years ago

ligarcia7 commented 4 years ago

Hi,

First of all thanks for sharing this work!

I have being reviewing this code and noticed that inside "_private_api_query" the code doesn't returns the desired information when the API responds with a list of dictionaries. Specifically line 263 will overwrite the downloaded data with a blank dictionary and afterwards the status_code will be added into it returning only the status_code. I am not sure how to fix it as i can't get which was the way it was originally thought.

        data = r.json()
        print(type(data))
        if isinstance(data, list):
            status_code = r.status_code
            data = dict()
            data['status_code'] = r.status_code
        if isinstance(data, dict):
            data['status_code'] = r.status_code

        return data

The difference on the result is clear when running prv_get_balances() vs prv_get_balances('AnyCoin'):

c = bittrex_api3.prv_get_balances()
print(c)

Result:
def Bittrex.api_query(http_meth=GET, sub_path=/balances, options=null)
request_url                : https://api.bittrex.com/v3/balances
<class 'list'>
{'status_code': 200}

d = bittrex_api3.prv_get_balances('BTC')
print(d)

Result:
def Bittrex.api_query(http_meth=GET, sub_path=/balances/BTC, options=null)
request_url                : https://api.bittrex.com/v3/balances/BTC
<class 'dict'>
{'currencySymbol': 'BTC', 'total': '0.------', 'available': '0.------', 'updatedAt': '2001-01-01T00:00:00Z', 'status_code': 200}

Thanks LG

wrm3 commented 4 years ago

That section has changed alot. I am editing my working copy to update this, very happy someone actually is looking at it! Also adding some example usages I threw together just in case it might help. trying to get my bot back online, its been 48 hours!

ligarcia7 commented 4 years ago

Thanks! I will review it and let you know if i have any issue! This is super useful i was trying to write something myself but got frustrated as couldn't figure it out due to the huge amount of options!

wrm3 commented 4 years ago

yah I spent so long stuck on invalid content hash (like 3 weeks) I decided I had to share once I got something kinda working. glad it helped!