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

gettt

v1.0.0

Published

gettt is a production-ready, fully-featured fetch wrapper for JavaScript and TypeScript. It provides a simple and intuitive API for making HTTP requests, with support for features like request cancellation, retries, and timeouts.

Readme

Gettt

A production-ready, fully-featured HTTP fetch wrapper for JavaScript and TypeScript. Gettt provides a clean, standardized API with built-in retry logic, caching, rate limiting, and comprehensive hook support for seamless integration into any application.

Features

  • Standardized Response Format: Consistent { data, error, status, headers, meta } structure across all requests
  • Smart Caching: TTL-based caching with stale-while-revalidate support
  • Automatic Retries: Configurable retry attempts with backoff
  • Request Deduplication: Automatically deduplicates identical in-flight requests
  • Rate Limiting: Built-in token bucket rate limiter
  • Circuit Breaker: Prevents cascade failures with automatic circuit breaking
  • Authentication: Seamless bearer token injection
  • Response Transformation: Built-in response normalization
  • Abort Signals: Full AbortController support for request cancellation
  • Comprehensive Hooks: Logging hooks for request/response/error/retry/cache events
  • TypeScript First: Fully typed with excellent IDE support

Table of Contents

Quick Start

npm install gettt
import gettt from 'gettt';

const res = await gettt('/users', { transform: (raw) => raw.items });
console.log(res.data);

Installation

npm install gettt
# or
yarn add gettt

Usage

Basic Example

import gettt from 'gettt';

const res = await gettt('/users', {
  transform: (raw) => raw.items, // avoid data.data
  retry: { attempts: 3 },
  cache: { ttl: 60000, staleWhileRevalidate: true },
  dedupe: true
});

if (res.error) console.error('Error:', res.error);
else console.log('Users:', res.data);

HTTP Methods

gettt supports all standard HTTP verbs:

const res = await gettt.get('/users');
const res2 = await gettt.post('/users', { body: JSON.stringify({ name: 'Alice' }) });
const res3 = await gettt.put('/users/1', { body: JSON.stringify({ name: 'Bob' }) });
const res4 = await gettt.delete('/users/1');

Request Cancellation

const controller = new AbortController();
setTimeout(() => controller.abort(), 2000);

const res = await gettt('/users', { signal: controller.signal });

if (res.error) console.log('Request failed or aborted');
else console.log('Users:', res.data);

Response Transformation

Normalize API responses to avoid data.data:

const res = await gettt('/users', {
  transform: (raw) => raw.results
});

console.log(res.data); // fully normalized

API Reference

Configuration Options

| Option | Type | Description | | ---------------- | -------------------------------------------------- | ----------------------------------------------------------------------------- | | baseURL | string | Base URL for all requests | | headers | Record<string,string> | Default headers | | retry | { attempts?: number } | Number of retry attempts | | timeout | number | Timeout per request (ms) | | auth | { getToken?: () => string \| Promise<string> } | Function to get bearer token | | cache | { ttl?: number, staleWhileRevalidate?: boolean } | Cache responses | | dedupe | boolean | Deduplicate identical in-flight requests | | rateLimit | { max: number, window: number } | Token bucket rate limiter | | circuitBreaker | { failureThreshold: number, cooldown: number } | Open circuit after failures | | hooks | object | Logging hooks (onRequest, onResponse, onError, onRetry, onCacheHit) | | transform | function | Transform raw response data | | signal | AbortSignal | Abort controller |

Hook System

import { Gettt } from 'gettt';

const api = new Gettt({
  hooks: {
    onRequest: (ctx) => console.log('Request →', ctx.request.url),
    onResponse: (ctx) => console.log('Response ←', ctx.response?.status),
    onError: (ctx) => console.error('Error ✖', ctx.error),
    onRetry: (ctx) => console.warn('Retry attempt', ctx.meta.attempt),
    onCacheHit: (ctx) => console.log('Cache hit for', ctx.request.url)
  }
});

Response Type

Every request returns a GetttResult:

type GetttResult<T = any> = {
  data: T | null;
  error: string | null;
  status: number;
  headers?: Record<string,string>;
  meta?: {
    attempt: number;
    duration: number;
    cached?: boolean;
    circuitOpen?: boolean;
  }
};

Advanced Usage

Request Flow

             ┌──────────────────────┐
             │  User calls gettt()    │
             │  or api.get/post()    │
             └─────────┬────────────┘
                       │
                       ▼
            ┌─────────────────────┐
            │  Merge configs &    │
            │  apply defaults     │
            └─────────┬───────────┘
                      │
                      ▼
            ┌─────────────────────┐
            │  Circuit Breaker?   │
            │  (open → abort)     │
            └─────────┬───────────┘
                      │
                      ▼
            ┌─────────────────────┐
            │  Rate Limit check   │
            │  (wait if needed)   │
            └─────────┬───────────┘
                      │
                      ▼
            ┌─────────────────────┐
            │ Deduplication check │
            │  (return in-flight) │
            └─────────┬───────────┘
                      │
                      ▼
            ┌─────────────────────┐
            │  Cache lookup       │
            │  (return if hit)    │
            └─────────┬───────────┘
                      │
                      ▼
            ┌─────────────────────┐
            │   Auth Token inject │
            └─────────┬───────────┘
                      │
                      ▼
            ┌─────────────────────┐
            │  Apply AbortSignal  │
            └─────────┬───────────┘
                      │
                      ▼
            ┌─────────────────────┐
            │     Retry loop      │
            │  (with timeout)     │
            └─────────┬───────────┘
                      │
                      ▼
            ┌─────────────────────┐
            │      Fetch API      │
            └─────────┬───────────┘
                      │
         ┌────────────┴────────────┐
         │                         │
         ▼                         ▼
   Success response           Network/Error
         │                         │
         ▼                         ▼
  Transform function applied     Retry or return error
         │
         ▼
  Cache store updated
         │
         ▼
   Dedup in-flight cleared
         │
         ▼
    Return standardized

{ data, error, status, headers, meta }

Production Configuration

import { Gettt } from 'gettt';

const api = new Gettt({
  baseURL: 'https://api.example.com',
  auth: { getToken: async () => 'mytoken123' },
  retry: { attempts: 3 },
  cache: { ttl: 60000 },
  dedupe: true,
  rateLimit: { max: 5, window: 1000 },
  circuitBreaker: { failureThreshold: 3, cooldown: 5000 },
  transform: (raw) => raw.items,
  hooks: {
    onRequest: (ctx) => console.log('Requesting:', ctx.request.url),
    onResponse: (ctx) => console.log('Received status:', ctx.response?.status)
  }
});

const users = await api.get('/users');
console.log(users.data);

Why Gettt?

Gettt solves common HTTP client pain points:

  • No more data.data: Standardized response format prevents data structure inconsistencies
  • Production-ready out of the box: Built-in retry logic, circuit breaker, and rate limiting
  • Request intelligence: Automatic deduplication and caching eliminate redundant network calls
  • Better debugging: Comprehensive hook system provides visibility into request lifecycle
  • Developer experience: Fully typed API with excellent TypeScript support

License

MIT License © 2026 Han Lin Yap