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

howlongtobeat-ts

v1.0.2

Published

TypeScript library to extrapolate data from HowLongToBeat.com search results.

Readme

howlongtobeat-ts

Ask DeepWiki GitHub npm npm

A TypeScript library for interacting with the HowLongToBeat website API. Easily search for games and retrieve estimates on how long it takes to complete them.

This project is heavily inspired by howlongtobeat-js by toasttsunami, but has been rewritten in TypeScript for improved type safety and maintainability.

As also noted by toasttsunami in his implementation, this library was created due to the inactivity of ckatzorke's howlongtobeat project, which appears to be abandoned. Additionally, recent changes to the HowLongToBeat.com API have rendered it non-functional, making alternative solutions necessary.

⚠️ Disclaimer: This library is not an official API and is not affiliated nor endorsed with HowLongToBeat.com or Ziff Davis LLC in any way. Please use this library responsibly and do not abuse or overload the HowLongToBeat servers. Use at your own risk.

Features

  • Search for games on HowLongToBeat
  • Retrieve completion time data for games
  • TypeScript support with full type definitions

Installation

Install the library via npm:

npm install howlongtobeat-ts

Usage

import { HowLongToBeatService, SearchModifier } from 'howlongtobeat-ts';

async function searchGame() {
  const hltbService = new HowLongToBeatService();
  
  // Search for a game
  const results = await hltbService.search('The Last of Us');
  
  if (results) {
    console.log('Search results:', results);
  }
}

// With search modifier
async function searchWithModifier() {
  const hltbService = new HowLongToBeatService();
  const results = await hltbService.search('Zelda', SearchModifier.HIDE_DLC);
  
  if (results) {
    console.log('Search results:', results);
  }
}

searchGame();

API

HowLongToBeatService

The main service class for interacting with the HowLongToBeat website.

Constructor

  • constructor(minSimilarity: number = 0.5): Creates an instance of the HowLongToBeatService class.
    • minSimilarity: Optional parameter to set the minimum similarity threshold for search results to not be filtered out (Default: 0.5).

Methods

  • async search(searchKey: string, searchModifier: SearchModifier = SearchModifier.NONE): Promise<HowLongToBeatEntry[]>: Searches for games matching the provided search key.
    • searchKey: The game title to search for
    • searchModifier: Optional search modifier to adjust search behavior that defaults to SearchModifier.NONE allowing all results.

SearchModifier

An enum representing different search modifiers that can be used to filter search results.

  • NONE: No modifier, all results are returned.
  • HIDE_DLC: Hides DLCs from the search results.
  • ONLY_DLC: Only shows DLCs in the search results.

HowLongToBeatEntry

An interface representing a game entry returned from the HowLongToBeat API.

  • id: The unique identifier for the game.
  • name: The name of the game.
  • mainTime: The average time to complete the main story.
  • mainCount: The number of users who reported the main story completion time.
  • mainExtrasTime: The average time to complete the main story plus extras.
  • mainExtrasCount: The number of users who reported the main story plus extras completion time.
  • completionistTime: The average time to complete the game 100%.
  • completionistCount: The number of users who reported the 100% completion time.
  • allStylesTime: The average time to complete the game in all styles.
  • allStylesCount: The number of users who reported the all styles completion time.
  • coopTime: The average time to complete the game in co-op mode.
  • coopCount: The number of users who reported the co-op completion time.
  • multiplayerTime: The average time to complete the game in multiplayer mode.
  • multiplayerCount: The number of users who reported the multiplayer completion time.
  • image: The URL of the game's image.
  • reviewScore: The review score of the game on HowLongToBeat.
  • platforms: An array of platforms the game is available on.
  • similarity: The similarity score of the game to the search query.
  • releaseYear: The release year of the game.
  • json: The raw JSON response from the HowLongToBeat API allowing for further inspection.

Development

Prerequisites

  • Node.js
  • npm or yarn

Setup

# Clone the repository
git clone https://github.com/Deadlock-too/howlongtobeat-ts.git

# Install dependencies
cd howlongtobeat-ts
npm install

# Build the project
npm run build

# Run tests
npm test

Issues, Questions & Discussions

If you found a bug, report it as soon as possible creating an issue, the code is not perfect for sure, and I will be happy to fix it. If you need any new feature, or want to discuss the current implementation/features, consider opening a discussion or even propose a change with a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.