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

ks-smart-api

v1.1.3

Published

A small, dependency-light API helper built on top of Axios.

Readme

ks-smart-api

A small, dependency-light API helper built on top of Axios.

  • Create a shared Axios client once (createClient)
  • Make requests with optional Bearer auth (request)
  • Store/clear an in-memory token (setToken, clearToken)
  • Optional console logging (setLogger)

Install

npm i ks-smart-api

Quick start

const { createClient, request, setToken, setLogger } = require('ks-smart-api');

createClient({ baseURL: 'https://api.example.com', timeout: 10000 });
setLogger(true); // optional
setToken('YOUR_JWT_OR_TOKEN'); // optional

async function run() {
  const me = await request({ method: 'GET', url: '/me' });
  console.log(me);
}

run().catch(console.error);

API

createClient({ baseURL, timeout? })

Creates and stores an Axios client used by request.

  • baseURL: string (required)
  • timeout: number in ms (optional, default: 10000)

Returns the created Axios instance.

request({ method, url, data?, params? })

Performs a request using the created client.

  • method: HTTP method string (e.g. "GET", "POST", "PUT", "DELETE")
  • url: string path or URL (commonly a path like "/users")
  • data: request body (optional)
  • params: query params object (optional)

Auth behavior:

  • If a token is set via setToken(token), request sends Authorization: Bearer <token>.

Return value:

  • Resolves with response.data.

Errors:

  • If the server responded, throws an object like { status, message }
  • Otherwise throws { status: 500, message }

setToken(token)

Stores an in-memory token used by request.

clearToken()

Clears the stored token.

setLogger(boolean)

Enable/disable console logging. When enabled, logs with a [API] prefix.

Notes

  • Token storage is in-memory (not persisted). If you need persistence, store the token in your app and call setToken() on startup.
  • You must call createClient() before request() or you’ll get Error: API client not initialized.