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

wikipedia-title-index

v1.2.6

Published

Local Wikipedia title index build and constrained query service.

Readme

wikipedia-title-index

Local Wikipedia title index builder and constrained query service.

Requirements

  • Node.js >= 24.10.0
  • CommonJS runtime

What it provides

  • Streaming index build from file or URL
  • Local SQLite index (titles(t TEXT PRIMARY KEY))
  • Local REST query service with SQLite authorizer policy
  • CLI for build/serve/title lookup/cache/status/clean

Install

npm i wikipedia-title-index

CLI

npx wikipedia-title-index build [--file <path> | --url <url>]
npx wikipedia-title-index serve
npx wikipedia-title-index query "<title-or-prefix>" [limit]
npx wikipedia-title-index cache clear
npx wikipedia-title-index status
npx wikipedia-title-index clean

Installed-package usage:

  • Use npx wikipedia-title-index ... after npm i wikipedia-title-index.
  • Plain wikipedia-title-index ... works only when installed globally (or when your shell PATH includes local npm bins).

Query modes (important)

wikipedia-title-index has two query surfaces with different capabilities:

| Surface | How to use | Supports raw SQL? | Purpose | |---|---|---:|---| | CLI | npx wikipedia-title-index query "<title-or-prefix>" [limit] | No | Exact + prefix title lookup only | | REST API | POST /v1/titles/query with JSON { sql, params, max_rows } | Yes | Policy-constrained SQL SELECT queries |

Notes:

  • The CLI query command does not accept SQL text.
  • SQL policy enforcement (SQLite authorizer) applies to the REST SQL endpoint.

CLI title lookup example

npx wikipedia-title-index query "Albert" 5

REST SQL example

Start service:

npx wikipedia-title-index serve

Run SQL query:

curl -sS -X POST http://127.0.0.1:32123/v1/titles/query \
  -H "content-type: application/json" \
  -d "{\"sql\":\"SELECT t FROM titles WHERE t >= ?1 AND t < ?2 ORDER BY t\",\"params\":[\"Albert\",\"Albert\uffff\"],\"max_rows\":5}"

Environment variables

  • WIKIPEDIA_INDEX_DATA_DIR (default: data)
  • WIKIPEDIA_INDEX_DB_PATH (override full DB path)
  • WIKIPEDIA_INDEX_SOURCE_URL (default: https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-all-titles-in-ns0.gz)
  • WIKIPEDIA_INDEX_AUTOSETUP (0 disables auto-setup)
  • SECS_WIKI_INDEX_PORT (default: 32123)
  • WIKIPEDIA_INDEX_CACHE_ENABLED (0 disables cache, default: 1)
  • WIKIPEDIA_INDEX_CACHE_TTL_SECONDS (default: 86400, 0 disables TTL pruning)
  • WIKIPEDIA_INDEX_CACHE_MAX_ENTRIES (default: 10000, 0 disables size pruning)

Query cache:

  • Successful /v1/titles/query responses and CLI query results are cached in data/cache/ by request shape.
  • Cache keys include DB fingerprint (path + size + mtime) to avoid stale reuse after rebuilds.

REST service

Start:

npx wikipedia-title-index serve

Endpoints:

  • GET /health
  • POST /v1/titles/query

POST /v1/titles/query request body:

  • sql (required): SQL SELECT statement
  • params (optional): SQL parameters
  • max_rows (optional): response row cap (bounded by server limits)

OpenAPI contract: openapi/openapi.yaml

Docs

  • Operations: docs/OPS.md
  • Package contract: docs/NPM.md
  • Agent behavior contract: docs/AGENT.md

Data and licensing

Wikipedia title data is subject to Creative Commons Attribution-ShareAlike (CC BY-SA). This package does not alter, reinterpret, or relicense the underlying data.

Notes

  • data/ artifacts are local runtime/build output and are not part of npm publish.
  • SQL access is constrained to read-only SELECT on main.titles.t.
  • Lock behavior (v1.0.1+): lock files are validated by recorded PID liveness. Stale locks are auto-removed; live locks block concurrent start.