ibflex
ibflex copied to clipboard
Remove hardcoded URL that breaks API connectivity
Problem
Commit 0a4989c introduced a hardcoded URL override in request_statement() that breaks API connectivity:
def request_statement(token: str, query_id: str, url: Optional[str] = None) -> StatementAccess:
"""First part of the 2-step download process."""
url = url or REQUEST_URL
### AKE FIX
url = 'https://ndcdyn.interactivebrokers.com/portal.flexweb/api/v1/flexQuery' # ← BREAKS CONNECTIVITY
response = submit_request(url, token, query=query_id)
...
This hardcoded URL causes timeout errors for users:
Request Timeout, re-sending...
Impact
- Users cannot connect to IB FlexQuery API
- The
urlparameter is completely ignored - Applications using this library are broken
- Affects all users who upgraded to commit 0a4989c or later
Root Cause
The hardcoded URL https://ndcdyn.interactivebrokers.com/portal.flexweb/api/v1/flexQuery appears to be a non-standard endpoint that doesn't work for most users. The standard endpoint is:
REQUEST_URL = 'https://gdcdyn.interactivebrokers.com/Universal/servlet/FlexStatementService.SendRequest'
Solution
Remove the 2-line hardcoded URL override and restore the original logic:
url = url or REQUEST_URL
This allows:
- Default behavior: use
REQUEST_URL - Custom URLs: pass via
urlparameter - Proper API connectivity for all users
Testing
- ✅ Tested with production IB accounts
- ✅ API connections work after removing hardcoded URL
- ✅ API connections fail with the hardcoded URL
Changes
- Remove 2 lines that hardcode the URL
- Restore original URL selection logic
- No other changes needed
This is a critical fix for API connectivity.