Nuclearz
Nuclearz

Reputation: 25

How to get balances and place an order using Yobit API in python

I'm trying to devolp a pump and dump bot for yobit in python; but i don't understand well how to use their API.

Documentation Link ---> https://yobit.net/en/api

This doesn't works well and i don't understand what's wrong.

class yobit(object):

    def __init__(self, key, secret):
        self.key = key
        self.secret = secret
        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/'
        elif method in self.trade:
            url = 'https://yobit.net/tapi/'
        else:
            return 'You are doing it wrong'

        urlString = ''
        for i, k in values.items():
            urlString += k+'/'

        url += method + '/' + urlString

        print(url)
        if method not in self.public:
            url += '&apikey=' + self.key
            url += '&nonce=' + str(int(time.time()))
            signature = hmac.new(self.secret, url, hashlib.sha512).hexdigest()
            headers = {'apisign': signature}
        else:
            headers = {}
        print(url)

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

Which is the syntax to get balances and to place an order?

Upvotes: 0

Views: 804

Answers (0)

Related Questions