Post
Topic
Board Exchanges
Re: [Exchange] GRAVIEX Exchange: low fees, fast withdrawals, high security
by
Pudrim
on 29/05/2018, 02:32:41 UTC
How to get market with python 3?

    access_key = 'xxxx'
    secret_key = 'yyyy'
    ctx = ssl.create_default_context()
    ctx.check_hostname = False
    ctx.verify_mode = ssl.CERT_NONE
    epoch_time = str(int(time.time())) + '000'
    request = 'access_key=' + access_key + '&tonce=' + epoch_time
    message = 'GET|/api/v2/markets|' + request
    signature = hmac.new(b'secret_key',b'message',hashlib.sha256).hexdigest()
    query = 'https://graviex.net/api/v2/markets?' + request + '&signature=' + signature
    graviex = urllib.request.urlopen(query, context=ctx).read()
    print(graviex)

Not work:
401. Unauthorized


hello mazertwo, I solve this problem!

{"error":{"code":2007,"message":"The tonce 1527560783000 is invalid, current timestamp is 1527560317000."}}

you need to leave your tonce (timestamp your PC converted to UTC) exactly the same as the timestamp UTC graviex


#Python 3.6

import hashlib
import hmac
import requests
import time
import ssl
import json

access_key = 'api key here '
secret_key = 'secret key here'


# 0. making ssl context - verify should be turned off
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

# ------------------
# Get markets list
# ------------------

# 1. list markets

epoch_time = str(int(time.time()+30))+'000'
print(epoch_time)
request = 'access_key=' + access_key + '&tonce=' + epoch_time
message = 'GET|/api/v2/markets|' + request

secret_key_bytes= bytes(secret_key , 'latin-1')
message_bytes = bytes(message, 'latin-1')

# 1.1 generate the hash.
signature = hmac.new(
    secret_key_bytes,
    message_bytes,
    hashlib.sha256
).hexdigest()

# 1.2 list markets
query = 'https://graviex.net/api/v2/markets?' + (request) + '&signature=' + (signature)


print(query) #put in the browser



r = requests.get(query)
data = json.loads(r.content.decode('utf-8'))
print(data)


#---------------------------------------------------------------------



#I had to increase 30 units in the timestamp to work here in my region. You should get the value of "query" and put in the browser subitrair #the timestamp value of graviex server by its timestamp.

#I spent many hours to solve this problem.