How does one authenticate with the YoBit API using Python 2.7?
<p>I am trying to right a trading bot with python that uses the YoBit api (<a href="https://yobit.net/en/api/" rel="nofollow noreferrer">https://yobit.net/en/api/</a>).  The only problem is I can't seem to figure out how to authenticate to use the private API. I was wondering if someone could give me an example of a working call to the private YoBit API. I found a post where someone claimed to have a working authentication for Python 3. I did my best to convert it to Python 2.7 and came up with this...</p>

<pre><code>from urllib2 import Request, urlopen
from pprint import pprint
import json
import time
import requests
import hmac
import hashlib
from urllib import urlencode

class yobit(object):

    def __init__(self, key, secret):
        self.key = 'mykey'
        self.secret = b'mysecret'
        self.public = ['info', 'ticker', 'depth', 'trades']
        self.trade = ['activeorders']

    def query(self, method, values={}):
        if method in self.public:
            url = 'https://yobit.net/api/3/'+method
            for i, k in values.iteritems():
                url += '/'+k

            req = requests.get(url)
            return json.loads(req.text)

        elif method in self.trade:
            url = 'https://yobit.net/tapi'
            values['method'] = method
            values['nonce'] = str(int(time.time()))
            body = urlencode(values)
            signature = hmac.new(self.secret, body, hashlib.sha512).hexdigest()
            headers = {
                'Content-Type': 'application/x-www-form-urlencoded',
                'Key': self.key,
                'Sign': signature
            }

            req = requests.post(url,data=values,headers=headers)
            return json.loads(req.text)

        return false


yobit('activeorders','liv_btc')
</code></pre>

<p>This, however, doesn't return anything.</p>