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

pypkg-cli

v1.1.1

Published

Command-line interface for PyPI - The Python Package Index

Readme

PyPI CLI

npm version License: MIT

A powerful command-line interface for PyPI - The Python Package Index. Search packages, view statistics, check security vulnerabilities, publish packages, and manage API tokens directly from your terminal.

Features

  • Package Discovery - Search and explore packages with filters
  • Package Information - Detailed metadata, versions, releases, and dependencies
  • Statistics & Analytics - Download trends, charts, and trending packages
  • Publishing - Validate and upload packages to PyPI or TestPyPI
  • Security Scanning - Vulnerability auditing via OSV API
  • Token Management - Create, list, and revoke API tokens
  • Multiple Output Formats - JSON, table, or pretty-printed output
  • Consistent JSON Envelope - All --json output uses a standard { package, data } envelope
  • Scriptable - Perfect for CI/CD pipelines and automation

Installation

# Using npm
npm install -g pypkg-cli

# Using bun
bun install -g pypkg-cli

Quick Start

1. Configure your API token (optional, for publishing)

# Interactive setup
pypi config init

# Or set directly
pypi config set apiToken pypi-xxxxxxxxxxxxx

# Or use environment variable
export PYPI_API_TOKEN=pypi-xxxxxxxxxxxxx

2. Search for packages

pypi search django --limit 10

3. Get package information

pypi info requests

Commands

Configuration

pypi config init              # Interactive configuration setup
pypi config get               # Show current configuration
pypi config set <key> <value> # Set a configuration value

Package Discovery

# Search for packages
pypi search django
pypi search "web framework" --limit 20

# Get package information
pypi info requests
pypi info flask --version 2.3.0

# List all versions
pypi versions numpy
pypi versions pandas --include-yanked

# Show release history
pypi releases django --limit 10

# View dependencies
pypi deps requests
pypi deps flask --extras async

Statistics

# Get download statistics
pypi stats requests
pypi stats numpy --period month

# Detailed download breakdown
pypi downloads pandas
pypi downloads flask --by-python-version

# Discover trending packages
pypi trending
pypi trending --category web --limit 20

Publishing

# Validate distribution files
pypi check
pypi check dist/mypackage-1.0.0.tar.gz
pypi check --json

# Upload a single file
pypi upload dist/mypackage-1.0.0.tar.gz

# Publish all files in dist/
pypi publish
pypi publish --repository testpypi

# Dry run (validate only)
pypi publish --dry-run

Token Management

# Create a new API token
pypi token create --name "CI/CD Token" --scope project:mypackage

# List all tokens
pypi token list
pypi token list --json

# Revoke a token
pypi token revoke <token-id>

Security

# Audit package for vulnerabilities
pypi audit requests
pypi audit flask --version 2.3.0

# Verify package integrity
pypi verify requests
pypi verify numpy --version 1.24.0
pypi verify requests --json

Global Options

All commands support these global options:

| Option | Description | |--------|-------------| | --api-token <token> | Use a specific API token (overrides config) | | --output <format> | Output format: json, table, or pretty (default: pretty) | | --verbose | Enable verbose logging | | --no-color | Disable colored output | | -h, --help | Display help for command |

Configuration

The CLI stores configuration in ~/.pypi/config.json. Configuration priority:

  1. Command-line flags (--api-token)
  2. Environment variables (PYPI_API_TOKEN)
  3. Configuration file

Environment Variables

| Variable | Description | |----------|-------------| | PYPI_API_TOKEN | Your PyPI API token | | PYPI_REPOSITORY | Repository URL (default: https://upload.pypi.org/legacy/) | | PYPI_OUTPUT_FORMAT | Output format (json, table, pretty) |

Configuration File

{
  "apiToken": "pypi-xxxxxxxxxxxxx",
  "repository": "https://upload.pypi.org/legacy/",
  "outputFormat": "pretty",
  "colorOutput": true
}

Examples

Search and filter packages

# Search for packages
pypi search "machine learning" --limit 20

# Get detailed package info
pypi info tensorflow --stats

View download statistics

# Get download stats with ASCII chart
pypi stats pandas --period week

# Compare download trends
pypi downloads numpy --by-python-version

Security audit before installing

# Check for known vulnerabilities
pypi audit django

# Verify package integrity
pypi verify requests --version 2.28.0

Publish a package

# Build your package
python -m build

# Validate before upload
pypi check

# Upload to TestPyPI first
pypi publish --repository testpypi

# Then publish to PyPI
pypi publish

CI/CD Integration

# Use environment variable for token
PYPI_API_TOKEN=$PYPI_TOKEN pypi publish --output json

# Check for vulnerabilities in CI (JSON envelope: { package, data })
pypi audit mypackage --json | jq '.data | length'

# Validate distributions in CI
pypi publish check --json | jq '.data.summary.all_valid'

API Token

To use authenticated PyPI features, you'll need an API token:

  1. Visit https://pypi.org/manage/account/token/
  2. Create a new API token
  3. Configure it using:
    • pypi config init (interactive)
    • pypi config set apiToken <token> (direct)
    • Set PYPI_API_TOKEN environment variable

The token will be stored securely in ~/.pypi/config.json with appropriate file permissions.

Development

Prerequisites

  • Bun >= 1.0.0
  • Node.js >= 18.0.0 (for runtime)
  • TypeScript >= 5.0.0

Scripts

bun run build     # Build the CLI for production
bun run dev       # Run in development mode
bun run test      # Run tests
bun run typecheck # Type check without building
bun run clean     # Remove build artifacts

Project Structure

pypi-cli/
├── src/
│   ├── commands/
│   │   ├── config/     # Configuration commands
│   │   ├── search/     # Package search
│   │   ├── info/       # Package info, versions, releases, deps
│   │   ├── publish/    # check, upload, publish
│   │   ├── stats/      # stats, downloads, trending
│   │   ├── token/      # create, list, revoke
│   │   └── security/   # audit, verify
│   ├── lib/
│   │   ├── api-client.ts  # PyPI API client
│   │   ├── config.ts      # Configuration management
│   │   ├── upload.ts      # Upload utilities
│   │   ├── cache.ts       # Statistics caching
│   │   ├── chart.ts       # ASCII chart rendering
│   │   ├── validators.ts  # PEP 440/508 validation
│   │   └── output.ts      # Output formatting
│   ├── types/
│   │   ├── api.ts      # PyPI API types
│   │   └── config.ts   # Config types
│   └── index.ts        # CLI entry point
├── tests/
│   └── unit/           # Unit tests
├── docs/
│   └── publishing.md   # Publishing guide
└── package.json

License

MIT

Contributing

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

Links