gateio / gateapi-python

243 stars 91 forks source link

How to use this repo to get account balance #132

Closed zydjohnHotmail closed 1 year ago

zydjohnHotmail commented 1 year ago

Hello: I want to use API to get accout balance. I can't find good example, the example URL: https://github.com/gateio/gateapi-python/tree/master/example The build script is for UNIX/Linux, but I am using Windows 10. I don't know how many people are using Unix to run GateIO API. So I simply try to use a Rest client to send one HTTP Get request, like this: HTTP GET https://api.gateio.ws/api/v4/wallet/total_balance Headers: KEY: my_api_key (32 number and letters combination) SIGN: cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e Timestamp: unix_epoch_number (like: 1661367583 )

But I got json format error reply: { "label": "INVALID_SIGNATURE", "message": "Signature mismatch" }

For me the issue is, for the GET Http request, the request body is empty, then how to get a signature of empty string? If API key is not related with get account balance request, then the signature for empty string should be the same, right? In my case, let me know how I can get my account balance with either the repo (in Windows 10, not in Unix), or using a simple HTTP GET request. Please advise, Thanks,

revilwang commented 1 year ago

Though the code example has not been tested on Windows, the SDK is multi-platform. You can use pip install --user gate-api to install it, and use the example like this one.

If you prefer to implement your own SDK, you can check the signature generation method in gate-api