TESTNET /fapi/v1/balance is retired, please use GET /fapi/v2/balance

i am currently using a testnet API and i am now getting the following error:

GET /fapi/v1/balance is retired, please use GET /fapi/v2/balance

I am using the python binance API wrapper which doesn’t seem to have updated. I have edited the client to the correct url as mentioned in the error but after doing this i get an error message relating to API permissions.

Does anyone have a solution?

The Python Futures Connector is using /fapi/v2/balance (https://github.com/binance/binance-futures-connector-python/blob/main/binance/um_futures/account.py#L534).
What is the exact issue for the API permission error? Please give full details, such as the request URL and the response error and message.

Hi! I’m also having the same issue with Testnet only since a couple of days. I’ve been using:

accountBalance = client.futures_account_balance()

which worked alright for mainnet, but for testnet it now returns the same “GET /fapi/v1/balance is retired, please use GET /fapi/v2/balance” error, haven’t found a solution. Also tried as:

timestamp = int(time.time() * 1000)
signature = hmac.new(config.API_SECRET.encode(‘utf-8’), f’symbol={SYMBOL}&timestamp={timestamp}'.encode(‘utf-8’), hashlib.sha256).hexdigest()
params = {‘symbol’: SYMBOL, ‘timestamp’: timestamp, ‘signature’: signature}
headers = {‘X-MBX-APIKEY’: config.API_KEY}
accountBalance = requests.get(‘https://fapi.binance.com/fapi/v2/balance’, params=params, headers=headers).json()
print(accountBalance)

and again, works alright for mainnet but not for testnet that returns:

{‘code’: -2015, ‘msg’: ‘Invalid API-key, IP, or permissions for action, request ip: …’}

  • For binance’s futures python package (binance-futures-connector), there’s no method named futures_account_balance, so I believe you’re using another package which might not have been updated with /fapi/v2/balance yet.

  • There’s issue using /fapi/v2/balance in Testnet, I’ve just tested successfully with:

GET https://testnet.binancefuture.com/fapi/v2/balance?timestamp=xxx&signature=xxx
1 Like

raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-5000): GET /fapi/v1/balance is retired, please use GET /fapi/v2/balance.
what should i do?

1 Like

Hi,
I ran into the same problem 2 day ago!

Yes, excatly it happened from 2 days ago.
temporary, I use it :

position = ‘’
while position == ‘’:
try:
position = client.futures_position_information(symbol=symbol)
break
except:
sleep(1)
continue

I change binance files, version “1.0.19” from Github (GitHub - sammchardy/python-binance: Binance Exchange API python implementation for automated trading) by files installed in python 3.9 /binance, and that’s work.
good luck

1 Like

Can we please get a simple python example ?

A very basic example liks this

+++
from binance.client import Client
client = Client(MY_API_KEY, MY_SECRET_KEY)
open_orders = client.futures_account()[‘positions’]
print(open_orders)
+++

does not work and produce the error:
binance.exceptions.BinanceAPIException: APIError(code=-5000): GET /fapi/v1/account is retired, please use GET /fapi/v2/account

how would I change the script above to make it working ?
thanks

do you know about “use the v2 version endpoint”?