APIError(代码=-2015):无效的API-key、IP或操作权限
我一直在接受上面的问题。
我不知道这是什么问题。
我能够访问client.get_all_tickers()命令,但当我尝试下订单或访问user_data (两者都需要签名)时,我得到了错误APIError(代码=-2015):无效的API-key、IP或操作权限。
我认为这个问题与签名有关。我检查了一下是否启用了相关的权限,并且已经启用了。此外,我试图创建一个新的API密钥,但问题仍然存在。
注意:我使用的是binance.us而不是binance.com,因为我在美国,所以我不能在binance.com上开户
因此,我的另一个想法是创建一个虚拟专用网,将我安置在英国,这样我就可以通过binance.com建立一个帐户,也许这会奏效。
import time
import datetime
import json
from time import sleep
from binance.client import Client
from binance.enums import *
import sys
import requests, json, time, hashlib
import urllib3
import logging
from urllib3 import PoolManager
from binance.exceptions import BinanceAPIException, BinanceWithdrawException
r = requests.get('https://www.binance.us/en/home')
client = Client(API_key,Secret_key,tld="us")
prices = client.get_all_tickers()
#Def to get location
def crypto_location(sym):
count = 0
for i in prices:
count += 1
ticker = i.get('symbol')
if ticker == sym:
val = i.get('price')
count = count-1
return count
bitcoin_location = crypto_location('BTCUSDT')
ethereum_location = crypto_location('ETHUSDT')
stable_coin_location = crypto_location('BUSDUSDT')
bitcoin_as_BUSD_location = crypto_location('BTCBUSD')
#%% Where to quickly get bitcoin price
t_min = time.localtime().tm_min
prices = client.get_all_tickers()
bitcoin_price = prices[bitcoin_location].get('price')
print(bitcoin_price)
ethereum_price = prices[ethereum_location].get('price')
print(ethereum_price)
stable_coin_price = prices[stable_coin_location].get('price')
print(stable_coin_price)
bitcoin_as_BUSD = prices[bitcoin_as_BUSD_location].get('price')
print(bitcoin_as_BUSD)
client.session.headers.update({ 'X-MBX-APIKEY': API_key})
client.get_account()错误发生在client.get_account()
发布于 2022-04-26 11:01:08
我也遇到了同样的问题,没有任何IP限制的二进制API每90天到期一次。我已经将API限制在我的IP上,而且它可以工作!
不过,你肯定会在这里找到一切的:https://python-binance.readthedocs.io/en/latest/index.html
https://stackoverflow.com/questions/65398380
复制相似问题