hapic is an HTTP API client built on top of axios, designed to simplify interactions with RESTful APIs. Current stable version is 2.8.2, released in September 2024, with monthly releases. It provides features like query building, JSON:API support, pagination, sorting, field selection, and includes relationships. Unlike plain axios or fetch, hapic offers a declarative way to construct complex API requests with type safety through TypeScript. It supports browser and Node.js environments.
npm install hapicNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a client with base URL and auth, then making a GET request with JSON:API query parameters (include, sort, fields, pagination).
Create a new client with createClient() for each configuration set.
Use Axios' transformResponse config directly when creating the client.
Always use the appropriate types (e.g., array for include, object for fields).
Use import syntax or set type: 'module' in package.json.
Ensure you have installed hapic and have 'moduleResolution': 'node' in tsconfig.json.
Use createClient() to instantiate the client, then call methods on the returned object.
Verify the baseURL and path in the request.