crate-checker
A Rust crate information retrieval tool that provides both a powerful CLI and HTTP API for querying crates.io.
Features
- Crate Existence Checking - Quickly verify if a crate exists on crates.io
- Version Information - Get detailed version history and metadata
- Dependency Analysis - Explore crate dependencies and their relationships
- Download Statistics - Access download metrics and trends
- Batch Processing - Process multiple crates efficiently in parallel
- REST API Server - Run as an HTTP server for integration with other tools
- Multiple Output Formats - JSON, YAML, Table, CSV, and compact formats
Installation
From crates.io
From source
Quick Start
CLI Usage
Check if a crate exists:
Get detailed information about a crate:
Search for crates:
Check multiple crates at once:
Process a batch from a JSON file:
Start the HTTP API server:
API Usage
use ;
async
Command Reference
Global Options
-f, --format <FORMAT>- Output format: table (default), json, yaml, csv, compact--verbose- Enable verbose output-q, --quiet- Only show errors--config <FILE>- Path to configuration file--timeout <DURATION>- Request timeout (e.g., 30s, 2m, 1h)--api-url <URL>- Custom crates.io API URL
Commands
check - Check if a crate exists
check-multiple - Check multiple crates
Options:
-s, --summary-only- Show only summary--fail-on-missing- Exit with error if any crate doesn't exist
info - Get detailed crate information
Options:
-d, --deps- Include dependency information-s, --stats- Include download statistics
versions - List all versions
Options:
--no-yanked- Hide yanked versions-l, --limit <N>- Limit number of versions
search - Search for crates
Options:
-l, --limit <N>- Maximum results (default: 10)-e, --exact- Show only exact matches
deps - Show dependencies
Options:
-v, --version <VERSION>- Specific version (default: latest)--runtime-only- Show only runtime dependencies
stats - Show download statistics
Options:
-v, --versions- Show version-specific stats
batch - Process multiple crates
Options:
--json <JSON>- JSON string with batch input--file <FILE>- JSON file with batch input-p, --parallel- Process in parallel
server - Start HTTP API server
Options:
-p, --port <PORT>- Port to bind (default: 3000)--host <HOST>- Host to bind (default: 0.0.0.0)--cors- Enable CORS-c, --config <FILE>- Server configuration file
config - Generate configuration file
examples - Show batch input examples
Batch Input Formats
Crate Version Map
Crate List
Advanced Operations
HTTP API Endpoints
When running as a server, the following endpoints are available:
GET /- API documentationGET /health- Health checkGET /metrics- Server metricsGET /api/crates/{name}- Get crate informationGET /api/crates/{name}/{version}- Check specific versionGET /api/crates/{name}/{version}/deps- Get dependenciesGET /api/crates/{name}/stats- Get download statisticsGET /api/search?q={query}&limit={n}- Search cratesPOST /api/batch- Batch processing
Configuration
Configuration File
Create a crate-checker.toml file:
[]
= 8080
= "0.0.0.0"
= 4
= true
[]
= true
= 300
= 1000
[]
= "info"
= "pretty"
[]
= "https://crates.io/api/v1"
= 30
Generate a sample configuration:
Environment Variables
All configuration options can be overridden using environment variables:
Examples
Monitor Crate Updates
use ;
use HashMap;
async
Integration with CI/CD
# .github/workflows/check-deps.yml
name: Check Dependencies
on:
schedule:
- cron: '0 0 * * MON'
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: cargo install crate-checker
- run: crate-checker check-multiple $(grep -E "^\w+ = " Cargo.toml | cut -d' ' -f1)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under
- Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0)
Support
If you encounter any issues or have questions, please file an issue on GitHub.
Made with ❤️ by the Rust community