Base API client is an abstract class built on top of axios (v0.27.x dependency) that simplifies creating typed API clients in Node.js (>=10) and browser environments. It provides standard HTTP methods (get, post, put, patch, delete), automatic URL resolution relative to a base URL, configurable timeout (using ms format), optional logging via a logger interface, and support for custom headers and basic auth. The package is actively maintained with frequent releases, includes TypeScript definitions, and offers a clean inheritance model for extending into specific API wrappers (e.g., Telegram, CRMs). It is well-tested across Node LTS versions on multiple platforms and has a small bundle size (~5KB gzipped).
npm install base-api-clientNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Extends BaseAPI to create a custom API client with a base URL, timeout, and logger. Demonstrates inheritance, constructor configuration, and HTTP methods.
If you need axios v1 in your project, consider overriding via resolutions or pnpm overrides, but be aware of potential API differences.
Always pass timeout as a string in ms format (e.g., '5000') or as an integer in milliseconds (e.g., 5000) — but note that numbers are not explicitly documented as supported. Safer to use strings.
Make sure your logger object has a .log method that accepts a level (string) and an object (any). For simple logging, you can use console.
Upgrade to v1.0.0 or later and pass options as an object. See constructor documentation.
Run `npm install base-api-client` and use the correct import: `import BaseAPI from 'base-api-client'` (not from a subpath).
Use `import BaseAPI from 'base-api-client'` (default import).
Ensure the logger has a `.log(level, object)` method. You can use a simple wrapper: `{ log: (level, msg) => console[level](msg) }`.Use relative paths (e.g., '/users') that will be resolved against the base URL. Avoid absolute URLs unless intended.