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 🙏

© 2025 – Pkg Stats / Ryan Hefner

howlongtobeat-js

v1.0.2

Published

Collects data from howlongtobeat.com using game title or id

Readme

howlongtobeat-js

A simple project that provides a Node.js API for interacting with the HowLongToBeat website, allowing you to search for games and retrieve information about their completion times.

Heavily inspired by ScrappyCocco's HowLongToBeat Python API and ckatzorke's howlongtobeat javascript API.

This project was made due to the lack of activity by ckatzorke on their repo, whose api i was utilizing in another project, but it broke due to changed made by HowLongToBeat.

Features

  • Search for games by name
  • Retrieve game information by ID
  • Parse and process JSON results from HowLongToBeat
  • Calculate string similarities for improved search results
  • Customizable search options, including DLC filtering

Installation

Clone the repository:

To use this API in your project, follow these steps:

  1. Clone the repository:

    git clone https://github.com/toasttsunami/hltb-js.git
  2. Install the dependencies:

    cd hltb-js
    npm install
  3. Import the HowLongToBeat class in your project:

    const { HowLongToBeat } = require('./path/to/HowLongToBeat.js');

Install from npm

Alternatively, you can install the howlongtobeat-js package directly from npm:

  1. Install the package:

    npm install howlongtobeat-js
  2. Import howlongtobeat-js into your project:

    const { HowLongToBeat } = require('howlongtobeat-js')

Usage

Searching for a game

const { HowLongToBeat } = require('./HowLongToBeat.js');

const hltb = new HowLongToBeat();

async function searchGame(gameName) {
  try {
    const results = await hltb.search(gameName);
    console.log(results);
  } catch (error) {
    console.error('Error searching for game:', error);
  }
}

searchGame('Dark Souls');

Retrieving game information by ID

async function getGameById(gameId) {
  try {
    const game = await hltb.searchFromId(gameId);
    console.log(game);
  } catch (error) {
    console.error('Error retrieving game by ID:', error);
  }
}

getGameById(2224);

API Reference

HowLongToBeat class

The main class for interacting with the HowLongToBeat API.

Constructor

  • constructor(minSimilarity = 0.4): Creates a new instance of the HowLongToBeat class.
    • minSimilarity: Minimum similarity threshold for filtering search results (default: 0.4).

Methods

  • async search(gameName, searchModifiers = SearchModifiers.NONE, similarityMatchCase = true): Searches for games by name.

    • gameName: The name of the game to search for.
    • searchModifiers: Search modifiers for filtering results (e.g., including/excluding DLC).
    • similarityMatchCase: Whether to perform case-sensitive similarity matching.
  • async searchFromId(gameId): Retrieves game information by its HowLongToBeat ID.

    • gameId: The unique identifier of the game on HowLongToBeat.

SearchModifiers

An enumeration of search modifiers:

  • NONE: No modifiers applied.
  • ISOLATE_DLC: Show only DLC in the search results.
  • HIDE_DLC: Hide DLCs in the search results.

HowLongToBeatEntry class

Represents a single game entry returned from the API.

Properties

  • gameId: HowLongToBeat game ID.
  • gameName: Default game name.
  • gameAlias: Alternative name for the game.
  • gameType: Type of entry (e.g., "game" or "dlc").
  • gameImageUrl: URL of the game's image.
  • gameWebLink: Link to the game's HowLongToBeat page.
  • reviewScore: User review score.
  • profileDev: Developer name.
  • profilePlatforms: List of platforms the game is available on.
  • releaseWorld: Release year.
  • similarity: Similarity score between the search query and the game name.
  • mainStory: Main story completion time (in hours).
  • mainExtra: Main story + extras completion time (in hours).
  • completionist: Completionist run time (in hours).
  • allStyles: Average of all playstyles (in hours).

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is open-source and available under the MIT License.

Acknowledgements

This project is not officially affiliated with HowLongToBeat. It is a third-party API implementation for educational and personal use.