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

torn-client

v0.3.6

Published

Fully-typed and auto-generated TypeScript client for the Torn City v2 API. Supports Node.js and browsers

Readme

Torn API Client

API Compatibility NPM Version License PRs

A TypeScript-first, auto-generated client for the Torn City v2 API

This client provides full type safety, built-in rate limiting and automatic multi-key balancing to simplify interactions with the Torn API

⚠️ Warning

The Torn v2 API is under active development and changes frequently
This client is also a work in progress, use with caution

Some multi-selection endpoints like /user - are not yet fully tested and may behave unexpectedly

Features

  • Fully Typed: Provides strong type safety and autocompletion for API methods and responses
  • Cross-Environment: Works seamlessly in both Node.js and browser environments
  • Zero Runtime Dependencies: No external dependencies, ensuring a lightweight footprint and easy integration
  • Multi-Key Management: Automatically balances requests across multiple API keys using round-robin or random strategies
  • Built-in Rate Limiting: Avoids hitting the API limit by auto-delaying requests
  • Robust Pagination: Simple .next() and .prev() methods are always available on paginated API responses
  • Auto-Generated: The client is generated from the official OpenAPI specification, ensuring it stays up-to-date with API changes

Installation

# Using npm
npm install torn-client

# Using yarn
yarn add torn-client

# Using pnpm
pnpm add torn-client

You can also use torn-client directly in a browser without any build tools by importing it from a CDN like unpkg

<script type="module">
  import { TornAPI } from 'https://unpkg.com/torn-client/dist/index.mjs';

  const client = new TornAPI({ apiKeys: ['YOUR_API_KEY'] });
</script>

Quick Start

import { TornAPI } from 'torn-client';

// Initialize the client with your API keys
const client = new TornAPI({
    apiKeys: ['YOUR_API_KEY'],
    comment: 'MyTornApp',
});

// Example: Fetch a user's profile using a context method
async function getUserProfile() {
    try {
        const user = await client.user.withId(1).profile();
        console.log(user.name, user.level, user.gender);
    } catch (error) {
        console.error('Failed to fetch user profile:', error);
    }
}

getUserProfile();

Usage with Context

The client separates general calls from ID-based ones

Global Call

// Fetches the Hall of Fame for factions, sorted by respect
const factionHof = await client.torn.factionhof({ cat: 'respect' });

Context-Specific Call

// All subsequent calls are now in the context of user ID 1
const userContext = client.user.withId(1);

// Fetch multiple details for the same user without repeating the ID
const profile = await userContext.profile();
const personalStats = await userContext.personalstats({ cat: 'all' });
const properties = await userContext.properties();

Documentation

Full API client reference is available at the Torn Client Docs
For information about Torn API endpoints and parameters, see the official Torn API v2 documentation

Contributing

Contributions, issues, and feature requests are welcome!
Feel free to open an issue or submit a pull request on GitHub
Please read contributing guide first

Contact

Got a question? Open an issue with the "question" label
You can also contact me in Torn: Neon or on Discord: neon0404