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

@brainwav/wsearch-cli

v0.1.4

Published

brAInwav wSearch CLI - Query Wikidata via REST, SPARQL, and Action API with safe, script-friendly output.

Readme

npm ci security license

brAInwav wSearch CLI helps developers query Wikidata safely and quickly

Safe, script-friendly CLI for Wikidata REST, SPARQL, and Action API queries. Read-only by default.

Last updated: 2026-01-04

Table of contents

Document requirements

  • Audience: developers and data teams using the CLI (beginner to intermediate).
  • Scope: install, configure, and run read-only Wikidata queries with the CLI.
  • Non-scope: Wikidata data modeling, write operations, or hosting a Wikibase instance.
  • Owner: repository maintainers.
  • Review cadence: every release or at least quarterly.
  • Required approvals: maintainers for public changes.

Prerequisites

  • Required: Node.js 18+, npm, internet access, and a descriptive User-Agent string for Wikimedia APIs.
  • Optional: OAuth token for higher rate limits (still read-only).

Quickstart

1) Install

npm install -g @brainwav/wsearch-cli

2) Run a query

wsearch --network --user-agent "MyApp/1.0 (https://example.org/contact)" entity get Q42

3) Verify

Expected output:

  • JSON for the entity, or a JSON envelope when using --json.
  • Exit code 0 on success.

Common tasks

Get an entity and save it to a file

  • What you get: the entity JSON for a Q/P/L id.
  • Steps:
wsearch --network --user-agent "MyApp/1.0 (https://example.org/contact)" \
  entity get Q42 --output ./Q42.json
  • Verify: ./Q42.json contains the entity data.

Run a SPARQL query from a file

  • What you get: SPARQL results in JSON/CSV/TSV.
  • Steps:
wsearch --network --user-agent "MyApp/1.0 (https://example.org/contact)" \
  sparql query --file ./query.rq --format json
  • Verify: result set printed to stdout.

Search via the Action API

  • What you get: entity search results by label.
  • Steps:
wsearch --network --user-agent "MyApp/1.0 (https://example.org/contact)" \
  action search --query "New York" --language en --limit 5
  • Verify: results include matches with ids and labels.

Use an encrypted token for requests

  • What you get: authenticated requests using Authorization: Bearer ....
  • Steps:
cat token.txt | wsearch auth login --token-stdin
wsearch --network --auth --user-agent "MyApp/1.0 (https://example.org/contact)" entity get Q42
  • Non-interactive (CI-friendly) example:
export WIKI_TOKEN="your-token"
export WIKI_PASSPHRASE="your-passphrase"
wsearch auth login
  • Custom env var names:
export MY_WIKI_TOKEN="your-token"
export MY_WIKI_PASSPHRASE="your-passphrase"
wsearch auth login --token-env MY_WIKI_TOKEN --passphrase-env MY_WIKI_PASSPHRASE
  • Verify: request succeeds; token is stored in ~/.config/wsearch-cli/credentials.json.

Set a default User-Agent

  • What you get: a persistent User-Agent without repeating flags.
  • Steps:
wsearch config set user-agent "MyApp/1.0 (https://example.org/contact)"
wsearch --network entity get Q42
  • Verify: requests succeed without --user-agent.

Preview a request without sending it

  • What you get: method, URL, and headers with tokens redacted.
  • Steps:
wsearch --print-request --user-agent "MyApp/1.0 (https://example.org/contact)" entity get Q42
  • Verify: output includes a preview and no network call is made.

Check local setup

  • What you get: a quick view of config state without making requests.
  • Steps:
wsearch doctor
  • Verify: output reports User-Agent and token presence.

Risks and assumptions

  • Network access is required for API calls; the CLI defaults to no-network and must be explicitly enabled.
  • Wikimedia APIs require a descriptive User-Agent; missing or empty values will block requests.
  • Auth tokens are stored encrypted on disk; protect the passphrase and avoid sharing logs with sensitive data.
  • Results are read-only snapshots; the CLI does not mutate Wikidata but responses can still contain sensitive data.
  • Output files are overwritten if the path already exists; choose paths carefully.

Troubleshooting

Symptom: "User-Agent is required"

Cause: Wikimedia APIs require a descriptive User-Agent. Fix:

wsearch --network --user-agent "MyApp/1.0 (https://example.org/contact)" entity get Q42

Symptom: "Network access is disabled"

Cause: the CLI defaults to no network. Fix:

wsearch --network --user-agent "MyApp/1.0 (https://example.org/contact)" entity get Q42

Symptom: 429 or rate-limit errors

Cause: API throttling. Fix: retry after a short delay or lower request frequency.

Reference

  • Docs index: docs/README.md.
  • Getting started: docs/GETTING_STARTED.md.
  • Usage reference: docs/USAGE.md.
  • Configuration: docs/CONFIG.md.
  • Troubleshooting: docs/TROUBLESHOOTING.md.
  • FAQ: docs/FAQ.md.
  • Changelog: CHANGELOG.md (Keep a Changelog).
  • License: LICENSE (MIT).
  • Brand guidelines: docs/BRAND.md.
  • Commands:
    • wsearch help [command]
    • wsearch entity get|statements <id>
    • wsearch sparql query --file <query.rq>
    • wsearch action search --query <text>
    • wsearch raw request <method> <path>
  • wsearch auth login|status|logout
  • wsearch config get|set|path
  • wsearch doctor
  • wsearch completion

brAInwav
from demo to duty