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

batteryincluded

v1.0.2

Published

A TypeScript client for the BatteryIncluded API

Readme

🔋 BatteryIncluded TypeScript SDK

Github Actions NPM version NPM last update License

An unofficial TypeScript SDK for BatteryIncluded, the AI-infrastructure for E-Commerce search. Provides type-safe access to the BatteryIncluded API for search, filters, recommendations and more.

Installation

npm install batteryincluded

Usage

  1. Create a .env file in the root of your project with the following content:
BATTERYINCLUDED_COLLECTION=your-collection-name
BATTERYINCLUDED_API_KEY=your-api-key
  1. Run the CLI to generate types based on your collection schema:
npx batteryincluded ./path/to/output/dir
  1. Use the client with full type safety:
import { createClient } from 'batteryincluded'

const client = createClient({
  collection: 'your-collection-name',
  apiKey: 'your-api-key',
})

const { data, error } = await client.GET('/browse', {
  params: {
    query: {
      page: 1,
      per_page: 20,
    }
  }
})

// Fully typed response data
console.log(data)

Make sure the output directory is included in your TypeScript project's tsconfig.json under the include array to ensure the generated types are available for import.

Available Endpoints

The SDK provides type-safe access to the following BatteryIncluded API endpoints:

  • /browse: Search endpoint for retrieving documents.
  • /highlights: Endpoint for retrieving query highlights.
  • /suggest: Endpoint for getting search suggestions based on a text query.
  • /recommendations: Endpoint for getting product recommendations based on a document ID.
  • /recommendations/cart: Endpoint for getting product recommendations based on a cart ID.
  • /similar-search: Endpoint for finding similar products based on a text query.
  • /presets: Endpoint for retrieving available search presets.

Type Generation

The SDK includes a CLI tool that generates TypeScript types based on the responses from your BatteryIncluded collection. This is a workaround to provide type safety for the API responses, as BatteryIncluded does not currently provide an OpenAPI schema.

In order to generate the types for these endpoints, the CLI will attempt to discover the schema by making requests to the API. For the /recommendations endpoint, it requires a document ID to generate recommendations. If no document ID is provided via the --recommendation-id flag, the CLI will automatically fetch the first document from the /browse endpoint to use its ID for generating recommendation types.

The query used for the /suggest and /similar-search endpoints can be customized using the --suggest-query flag, which defaults to 'a' to ensure it returns results for discovery.

Custom Probe Config

The CLI also supports loading custom probe configurations from a batteryincluded.config.{js,json,mjs} file in your project. This allows you to specify additional endpoints or customize the discovery process. If no custom config is provided, the CLI will use a default configuration that includes the necessary endpoints for generating types for search, suggestions, and recommendations.

// batteryincluded.config.mjs
import { defineCodegenConfig } from 'batteryincluded'

export default defineCodegenConfig({
  '/browse': {
    query: {
      page: 1,
      // Load more documents for better schema discovery
      per_page: 100,
    },
  },
  '/suggest': {
    query: {
      q: 'custom search term'
    }
  }
})

For more information on the code generator and how to customize the probe configuration, see the AutoDisco documentation.

License

Published under the MIT License.