Introduction
@bishal-shrestha/rest-client is a lightweight, extensible, and strongly-typed HTTP client for interacting with RESTful APIs with support for GET
, POST
, PATCH
, PUT
, DELETE
in JavaScript and TypeScript. Built on the Fetch API, with built-in support for retries, timeouts, and request lifecycle hooks.
The library is fully compatible with CommonJS (CJS), ES module (ESM) and Universal Module Definition (UMD) environments and provides complete TypeScript typings for seamless integration in modern JavaScript and TypeScript projects.
Features
- Supports all standard RESTful HTTP methods:
GET
,POST
,PUT
,PATCH
, andDELETE
- Automatic handling of JSON and plain text responses
- Configurable request timeout management
- Built-in retry mechanism with exponential backoff, customizable per use case
- Support for default headers, including authorization tokens and API keys
- Ability to override headers and append query parameters on a per-request basis
- Request cancellation using AbortController
- Comprehensive error reporting with status code, status text, and response content
- Fully compatible with CommonJS, ES Modules, and UMD environments
- Complete TypeScript typings for type safety and IntelliSense support
Note
Versions 1.0.0
to 1.0.5
were reserved for internal testing and were not published to npm. Public releases start from 1.0.6
.