Skip to main content

Crate tail_fin_macromicro

Crate tail_fin_macromicro 

Source
Expand description

MacroMicro 財經 M 平方 adapter — pure-HTTP client for www.macromicro.me.

§Auth model (three independent tokens — keep them straight)

  1. Cookies (Netscape file): cf_clearance (Cloudflare bypass), PHPSESSID, mmu, mmt (PHP session + member binding). The cf_clearance token is short-lived (~1h, sometimes a few hours); when it expires, re-export from a logged-in browser visit.
  2. App.stk — 32-hex per-session token rendered in the page HTML at <p data-stk="…"> (footer). Sent as Authorization: Bearer <stk> on /charts/data/* and /api/view/chart/*. The client lazily fetches and caches it; error #1165 triggers a transparent refresh-and-retry inside the public methods, so callers do not need to orchestrate manual recovery.
  3. JWT from GET /api/jwt — member token (sub = member id, role = PRO/FREE, exp +1h). Used for other member-gated APIs; NOT the Bearer for chart data.

Plus a custom Docref header echoing the page URL alongside Referer — both required on chart endpoints.

No browser, no Cloudflare-clearance refresh logic. See http for the request-shape contract.

Re-exports§

pub use http::normalize_ids;
pub use http::MacroMicroClient;
pub use types::*;

Modules§

http
HTTP client for www.macromicro.me. See crate for the auth model.
parsing
Pure JSON → typed conversions plus the HTML helper for extracting the per-session App.stk Bearer token. No I/O.
types
Typed responses for MacroMicro’s forex + charts surface.