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

baidusearch-cli

v0.1.1

Published

A TypeScript library for searching Baidu (百度搜索) programmatically

Readme

baidusearch-cli

CI npm version License: MIT TypeScript

A TypeScript library for searching Baidu (百度搜索) programmatically. Inspired by library baidusearch-cli

Features

  • 🚀 Simple and easy-to-use API
  • 📦 Support both CommonJS and ES Modules
  • 🔍 Get structured search results from Baidu
  • 💪 Written in TypeScript with full type definitions
  • 🛠️ CLI tool included
  • ⚡ Built with modern tools (axios, cheerio)
  • 🔄 Automated CI/CD with GitHub Actions
  • 📝 Automatic changelog generation

Installation

npm install baidusearch-cli

Usage

As a Library

import { search } from 'baidusearch-cli';

// Basic usage
const results = await search('Node.js');
console.log(results);

// With options
const results = await search('TypeScript', {
  numResults: 20,
  debug: true,
});

results.forEach((result) => {
  console.log(`${result.rank}. ${result.title}`);
  console.log(`   ${result.abstract}`);
  console.log(`   ${result.url}\n`);
});

As a CLI Tool

# Install globally
npm install -g baidusearch-cli

# Basic search
baidusearch-cli "Node.js"

# Specify number of results
baidusearch-cli "TypeScript" 20

# Enable debug mode
baidusearch-cli "JavaScript" 10 1

Or use with npx:

npx baidusearch-cli "Node.js"

API

search(keyword: string, options?: SearchOptions): Promise<SearchResult[]>

Search Baidu with the given keyword.

Parameters

  • keyword (string): The search keyword (required)
  • options (SearchOptions): Optional configuration
    • numResults (number): Number of results to return (default: 10)
    • debug (boolean): Enable debug logging (default: false)

Returns

Promise of SearchResult[]:

interface SearchResult {
  title: string; // Result title
  abstract: string; // Result abstract/description
  url: string; // Result URL
  rank: number; // Result ranking
}

Development

# Install dependencies
npm install

# Build the project
npm run build

# Run in development mode
npm run dev

# Lint code
npm run lint
npm run lint:fix

# Format code
npm run format
npm run format:check

# Type check
npm run type-check

# Run tests
npm test

Scripts

Build

  • npm run build - Build the project
  • npm run dev - Watch mode for development
  • npm run type-check - Type check without emitting files

Code Quality

  • npm run lint - Lint TypeScript files
  • npm run lint:fix - Fix linting issues
  • npm run format - Format code with Prettier
  • npm run format:check - Check code formatting

Release

  • npm run release - Create a new release (auto-detects version bump)
  • npm run release:patch - Create a patch release (1.0.x)
  • npm run release:minor - Create a minor release (1.x.0)
  • npm run release:major - Create a major release (x.0.0)

CI/CD

This project uses GitHub Actions for continuous integration and deployment:

Workflows

  • CI (.github/workflows/ci.yml)

    • Runs on every push and pull request
    • Lints code with ESLint
    • Builds the project on Node.js 16, 18, and 20
    • Runs tests
  • Release (.github/workflows/release.yml)

    • Triggers on version tags (e.g., v1.0.0)
    • Automatically generates changelog
    • Creates GitHub release
    • Publishes to NPM
  • Publish (.github/workflows/publish.yml)

    • Manual workflow for publishing
    • Bumps version
    • Updates CHANGELOG.md
    • Publishes to NPM
    • Creates GitHub release
  • CodeQL (.github/workflows/codeql.yml)

    • Security scanning
    • Runs weekly and on pushes to main
  • Commitlint (.github/workflows/commitlint.yml)

    • Validates commit messages follow conventional commits

Publishing

Option 1: Manual Release

# Create a new release locally
npm run release:patch  # or minor/major

# Push tags
git push --follow-tags origin main

# The release workflow will automatically publish to NPM

Option 2: GitHub Actions Workflow

  1. Go to Actions tab in GitHub
  2. Select "Publish" workflow
  3. Click "Run workflow"
  4. Choose version bump type (patch/minor/major)
  5. The workflow will handle version bump, changelog, and publishing

Setup Required

To enable automated publishing, add these secrets to your GitHub repository:

  • NPM_TOKEN - Your NPM automation token (https://www.npmjs.com/settings/~/tokens)

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

Commit Message Convention

This project follows Conventional Commits:

feat: add new feature
fix: bug fix
docs: documentation changes
style: formatting, missing semi colons, etc
refactor: code refactoring
perf: performance improvements
test: add missing tests
chore: maintenance tasks

License

MIT

Credits

This TypeScript version is based on the original Python implementation.