BTCMarkets / API

API
120 stars 30 forks source link

withdraw api can't work ? how to make it work ? #124

Closed 13122310958 closed 6 years ago

13122310958 commented 6 years ago

Hi guys , I post the data as following to the api . but always return {"success":false,"errorCode":1,"errorMessage":"Authentication failed."}

('\nRequest:', 'POST', 'https://api.btcmarkets.net/fundtransfer/withdrawCrypto', {'Accept-Charset': 'UTF-8', 'apikey': '0xxxxxx-xxxxx-xxxx', 'Accept-Encoding': 'gzip, deflate', 'signature': u'h7HtPsxxxxf2niygXlF1xxxxxxxxxRkdOYQqF3yvJIQmVu/a+uBpxm+1nCM/FkQlREw==', 'timestamp': '1519721167047', 'Content-Type': 'application/json', 'User-Agent': 'python-requests/2.18.4'}, '{"currency":"ETC","amount":1000000,"address":"0xabcd1234"}')

Can you tell me what can I do to make it work ?

Thanks

13122310958 commented 6 years ago

but others like order api can work .

stephenyao commented 6 years ago

Because withdrawal needs authentication, so you will need to go to btcmarkets.net and generate an API token, then using a hashing algorithm to hash your request. It’s in the documentation

13122310958 commented 6 years ago

Hi Stephenyao ,

Yes , we already have an API token , Does we need to request a whitelist ip for us to use this API ?

Thanks Eric

On Wed, Feb 28, 2018 at 11:03 PM, stephenyao notifications@github.com wrote:

Because withdrawal needs authentication, so you will need to go to btcmarkets.net and generate an API token, then using a hashing algorithm to hash your request. It’s in the documentation

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/BTCMarkets/API/issues/124#issuecomment-369219022, or mute the thread https://github.com/notifications/unsubscribe-auth/AImZprwpM33MMJs3dHTaLczmuahKofNDks5tZUCfgaJpZM4SUqFS .

-- Eric.Liu

19843103 commented 6 years ago

We've already use algorithm to hash our request. Can you please let us know if we need to white list our ip? Thank you

justin-ngin commented 6 years ago

Hi @13122310958 ,

There is no whitelisting of IPs to use the API. The order of the variables in your post request is incorrect and is probably the reason for the failed authentication. As noted on the Authentication page in the wiki, the order of the variables needs to match EXACTLY what is provided in the sample request on the Fund Transfer wiki page.

If this doesn't solve the issue, please let me know here.

Cheers, Justin

13122310958 commented 6 years ago

Hi @Justin-ngin ,

Can you check my code :

https://github.com/13122310958/api-client-btcmarket

Cheers, Eric

justin-ngin commented 6 years ago
 def withdrawCrypto(self, currency, amount, address, tag=None, params={}):
        request = {
            'amount': amount,
            'address': address,
            'currency': currency,
        }
        data = OrderedDict([('currency', currency),('amount', amount),('address', address)])
        postData = json.dumps(data, separators=(',', ':'))
        return post_request(self.key, self.secret, '/fundtransfer/withdrawCrypto', postData)

Your OrderedDict is in the wrong order. Per the Fund Transfer API wiki page: {"amount":10000000,"address":"1EJKj147QmEzywLnLpuxSr6SoPr1p62VBX","currency":"BTC"} The order of the key-value pairs in your postData must match this exactly.

Regards, Justin

13122310958 commented 6 years ago

It works , Thanks. Eric

On Thu, Mar 1, 2018 at 3:24 PM, Justin notifications@github.com wrote:

def withdrawCrypto(self, currency, amount, address, tag=None, params={}): request = { 'amount': amount, 'address': address, 'currency': currency, } data = OrderedDict([('currency', currency),('amount', amount),('address', address)]) postData = json.dumps(data, separators=(',', ':')) return post_request(self.key, self.secret, '/fundtransfer/withdrawCrypto', postData)

Your OrderedDict is in the wrong order. Per the Fund Transfer API wiki page: {"amount":10000000,"address":"1EJKj147QmEzywLnLpuxSr6SoPr1p6 2VBX","currency":"BTC"} The order of the key-value pairs in your postData must match this exactly.

Regards, Justin

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BTCMarkets/API/issues/124#issuecomment-369470249, or mute the thread https://github.com/notifications/unsubscribe-auth/AImZplZ0o83uXEvjxF6p8UIXEcWPSqMqks5tZ3gYgaJpZM4SUqFS .

-- Eric.Liu