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

@studiometa/forge-api

v0.3.0

Published

Laravel Forge API client — HTTP client, types, config storage, and rate limiting

Downloads

1,121

Readme

@studiometa/forge-api

npm version License: MIT

Internal HTTP client, TypeScript types, configuration storage, and rate limiting for the Laravel Forge API. This is the foundation package for all @studiometa/forge-* packages.

Note: Most users should use @studiometa/forge-sdk instead, which provides a fluent, chainable API on top of this package.

Installation

npm install @studiometa/forge-api

Usage

HTTP Client

import { HttpClient } from '@studiometa/forge-api';

const client = new HttpClient({
  token: 'your-api-token',
});

// Direct API calls
const response = await client.get('/servers');
const server = await client.post('/servers', { name: 'web-1', ... });
await client.delete('/servers/123');

Configuration

Read API token from environment variable or config file:

import { getToken, setToken, deleteToken } from "@studiometa/forge-api";

// Resolution: FORGE_API_TOKEN env var > config file
const token = getToken();

// Save to config file (~/.config/forge-tools/config.json)
setToken("your-token");

// Remove config
deleteToken();

Error Handling

import { ForgeApiError, isForgeApiError } from "@studiometa/forge-api";

try {
  await client.get("/servers/999");
} catch (error) {
  if (isForgeApiError(error)) {
    console.log(error.status); // 404
    console.log(error.statusText); // "Resource not found"
    console.log(error.url); // "/servers/999"
    console.log(error.body); // API response body
  }
}

Rate Limiting

The HTTP client includes automatic rate limiting (60 requests/minute) with exponential backoff on 429 responses:

const client = new HttpClient({
  token: "your-token",
  rateLimit: {
    maxRetries: 3, // Max retries on 429 (default: 3)
    baseDelay: 1000, // Base delay in ms (default: 1000)
  },
});

Dependency Injection (Testing)

const mockFetch = async () => ({
  ok: true,
  status: 200,
  headers: new Headers({ "content-type": "application/json" }),
  json: async () => ({ servers: [] }),
  text: async () => "{}",
});

const client = new HttpClient({
  token: "test",
  fetch: mockFetch,
});

Exports

| Export | Description | | --------------------------------------- | ----------------------------------------------------- | | HttpClient | Low-level HTTP client with auth, rate limiting, retry | | ForgeApiError | Typed error with status, url, body | | isForgeApiError() | Type guard for ForgeApiError | | RateLimiter | Sliding window rate limiter (60 req/min) | | ConfigStore | XDG-compliant JSON config store | | getToken / setToken / deleteToken | Token management helpers | | Type definitions | ForgeServer, ForgeSite, ForgeDeployment, etc. |

Config Storage

| Platform | Path | | -------- | ------------------------------------------------------- | | Linux | ~/.config/forge-tools/config.json | | macOS | ~/Library/Application Support/forge-tools/config.json | | Windows | %APPDATA%/forge-tools/config.json |

License

MIT © Studio Meta