@unireq/cli
v0.0.2
Published
HTTP CLI client with REPL mode for API exploration and testing
Maintainers
Readme
@unireq/cli
HTTP CLI client with REPL mode for API exploration and testing. Like curl meets kubectl with OpenAPI awareness.
Installation
pnpm add -g @unireq/cli
# or
npm install -g @unireq/cliQuick Start
One-Shot Mode
Execute HTTP requests directly from the command line:
# Simple GET request
unireq get https://api.example.com/users
# POST with JSON body
unireq post https://api.example.com/users -d '{"name":"Alice","email":"[email protected]"}'
# With headers and query parameters
unireq get https://api.example.com/users -H "Authorization: Bearer token" -q "page=1" -q "limit=10"
# Trace mode (timing details)
unireq get https://api.example.com/users --trace
# Export as curl command
unireq get https://api.example.com/users --export curlREPL Mode
Launch interactive mode for API exploration:
unireqNavigate and explore APIs like a filesystem:
unireq> cd /users
/users> ls
GET /users List all users
POST /users Create a new user
GET /users/{id} Get user by ID
/users> get
[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]
/users> post -d '{"name":"Charlie"}'
{"id":3,"name":"Charlie"}
/users> cd ..
/> exitFeatures
| Feature | Description | |---------|-------------| | One-shot mode | Execute single requests like curl/httpie | | REPL mode | Interactive API exploration with navigation | | OpenAPI integration | Load specs for autocompletion and validation | | Workspaces | Project-based configuration with profiles | | Authentication | API key, Bearer, JWT login, OAuth2 client credentials | | Collections | Save and replay requests with assertions | | Secrets vault | Secure credential storage with OS keychain support | | Output formats | Pretty, JSON, raw, with syntax highlighting | | Export | Generate curl/httpie equivalent commands |
Commands
HTTP Methods
All standard HTTP methods are supported:
unireq get <url>
unireq post <url> [-d <body>]
unireq put <url> [-d <body>]
unireq patch <url> [-d <body>]
unireq delete <url>
unireq head <url>
unireq options <url>Request Options
| Option | Description |
|--------|-------------|
| -H, --header <header> | Add header (repeatable): -H "Content-Type: application/json" |
| -q, --query <param> | Add query parameter (repeatable): -q "page=1" |
| -d, --data <body> | Request body (JSON auto-detected) |
| -o, --output <format> | Output format: pretty, json, raw |
| --trace | Show timing details (TTFB, download, total) |
| --export <format> | Export as: curl, httpie |
Workspace Commands
# Initialize a workspace in current directory
unireq workspace init
# List all workspaces
unireq workspace list
# Add a workspace to registry
unireq workspace add my-api /path/to/project
# Switch active workspace
unireq workspace use my-api
# Remove workspace from registry
unireq workspace remove my-api
# Validate workspace configuration
unireq workspace doctorProfile Commands (REPL)
profile list # List available profiles
profile use <name> # Switch to profile
profile show # Show current profile detailsAuth Commands (REPL)
auth login # Authenticate with configured provider
auth status # Show current auth state
auth logout # Clear authenticationCollection Commands (REPL)
save <name> # Save last request to collection
run <name> # Execute saved request
history # Show request historySecret Commands (REPL)
secret set <name> # Store a secret
secret get <name> # Retrieve a secret
secret list # List secret names
secret delete <name> # Remove a secretWorkspace Configuration
Create a .unireq/workspace.yaml in your project:
version: 1
name: my-api
baseUrl: https://api.example.com
# Variables for interpolation
vars:
apiVersion: v1
# Environment profiles
profiles:
dev:
baseUrl: http://localhost:3000
vars:
debug: true
prod:
baseUrl: https://api.example.com
vars:
debug: false
activeProfile: dev
# OpenAPI spec for navigation and validation
openapi:
source: ./openapi.yaml
# Authentication configuration
auth:
default: bearer
providers:
bearer:
type: bearer
token: ${secret:api_token}
# Secrets backend
secrets:
backend: auto # auto | keychain | vaultVariable Interpolation
Use variables in your configuration:
baseUrl: https://${var:host}:${env:PORT}
headers:
Authorization: Bearer ${secret:api_token}
X-Request-ID: ${prompt:request_id}| Syntax | Source |
|--------|--------|
| ${var:name} | Workspace variables |
| ${env:NAME} | Environment variables |
| ${secret:name} | Secure vault storage |
| ${prompt:name} | Interactive prompt |
Output Formats
Pretty (default)
Syntax-highlighted JSON/XML with colored status codes:
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": 1,
"name": "Alice"
}JSON
Raw JSON output for piping:
unireq get /users -o json | jq '.[] | .name'Trace
Detailed timing information:
TTFB: 45ms ████████░░░░░░░░
Download: 12ms ███░░░░░░░░░░░░░
Total: 57msDependencies
@unireq/http- HTTP client core@unireq/core- Request composition@unireq/config- Configuration management
Documentation
Full documentation available at unireq.dev
License
MIT
