A wrapper around superagent that simplifies HTTP API calls by allowing developers to define services declaratively with methods, paths, and default options. The library provides a centralized configuration for base URL, headers, and options, and returns Promise-based functions for each service. Current version 0.23.1 is stable but has minimal release cadence (last update 2018). It differs from bare superagent by removing boilerplate and enabling service definitions, though it requires manual injection of the superagent agent and is not actively maintained. Superseded by modern alternatives like Axios or ky.
npm install superapiNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to configure superapi with a base URL, headers, services, inject superagent, and make GET and POST calls using promises.
api.agent = require('superagent');Check that api.agent is set before calling HTTP verb helpers.
Ensure service paths are absolute (with leading '/') or correctly relative.
Use CommonJS require() and ensure a bundler that can handle ES module transpiled code.
Use `const superapi = require('superapi');` instead of `require('superapi').default`.Add api.agent = require('superagent'); after creating the api instance.Check the `services` configuration: the key used in `api.api[key]` must exactly match the key in the services object.
Ensure the path in service config starts with '/' and the baseUrl ends without a slash, or adjust accordingly.