Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import websocket
- import logging
- logging.basicConfig()
- nextIvalue = 0
- def call_service(ws, service_name, data, level=0):
- global nextIvalue
- frame = {
- 'm': level,
- 'i': nextIvalue,
- 'n': service_name,
- 'o': json.dumps(data)
- }
- nextIvalue += 2
- str = json.dumps(frame)
- print '< %s' % str
- ws.send(str)
- def on_error(ws, error):
- print('!> %s' % error)
- def show_info(ws, data):
- print('> %s' % data)
- ws.close()
- def get_info(ws, data):
- auth = json.loads(json.loads(data)['o'])
- if (auth['Authenticated']):
- ws.on_message = show_info
- # Escolha as permissões que você deseja dar a esta chave.
- # Você pode criar várias chaves. Por exemplo, uma apenas com opções de depósito e trading
- call_service(ws, 'AddUserAPIKey', {'UserId': auth['UserId'], 'Permissions': ['Trading', 'Withdraw', 'Deposit']})
- else:
- ws.close()
- def start_talking(ws):
- ws.on_message = get_info
- call_service(ws, 'WebAuthenticateUser', {
- 'UserName': 'your@email.com',
- 'Password': 'your-password'
- })
- def main():
- ws = websocket.WebSocketApp('wss://api.coinext.com.br/WSGateway/',
- on_error=on_error,
- on_open=start_talking)
- ws.run_forever()
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment