Skip to content

Portfolio Margin testnet /papi endpoints return 202 empty body #535

@kutear

Description

@kutear

Product / package

binance-sdk-derivatives-trading-portfolio-margin==2.0.0

Environment

  • Python: 3.12
  • REST base path: DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL
  • Resolved base path value: https://testnet.binancefuture.com
  • API endpoints tested: Portfolio Margin /papi/* endpoints on Futures Testnet

Description

The PyPI documentation says:

For testing purposes, /papi/* endpoints can be used in the Futures Testnet

and shows setting:

base_path=DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL

However, when using that exact testnet base path, Portfolio Margin REST calls fail because the HTTP response body is empty and cannot be parsed as JSON.

Minimal SDK reproduction

from binance_common.configuration import ConfigurationRestAPI
from binance_common.constants import DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL
from binance_sdk_derivatives_trading_portfolio_margin.derivatives_trading_portfolio_margin import DerivativesTradingPortfolioMargin

configuration = ConfigurationRestAPI(
    api_key="<testnet-or-api-key>",
    api_secret="<testnet-or-api-secret>",
    base_path=DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL,
)

client = DerivativesTradingPortfolioMargin(config_rest_api=configuration)

client.rest_api.account_balance()
client.rest_api.account_information()
client.rest_api.get_um_account_detail()
client.rest_api.query_um_position_information(symbol="BTCUSDT")
client.rest_api.query_all_current_um_open_orders(symbol="BTCUSDT")

Actual result

All of the above SDK calls fail with a JSON parse error:

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Raw HTTP behavior

I also tested the same endpoints directly, outside of the SDK, with signed requests. The responses are empty HTML responses with HTTP 202:

GET https://testnet.binancefuture.com/papi/v1/balance
GET https://testnet.binancefuture.com/papi/v1/account
GET https://testnet.binancefuture.com/papi/v1/um/account
GET https://testnet.binancefuture.com/papi/v1/um/positionRisk?symbol=BTCUSDT
GET https://testnet.binancefuture.com/papi/v1/um/openOrders?symbol=BTCUSDT

Response summary for each endpoint:

{
  "status": 202,
  "statusText": "Accepted",
  "contentType": "text/html; charset=UTF-8",
  "bodyPreview": ""
}

The same 202 Accepted empty response is also returned for /papi/* paths without authentication, instead of a normal Binance JSON error response.

Connectivity cross-check

The Futures Testnet host itself appears reachable and returns JSON for regular Futures endpoints:

GET https://testnet.binancefuture.com/fapi/v1/time         -> 200 application/json
GET https://testnet.binancefuture.com/fapi/v1/exchangeInfo -> 200 application/json
GET https://testnet.binancefuture.com/papi/v1/time         -> 202 text/html, empty body

Expected result

Either:

  1. /papi/* endpoints should return a normal JSON response on Futures Testnet when using DERIVATIVES_TRADING_PORTFOLIO_MARGIN_REST_API_TESTNET_URL, or
  2. if Portfolio Margin testnet requires a specific type of testnet account/key/permission, the SDK documentation should clarify the requirement, or
  3. if the base path is different for Portfolio Margin testnet, the correct base path should be documented.

Could you confirm whether Portfolio Margin /papi/* REST endpoints are currently supported on Futures Testnet, and whether https://testnet.binancefuture.com is still the correct base_path for this package?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions