Liking cljdoc? Tell your friends :D

clj-yfinance.experimental.auth

⚠️ 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:

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
⚠️ 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
raw docstring

authenticated-requestclj

(authenticated-request url & {:keys [retry-on-401?] :or {retry-on-401? true}})

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 {...}}

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 {...}}
sourceraw docstring

force-refresh!clj

(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.
sourceraw docstring

get-crumbclj

(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.
sourceraw docstring

get-sessionclj

(get-session)

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.

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.
sourceraw docstring

session-infoclj

(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?
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close