LoliAPI Frontend
Overview
Implement reliable frontend integrations for LoliAPI image endpoints. Default to framework-agnostic JavaScript + Fetch and adapt to React/Vue only when explicitly requested.
Workflow Decision Tree
- •Determine output type.
- •Need a visible image quickly: use endpoint URL directly as
<img src>. - •Need the source URL string for composition/logging/storage: call endpoint with
type=url.
- •Determine endpoint family.
- •Adaptive image:
/acg/ - •Desktop image:
/acg/pc/ - •Mobile image:
/acg/pe/ - •Avatar image:
/acg/pp/ - •Random background image:
/bg/
- •Determine randomness strategy.
- •Random image: omit
id. - •Stable image: pass
id=<integer>.
- •Apply resilience defaults.
- •Validate inputs before request.
- •Apply timeout via
AbortController. - •Retry once for transient network failures.
- •Provide loading, success, and error UI states.
- •Escalate to diagnostics.
- •Read
references/troubleshooting.mdwhen response shape, redirect behavior, or rendering is inconsistent.
Required Output Contract
When generating integration code, include all items below unless the user explicitly opts out.
- •Expose one URL builder function that accepts
endpoint, optionalid, and optionaltype. - •Use
URLandURLSearchParamsinstead of string concatenation. - •Include timeout handling and user-facing error fallback.
- •Document whether code relies on redirect behavior or
type=url. - •Keep code framework-agnostic by default; adapt only when requested.
Reference Loading Rules
- •Read
references/endpoints.mdfirst for endpoint capabilities and parameter behavior. - •Read
references/frontend-patterns.mdwhen generating concrete code. - •Read
references/troubleshooting.mdonly when debugging or hardening behavior. - •Treat
/getip/as low-trust documentation unless independently verified.
Guardrails
- •Never assume
/getip/examples are correct; the source document section is inconsistent. - •Avoid assumptions beyond documented endpoint behavior.
- •Prefer deterministic fallback behavior:
- •If
idis invalid, dropidand fetch random. - •If
typeis invalid, omittypeand accept default redirect.