Poloniex API - 无效的API密钥\ /密钥对 [英] Poloniex API - Invalid API key\/secret pair
问题描述
我无法生成简单的私人请求。
I can't generate simple private request.
使用Swift 4小时后,我开始尝试在浏览器中生成请求。
After 4 hour using Swift for it, I start trying to generate request in browser.
所以我希望获得所有余额。 command = returnBalances
So I want to get all balances. command=returnBalances
Randome integer nonce = 23455
Randome integer nonce=23455
我必须将这些信息转换为HMAC-SHA512。所以我使用在线生成器 - quickhash.com ,选择 SHA-512(SHA2),选择 使用HMAC方法,放入我的API密钥,然后选择 Base64编码。
That info together I have to convert to "HMAC-SHA512". So I use online generator - quickhash.com, choose SHA-512(SHA2), choose "Use HMAC Method", put inside my API Key, and choose Base64 encoding.
之后,我有这 - fu66g4WfjyJOrjfPtmWoaZGn1v6NK + YeiiKklD5EWfkvfXpBeCQE41Cg7jemh / Q / 1yaLBvkxhoX2vpe2949IOA ==
After that, I have this - fu66g4WfjyJOrjfPtmWoaZGn1v6NK+YeiiKklD5EWfkvfXpBeCQE41Cg7jemh/Q/1yaLBvkxhoX2vpe2949IOA==
然后,我必须建立链接,请求。好的:
and then, I have to make link, for request. Okay:
但我收到错误:
{"error":"Invalid API key\/secret pair."}
有人可以帮忙吗?我的错误在哪里?
推荐答案
你正在做 GET
-request。您必须为私有函数执行 POST
- 请求。来自文档:
You are doing a GET
-request. You have to do a POST
-request for private functions. From the documentation:
所有对交易API的调用都通过HTTP POST发送到
https://poloniex.com / tradingApi 并且必须包含以下
标头:
All calls to the trading API are sent via HTTP POST to https://poloniex.com/tradingApi and must contain the following headers:
Key - Your API key.
Sign - The query's POST data signed by your key's "secret" according to the HMAC-SHA512 method.
此外,所有查询都必须包含noncePOST参数。
nonce参数是一个整数,必须始终大于
之前使用的nonce。
Additionally, all queries must include a "nonce" POST parameter. The nonce parameter is an integer which must always be greater than the previous nonce used.
这意味着在HTTP-Headers中发送密钥
和 Sign
。其余的(命令
, nonce
)是正文的一部分。
That means Key
and Sign
are sent inside the HTTP-Headers. The rest (command
, nonce
) are part of the body.
示例请求:
- 假设您的API密钥为123,而您的API密钥为456。
-
returnBalances
请求的参数是command = returnBalances& nonce = 1473087174
。 请注意:每次请求都必须增加nonce
-parameter。建议使用当前时间戳。 - 使用HMAC-SHA512和您的秘密签署
command = returnBalances& nonce = 1473087174
456 )。结果将被放入Sign
-Header。 - 您放置了您的API密钥( 123 )进入
键
-Header。 - 你把请求参数
command = returnBalances& nonce = 1473087174
进入请求正文。 - 您将请求发送到 https://poloniex.com/tradingApi 使用 SSL使用
POST
-method 和 -encryption 。
- Let's say your API-Key is 123 and your API-Secret is 456.
- The parameters for a request to
returnBalances
arecommand=returnBalances&nonce=1473087174
. Please note: Thenonce
-parameter must be increased with every request. It is recommended to use the current timestamp. - You sign
command=returnBalances&nonce=1473087174
using HMAC-SHA512 and your secret (456). The result will be put into theSign
-Header. - You put your API-Key (123) into the
Key
-Header. - You put the request parameters
command=returnBalances&nonce=1473087174
into the request-body. - You send your request to https://poloniex.com/tradingApi using the
POST
-method and using SSL-encryption.
除非您使用允许的第三方软件/插件,否则通过浏览器执行此操作将无效你要修改请求标题等等。
Doing this over your browser will not work unless you use third-party-software/plugins which allow you to modify the request-headers, etc.
这篇关于Poloniex API - 无效的API密钥\ /密钥对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!