⚠️ EXPERIMENTAL: Authentication and session management for Yahoo Finance.
This namespace handles cookie/crumb authentication for Yahoo's restricted endpoints (fundamentals, options, financial statements).
WARNING: This is experimental and may break at any time. Yahoo can:
For production use, consider stable alternatives:
Implementation notes:
⚠️ EXPERIMENTAL: Authentication and session management for Yahoo Finance. This namespace handles cookie/crumb authentication for Yahoo's restricted endpoints (fundamentals, options, financial statements). WARNING: This is experimental and may break at any time. Yahoo can: - Change authentication at any time - Block or rate-limit requests - Detect automated access For production use, consider stable alternatives: - AlphaVantage: https://www.alphavantage.co/ - Financial Modeling Prep: https://financialmodelingprep.com/ - Polygon.io: https://polygon.io/ Implementation notes: - Uses singleton session (thread-unsafe, single-user) - Cookies auto-refresh every hour - MAX 1 retry on authentication failure - Rate-limit protection via session reuse
(authenticated-request url & {:keys [retry-on-401?] :or {retry-on-401? true}})Make an authenticated HTTP request to Yahoo Finance.
Parameters:
Returns: {:ok? true :response <HttpResponse>} or {:ok? false :error {...}}
Make an authenticated HTTP request to Yahoo Finance.
Parameters:
- url: Full URL string
- retry-on-401?: If true, will attempt ONE session refresh on 401 error
Returns:
{:ok? true :response <HttpResponse>} or
{:ok? false :error {...}}(force-refresh!)Forcefully refresh the session (used after 401 errors).
This is called automatically when authentication fails. MAX 1 retry per request to avoid hammering Yahoo's servers.
Forcefully refresh the session (used after 401 errors). This is called automatically when authentication fails. MAX 1 retry per request to avoid hammering Yahoo's servers.
(get-crumb)Get the current authentication crumb.
Returns the crumb string or nil if session not initialized.
Get the current authentication crumb. Returns the crumb string or nil if session not initialized.
(get-session)Returns current authenticated session, refreshing if needed.
The session includes:
Sessions are automatically refreshed after 1 hour or on authentication failure.
Returns current authenticated session, refreshing if needed. The session includes: - :http-client - Java HttpClient instance with cookies - :crumb - Authentication crumb for Yahoo API - :created-at - Session creation timestamp - :status - :active, :failed, or :uninitialized Sessions are automatically refreshed after 1 hour or on authentication failure.
(session-info)Get information about the current session (for debugging).
Returns map with :status, :age-minutes, :crumb-present?
Get information about the current session (for debugging). Returns map with :status, :age-minutes, :crumb-present?
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |