gateio / gatews

Gate Websocket V4 SDK
91 stars 35 forks source link

Documentation is incorrect #7

Closed TheHolyRoger closed 3 years ago

TheHolyRoger commented 3 years ago

Please update your docs! I had to come here looking for how to auth to the websocket.

Info here is wrong: https://www.gateio.ch/docs/apiv4/ws/index.html#spot-websocket-v4

revilwang commented 3 years ago

Please point out which part is wrong.

TheHolyRoger commented 3 years ago

@revilwang WS API docs say "# refer to Authentication section for gen_sign implementation"

There is no authentication section on that page...

revilwang commented 3 years ago

Scroll down to the end of API Overview section, and you'll see details about Authentication.

TheHolyRoger commented 3 years ago

Are you talking about the REST page? https://www.gate.io/docs/apiv4/en/index.html#api-signature-string-generation

def gen_sign(method, url, query_string=None, payload_string=None):
    key = ''        # api_key
    secret = ''     # api_secret

    t = time.time()
    m = hashlib.sha512()
    m.update((payload_string or "").encode('utf-8'))
    hashed_payload = m.hexdigest()
    s = '%s\n%s\n%s\n%s\n%s' % (method, url, query_string or "", hashed_payload, t)
    sign = hmac.new(secret.encode('utf-8'), s.encode('utf-8'), hashlib.sha512).hexdigest()
    return {'KEY': key, 'Timestamp': str(t), 'SIGN': sign}

This is wrong for your WS ^

revilwang commented 3 years ago

No, WebSocket Authentication part is just above the System API section.

TheHolyRoger commented 3 years ago

Oh, ok I see it now sorry! It could use a header on the menu for it...

revilwang commented 3 years ago

Thanks for your advice. Let's put it into a standalone section on next doc update