npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dynamic-api-wrapper

v1.0.0

Published

A flexible API wrapper for any REST API

Downloads

4

Readme

🚀 Dynamic API Wrapper

npm version License: MIT

A powerful, flexible, and easy-to-use API wrapper for any REST API.
Simplify API integrations in Node.js with built-in authentication, error handling, and rate limiting.


🌟 Features

✅ Supports GET, POST, PUT, DELETE, PATCH requests
✅ Works with any REST API
✅ Supports API Key & OAuth authentication
Automatic retries on failures & rate limits
Environment variable support (for API keys)
Modular & Extensible
TypeScript support for better DX


📌 When to Use

  • Connecting to external REST APIs in a Node.js project
  • Building microservices that require multiple API calls
  • Simplifying API integration for internal and external services
  • Handling authentication, retries, and error handling automatically

🛠️ How This API Wrapper Makes Your Work Easier

Before using this wrapper, you might be making raw API calls manually using axios or fetch, leading to:
Repeated code for handling API requests
Hardcoded authentication headers everywhere
No error handling for rate limits or failed requests
Difficult debugging & maintenance

✅ How This Wrapper Helps

🔹 One-time setup → Initialize the client once and reuse it
🔹 Automatic authentication → No need to manually add headers
🔹 Built-in error handling → Automatically retries rate-limited requests
🔹 Less code, more efficiency → Clean, readable API calls
🔹 Consistent API design → Same method for any REST API

📌 Example Before vs. After Using This Wrapper

Without This Wrapper (Traditional Approach)

const axios = require("axios");

async function getUser(userId) {
  try {
    const response = await axios.get(`https://api.example.com/users/${userId}`, {
      headers: { Authorization: `Bearer ${process.env.API_KEY}` }
    });
    return response.data;
  } catch (error) {
    console.error("API Error:", error.message);
  }
}

getUser("12345");

With This Wrapper

const DynamicAPIWrapper = require("dynamic-api-wrapper");

const api = new DynamicAPIWrapper({
  baseURL: "https://api.example.com",
  apiKey: process.env.API_KEY,
});

async function getUser() {
  try {
    const user = await api.get("/users/12345");
    console.log(user);
  } catch (error) {
    console.error("Error:", error.message);
  }
}

getUser();

🎯 What's Different?

No need to manually handle headers
No need to handle errors manually
Reusable client for multiple API calls
Cleaner, more readable code


📦 Installation

Install via NPM:

npm install dynamic-api-wrapper

Or using Yarn:

yarn add dynamic-api-wrapper

🚀 Quick Start

1️⃣ Import & Initialize

const DynamicAPIWrapper = require("dynamic-api-wrapper");

const api = new DynamicAPIWrapper({
  baseURL: "https://api.example.com",
  apiKey: process.env.API_KEY, // API Key from .env
});

2️⃣ Make API Requests

GET Request

async function fetchUser() {
  try {
    const user = await api.get("/users/12345");
    console.log(user);
  } catch (error) {
    console.error("Error:", error.message);
  }
}
fetchUser();

POST Request

api.post("/users", { name: "John Doe" })
  .then(response => console.log(response))
  .catch(error => console.error(error));

OAuth Support

const api = new DynamicAPIWrapper({
  baseURL: "https://api.example.com",
  token: process.env.OAUTH_TOKEN,
  authType: "oauth",
});

⚙️ How It Works

  1. Create an API client instance with baseURL and authentication method.
  2. Make API calls using get(), post(), put(), or delete().
  3. Handles rate limits, errors, and retries automatically.

✅ Uses Axios for requests
✅ Supports OAuth and API Key-based authentication
✅ Retries 429 (Rate Limit Exceeded) errors automatically


🛠️ Configuration

Using .env for API Keys

Create a .env file and store your API credentials securely:

API_KEY=your_api_key_here
API_BASE_URL=https://api.example.com

Then, use it in your code:

require("dotenv").config();

💡 Advanced Usage

Custom Headers

api.get("/data", {}, { "Custom-Header": "value" });

Sending Query Parameters

api.get("/search", { query: "test", limit: 10 });

Handling Errors

try {
  const response = await api.get("/users/12345");
} catch (error) {
  console.error("API Error:", error.message);
}

📝 License

This project is licensed under the MIT License.
Read More


👨‍💻 Author

Ankit – Full Stack Developer
🔗 LinkedIn
🔗 GitHub
🔗 NPM Profile

Support My Work:
Buy Me A Coffee


💬 Contributing

Contributions are welcome!
Feel free to submit issues and pull requests on GitHub.

Happy coding! 🚀