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

supaapps-api-kit-client

v0.9.2

Published

A versatile, type-safe API kit client designed for TypeScript applications.

Readme

supaapps-api-kit-client

A versatile, type-safe API client designed for TypeScript applications. It simplifies making HTTP requests and handling responses with built-in support for authorization and automatic handling of unauthorized access scenarios, integrates with supaapps-auth to handle Automatic Token Refresh and Callbacks when auth fails.

Features

  • Type Safety: Leverages TypeScript for ensuring type safety in requests and responses.
  • Authorization Support: Automatically includes authorization tokens in requests.
  • Customizable Unauthorized Access Handling: Executes a callback function when encountering a 401 Unauthorized response, allowing for custom reaction strategies such as redirecting to a login page.
  • Simplified API Requests: Offers methods for common HTTP requests (GET, POST, PUT, PATCH, DELETE) with a straightforward, promise-based API.

Installation

Install the package using npm:

npm install supaapps-api-kit-client
# or
yarn add supaapps-api-kit-client

Setup

Before making any requests, initialize the ApiKitClient with your API's base URL, an authorization token, and a callback function for handling unauthorized access.

import { ApiKitClient } from 'supaapps-api-kit-client';

const BASE_URL = 'https://api.example.com'

const authTokenCallback = () => {
  // Implement authToken logic here
};

const unauthorizationCallback = () => {
  // Implement redirection to login page here
};

const useAuth: boolean = // Optional: default is false, use true if you want to use auth;

// in case of using auth
ApiKitClient.initialize(BASE_URL, authTokenCallback, unauthorizationCallback, true);


// in case of not using auth
ApiKitClient.initialize(BASE_URL);

You can initialize multiple ApiClient instances with different configurations if needed. here is ways to initialize multiple instances


import {ApiKitClient} from "./ApiKitClient";

const apiClient1 = (new ApiKitClient()).initialize(BASE_URL); // this initialize apiClient with key 'default'
const apiClient2 = (new ApiKitClient('default')).initialize(BASE_URL); // this initialize apiClient with 'default' as well
const apiClient3 = (new ApiKitClient('public')).initialize(BASE_URL); // this initialize apiClient with 'public'

// set key with method
const apiClient4 = ApiKitClient.i('public').initialize(BASE_URL); // this initialize apiClient with 'public' key

const apiClient5 = ApiKitClient.i('billing').initialize(BASE_URL, authTokenCallback, unauthorizationCallback, true); // this initialize apiClient with 'billing' key

Making Requests

Use the ApiKitClient instance to make API requests. Here are some examples:

Fetching Data

Fetch a list of resources:

interface User {
  id: number;
  name: string;
  email: string;
}

ApiKitClient.get<User[]>('/users')
  .then(response => console.log(response.data)) // Expected to be of type User[]
  .catch(error => console.error(error));

Fetch a single resource:

ApiKitClient.getOne<User>('/users/1')
  .then(response => console.log(response.data)) // Expected to be of type User
  .catch(error => console.error(error));

Fetch a paginated resource:

ApiKitClient.getPaginated<User>('/users')
  .then(response => console.log(response)) // Expected to be of type PaginatedResponse<User>
  .catch(error => console.error(error));

Creating Data

// Create a new user
const newUser: User = {
  id: 1,
  name: 'John Doe',
  email: '[email protected]',
};

ApiKitClient.post<User>('/users', newUser)
  .then(response => console.log(response.data)) // Expected to be of type User
  .catch(error => console.error(error));

Updating Data

// Update a user's information
const updatedUser: User = {
  id: 1,
  name: 'Jane Doe',
  email: '[email protected]',
};

const updatedUser2: User = {
  name: 'Jane Doe',
};

ApiKitClient.put<User>('/users/1', updatedUser)
  .then(response => console.log(response.data)) // Expected to be of type User
  .catch(error => console.error(error));

ApiKitClient.patch<User>('/users/1', updatedUser2)
  .then(response => console.log(response.data)) // Expected to be of type User
  .catch(error => console.error(error));

Deleting Data

// Delete a user
ApiKitClient.delete('/users/1')
  .then(() => console.log('User deleted'))
  .catch(error => console.error(error));

Handling Unauthorized Access

The unauthorized access callback provided during initialization will be called automatically for any request that receives a 401 Unauthorized response, allowing you to handle such scenarios globally (e.g., redirecting the user to a login page).