- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
没有在 Python 中工作太多,我显然没有发送所要求的正确签名。我如何对其进行哈希处理并正确传递?
SIGNED endpoints require an additional parameter, signature, to be sent in the query string or request body.
Endpoints use HMAC SHA256 signatures. The HMAC SHA256 signature is a keyed HMAC SHA256 operation. Use your secretKey as the key and totalParams as the value for the HMAC operation.
The signature is not case sensitive.
totalParams is defined as the query string concatenated with the request body.
完整文档: https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md
import requests, json, time, hashlib
apikey = "myactualapikey"
secret = "myrealsecret"
test = requests.get("https://api.binance.com/api/v1/ping")
servertime = requests.get("https://api.binance.com/api/v1/time")
servertimeobject = json.loads(servertime.text)
servertimeint = servertimeobject['serverTime']
hashedsig = hashlib.sha256(secret)
userdata = requests.get("https://api.binance.com/api/v3/account",
params = {
"signature" : hashedsig,
"timestamp" : servertimeint,
},
headers = {
"X-MBX-APIKEY" : apikey,
}
)
print(userdata)
我得到了
{"code":-1100,"msg":"Illegal characters found in parameter 'signature'; legal range is '^[A-Fa-f0-9]{64}$'."}
最佳答案
这个:
hashedsig = hashlib.sha256(secret)
给你一个散列对象,而不是一个字符串。您需要以十六进制形式获取字符串:
hashedsig = hashlib.sha256(secret).hexdigest()
您可以通过将您链接的文档(显示它们需要十六进制字符串)与您的原始 hashedsig
及其提供的功能进行比较来解决这个问题。
其次,正如评论者所指出的,您需要应用 HMAC,而不仅仅是 SHA256:
params = urlencode({
"signature" : hashedsig,
"timestamp" : servertimeint,
})
hashedsig = hmac.new(secret.encode(), params.encode(), hashlib.sha256).hexdigest()
您可以在这里找到类似的代码:http://python-binance.readthedocs.io/en/latest/_modules/binance/client.html
关于python - 使用 SHA56 和 Python 请求的 Binance API 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48592450/
在DOCS我们看到: const conn = new WebSocket("wss://dex.binance.org/api/ws"); conn.onopen = function(evt) {
我是 StackOverflow 的新手,但我听说有很棒且乐于助人的人可以帮助我。 😉 我的使命: 找到一种使用 c# 调用 Binance REST API 进行交易的方法 没有dll,使用我自己
更新 1: 我正在 Linux AWS EC2 实例上安装 python-binance,当我尝试在 Python 3.7.0rc1 中使用 pip3 安装 python-binance 时,出现以下
在 Binance 测试 API 上出现错误。现货交易 符号:BNBUSDT 数量:0.331 Responce: {"code":-1013,"msg":"Filter failure: LOT_S
我正在尝试使用 WebSocket 从 Binance (ETHUSDT) 获取和绘制实时数据。获取数据没问题,但是在使用 matplotlib 时我无法获得实时绘图。 在代码中,我每次收到消息时都会
我试图理解 here 提出的 margin 水平计算公式: Margin Level = Total Asset Value / (Total Borrowed + Total Accrued Int
您好,我正在将 Binance api 与 python 一起使用,我所能拥有的只是我的 SPOT 账户余额。我正在使用这个: client.get_account() 不幸的是,不包括质押 Asse
我在Binance上设置了只读API key ,以访问帐户信息(例如货币余额),但看不到JSON数据。我输入URL的字符串查询返回以下错误: {"code":-2014,"msg":"API-key
我正在使用 Node 和 ws npm 包来处理 WebSockets。获得了文档(如下)中所述的 listenKey,但我无法使用用户数据流获取我的帐户信息。我更喜欢使用流来读取我最新的帐户信息(余
是否有特定的 binance futures API 端点可以自动平仓? GUI 中有这样一个选项。现在我只能想象得到所有头寸的数量而不是卖出那个数量,但是有没有更简单的方法? 我希望能够调用 ccx
我正在使用 unicorn_binance_websocket_api 从 2 个不同的时间范围流式传输 100 个加密货币的价格数据,我想处理这些数据以存储不同加密货币各自时间范围的收盘价,然后执行
在尝试下订单时,我收到以下错误消息: Code: -2010 Account has insufficient balance for requested action 我正在请求 POST 端点 h
我想按照 their site 中的说明设置止损限价单.换句话说,我想在达到某个止损价格时下限价订单。 API documentation只有一个 client.create_order 函数示例,这
当谈到特定货币对的 24 小时变化时, 这是如何计算的? 如果它是当前时间的价格与 24 小时前的价格相比,那么例如: BTC当前价格9431现在(2020 年 6 月 16 日下午 5 点)与 93
嗨,我认为这会很简单,但我无法弄清楚。 它无法找到 binance.websockets,即使它可以找到应该属于同一个包的 binance.client 的任何原因? import config im
在这些站点( https://coinalyze.net/ethereum-classic/liquidations/ 、 BTC/USDT )上,我可以将以下指示添加到 grpah [ Liquid
我正在尝试发送 GET向 Binance 的 API 提出请求,但我不知道如何去做。 这是文档页面:https://github.com/binance-exchange/binance-offici
我正在开发一个交易机器人,我想通过从 Binance 获取我在特定时间段内的订单历史列表来训练它。我查看了 API 文档 here ,但似乎总是要求我提供股票代码。虽然迭代所有股票代码是一种选择,但它
Binance 提供具有多种功能的 Web Socket Streams,例如聚合流、交易流、Kline/Candlestick 流等,您可以在此处查看 https://github.com/bina
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎不是关于 a specific programming problem, a softwar
我是一名优秀的程序员,十分优秀!