A tiny (~500 bytes) CrUX API wrapper supporting both record and history APIs, with TypeScript types, automatic retry on rate limits, and URL normalization. Current stable version: 4.1.0. Release cadence: irregular, with major versions for breaking changes (ESM conversion in v3, dropping effectiveConnectionType in v4). Key differentiators: isomorphic (browser + Node.js), returns null on 404, handles 429 with retries, and provides TypeScript definitions for API responses. Alternatives require manual fetch handling and lack type safety.
npm install crux-apiNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates queryRecord and queryHistoryRecord instances with an API key, fetches CrUX data for a URL, and normalizes URLs.
Remove effectiveConnectionType parameter from queries; it is no longer supported by CrUX API.
Use ES module imports (import { createQueryRecord } from 'crux-api') or switch to dynamic import.Use individual queryRecord calls for each URL instead of batch.
Pass a valid key to createQueryRecord or createQueryHistoryRecord.
Always check for null return before accessing properties.
Use named import: import { createQueryRecord } from 'crux-api'Wait for quota reset or reduce request frequency. The library retries automatically on 429, but if retries are exhausted, you may need to upgrade your API plan.
The library returns null for 404; handle null gracefully. Ensure URL is normalized (use normalizeUrl).
Use import syntax or dynamic import(): const mod = await import('crux-api')No dependency data recorded yet.