Skip to content

v0.2.0 — 2FA support

Choose a tag to compare

@MartinBasualdo0 MartinBasualdo0 released this 09 May 15:23
· 8 commits to main since this release

Highlights

PPI started requiring 2FA, which broke __init__ for accounts with email-based second factor. This release adds proper 2FA handling so the library can authenticate again.

What's new

  • New otp_provider parameter on PPI(...) — pass any Callable[[], str] returning the 6-digit code (callback, IMAP poller, prompt, etc.). Falls back to input() when not provided.
  • New remember_device parameter (default False) forwarded to PPI's recordar field.
  • Resolves the user's cuentaID from the JWT claim PPAuth.Claims.General.Cuentas when /api/Cuenta/ComitentesAsignados is not available for the account.
  • Cleaner error messages in api_request — 401s now raise ApiException with the actual server response instead of being silently swallowed; 4xx/5xx no longer collapse into a generic Bad HTTP API Response.

Usage

from py_ppi_arg import PPI

# Interactive (prompts in console for the code):
app = PPI(user="...", password="...")

# Programmatic with callback:
app = PPI(user="...", password="...", otp_provider=lambda: input("OTP: "))

Known limitations

  • Account-context endpoints get_tickers_list and the underlying /api/Ordenes/InstrumentosOperables may return 401 depending on the role/permissions PPI assigns to the account, regardless of the cuentaID value passed. Market-data endpoints (search_tickers, get_technical_data_bonds, get_historic_data, get_intraday_data) work correctly.

Backwards compatibility

All new parameters have defaults, so existing call sites without 2FA on the account continue to work unchanged.