The stock borrow Fee Rate is available via the API using the Historical Data Function. This data is available in various units of duration up to the present moment and additional information is available in the API User's Guide.
Are stock loan borrow rates available via the API?
Powered by IBot
How do I obtain historical data via API?
Are historical positions or account balances available from the TWS API?
How can I see studies via the TWS API?
Can I use the API with an IBKR Lite account with IBKR Singapore?