Philosophy
CallApi is built on four core principles: Lightweight: Small bundle size (under 6KB). Zero dependencies. Pure ESM. Simple: Based on the Fetch API and mirrors its interface 1-to-1. Only adds useful features with sensible defaults. Type-safe: Built with TypeScript. Full type support for responses and errors via schemas, validators, and manual generics. Extensible: Plugins and hooks let you add or modify features without changing the core code.CallApi vs Axios
Overview
Axios has been a fundamental part of web development for years and remains popular. However, modern web development has evolved, and CallApi addresses many of Axios’s limitations.Key Differences
- Tab Title
- Tab Title
- Tab Title
- Tab Title
Axios:
- Based on XMLHttpRequest (legacy API)
- Custom API design
- Verbose configuration for some use cases
- Requires adapters for different environments
- Based on modern Fetch API
- Drop-in replacement for fetch
- Concise, intuitive API
- Works everywhere (browsers, Node 18+, Deno, Bun, Workers)
Migration Example
- Tab Title
- Tab Title
When to Choose Axios
- You need IE11 support
- Your team is deeply familiar with Axios and migration cost is high
- You rely on Axios-specific ecosystem packages
When to Choose CallApi
- You want modern, fetch-based API
- Bundle size matters
- You need TypeScript type inference
- You want built-in retries and deduplication
- You need schema validation
- You’re starting a new project
CallApi vs Ky
Overview
Ky is a popular modern fetch wrapper with a focus on simplicity and developer experience.Key Differences
- Tab Title
- Tab Title
- Tab Title
| Feature | Ky | CallApi |
|---|---|---|
| Fetch-based | ✅ | ✅ |
| Timeout Support | ✅ | ✅ |
| Retry Logic | ✅ | ✅ (More flexible) |
| Hooks | ✅ | ✅ (More comprehensive) |
| JSON Handling | ✅ | ✅ (Content-Type aware) |
| Bundle Size | ~5KB | <6KB |
When to Choose Ky
- You want a minimal API with no extra features
- You don’t need schema validation or type inference
- You prefer chaining API style
When to Choose CallApi
- You need request deduplication
- You want schema validation with type inference
- You need a plugin system for extensibility
- You want URL helpers and parameter substitution
- You need streaming progress tracking
CallApi vs Ofetch
Overview
CallApi is highly inspired by Ofetch. Both share similar philosophies and design patterns.Key Differences
- Tab Title
- Tab Title
- Tab Title
Both libraries share:
- Fetch API foundation
- Automatic JSON handling
- Retry support with exponential backoff
- Lifecycle hooks/interceptors
- Object literal request body support
- Timeout support
- TypeScript-first design
Code Comparison
- Tab Title
- Tab Title
- Tab Title
Ofetch:CallApi:
When to Choose Ofetch
- You need a proven, battle-tested library
- You’re already using it and don’t need extra features
- You prefer a slightly simpler API
When to Choose CallApi
- You need request deduplication
- You want built-in schema validation and type inference
- You need a plugin system
- You want streaming progress tracking
- You need URL parameter substitution
- You want method prefixes (@get, @post)
- Smaller bundle size matters
Feature Matrix
Comprehensive comparison of all libraries:| Feature | Axios | Ky | Ofetch | CallApi |
|---|---|---|---|---|
| Core | ||||
| Fetch-based | ❌ | ✅ | ✅ | ✅ |
| Zero Dependencies | ❌ | ✅ | ✅ | ✅ |
| Bundle Size | 13KB | 5KB | 8KB | <6KB |
| Request Features | ||||
| Timeout | ✅ | ✅ | ✅ | ✅ |
| Retry Logic | ❌ | ✅ | ✅ | ✅ |
| Exponential Backoff | ❌ | ⚠️ | ✅ | ✅ |
| Request Cancellation | ✅ | ✅ | ✅ | ✅ |
| Request Deduplication | ❌ | ❌ | ❌ | ✅ |
| URL Param Substitution | ❌ | ❌ | ❌ | ✅ |
| Method Prefixes | ❌ | ❌ | ❌ | ✅ |
| Response Features | ||||
| Auto JSON Parsing | ✅ | ✅ | ✅ | ✅ |
| Content-Type Detection | ⚠️ | ✅ | ✅ | ✅ |
| Schema Validation | ❌ | ❌ | ❌ | ✅ |
| Streaming Progress | ✅ | ❌ | ❌ | ✅ |
| Developer Experience | ||||
| TypeScript Support | ⚠️ | ✅ | ✅ | ✅ |
| Type Inference | ❌ | ⚠️ | ⚠️ | ✅ |
| Hooks/Interceptors | ✅ | ✅ | ✅ | ✅ |
| Plugin System | ❌ | ❌ | ❌ | ✅ |
| Error Handling | ⚠️ | ✅ | ✅ | ✅ |
Migration Paths
For detailed migration guides from each library, see:Summary
CallApi is designed for modern web development: Choose CallApi if you want:- Modern, fetch-based API
- Built-in schema validation with type inference
- Request deduplication for performance
- Extensible plugin system
- Comprehensive TypeScript support
- Small bundle size (<6KB)
- All the convenience features you need
- Axios: You need IE11 support or have heavy Axios investment
- Ky: You want absolute minimal API surface
- Ofetch: You’re already using it and satisfied