Welcome to CallApi
An advanced fetch library that actually solves real problems. Drop-in replacement for fetch with zero dependencies and under 6KB.Quick Start
Get up and running with CallApi in under 5 minutes
Installation
Install CallApi with your favorite package manager
API Reference
Explore the complete API documentation
Plugins
Extend CallApi with powerful plugins
Why CallApi?
Fetch is too basic for real apps. You end up writing the same boilerplate: error handling, retries, deduplication, response parsing, and more. CallApi handles all of that and practically more.Key Features
Request Deduplication
Automatically handles duplicate requests. No race conditions, no wasted bandwidth.
Smart Response Parsing
Automatically detects Content-Type and parses responses accordingly.
Structured Error Handling
HTTPError, ValidationError, and JavaScript errors all structured for easy handling.
Automatic Retries
Built-in retry logic with exponential backoff and custom retry conditions.
Schema Validation
TypeScript-first with runtime validation using Zod, Valibot, or any Standard Schema.
Lifecycle Hooks
Hook into any point of the request/response lifecycle for maximum control.
Plugin System
Extend functionality with reusable plugins for logging, metrics, auth, and more.
URL Helpers
Dynamic params, query strings, and method prefixes make URLs effortless.
Request Deduplication
User spam-clicks a button? CallApi handles it automatically. No race conditions.The default
dedupeStrategy is "cancel" which cancels the previous request. Use "defer" to share responses, or "off" to disable deduplication.Smart Response Parsing
CallApi looks at the Content-Type header and automatically parses your responses.json, text, blob, arrayBuffer, formData, stream
Structured Error Handling
No more guessing what went wrong. CallApi provides structured errors for every scenario.Automatic Retries
Retries with exponential backoff out of the box. Fully configurable.Schema Validation
Define your API contract with TypeScript types and runtime validation.CallApi supports any validation library that implements the Standard Schema specification, including Zod, Valibot, Yup, and more.
Lifecycle Hooks
Hook into CallApi’s lifecycle at any point for logging, authentication, error tracking, and more.onRequest- Before the request is sentonRequestReady- After request is prepared but before fetchonSuccess- On successful response (2xx status)onResponse- On any response (success or HTTP error)onResponseError- On HTTP error responses (4xx, 5xx)onValidationError- On schema validation failureonRequestError- On network/request errorsonError- On any erroronRequestStream- For upload progress trackingonResponseStream- For download progress tracking
Plugin System
Extend CallApi with reusable plugins for cross-cutting concerns.URL Helpers
Dynamic params, query strings, and method prefixes make working with URLs effortless.@get, @post, @put, @patch, @delete, @head, @options
What Makes CallApi Special?
TypeScript-First
Full type inference everywhere. Write once, type-safe forever.
Familiar API
If you know fetch, you already know CallApi.
Actually Small
Under 6KB gzipped. Zero dependencies. Not 50KB like other libraries.
Blazing Fast
Built on native Web APIs. No unnecessary abstractions.
Works Everywhere
Browsers, Node.js 18+, Deno, Bun, Cloudflare Workers, and more.
Battle-Tested
Used in production by teams building real applications.
Runtime Support
CallApi works in any JavaScript runtime that supports the Fetch API:- Browsers (modern)
- Node.js 18+
- Deno
- Bun
- Cloudflare Workers
- Vercel Edge Functions
- Any other environment with native fetch
Next Steps
Quick Start
Build your first CallApi request in 5 minutes
Installation Guide
Install CallApi with npm, yarn, pnpm, or bun