| title | CLI Mode | |
|---|---|---|
| tags |
|
Execute requests from the command line.
restcli <file>Or explicit:
restcli run <file>File extension is optional:
restcli get-userFinds get-user.http, get-user.yaml, get-user.json, or get-user.jsonc.
restcli -p Dev request.httpShort: -p
Long: --profile
restcli -o json request.httpOptions: json, yaml, text
Short: -o
Long: --output
restcli -f request.httpIncludes status line, headers, and body.
Short: -f
Long: --full
restcli -s response.json request.httpShort: -s
Long: --save
restcli -b '{"key":"value"}' request.httpShort: -b
Long: --body
restcli -e userId=123 -e token=abc request.httpRepeatable flag for multiple variables.
Short: -e
Long: --extra-vars
restcli --env-file .env request.httpLoad variables from file.
restcli --filter "items[?status==\`active\`]" request.httpJMESPath filter expression.
restcli -q "[].name" request.httpJMESPath query or bash command.
Short: -q
Long: --query
Pipe data directly:
cat payload.json | restcli request.httpOr:
echo '{"data":"value"}' | restcli post-data.httpStdin overrides body in request file.
restcli run api.http \
-p Production \
-o json \
-e apiKey=secret123 \
-e version=v2 \
--filter "results[?active]" \
-s output.json| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Request failed or error |
| 2 | Missing variables |
restcli health.http -o json | jq '.status == "ok"'TOKEN=$(restcli login.http -o json | jq -r '.token')
restcli -e token=$TOKEN get-data.httpfor id in {1..10}; do
restcli get-user.http -e userId=$id -o json >> results.jsonl
doneif restcli health.http -q '.status' | grep -q 'ok'; then
restcli deploy.http
fiIf variables are missing and not provided via flags, CLI prompts for input:
restcli get-user.http
# Prompts: Enter value for userId:Disable prompts in scripts by setting all variables via flags or profiles.
Basic request:
restcli get-user.httpWith profile and variables:
restcli -p Dev -e userId=5 get-user.httpJSON output saved to file:
restcli api.http -o json -s result.jsonFilter and query:
restcli users.http \
--filter "users[?age > \`18\`]" \
--query "[].{name: name, email: email}"Pipe stdin body:
cat new-user.json | restcli create-user.http -o jsonFull output with headers:
restcli -f auth.httpRequests with @confirmation directive require confirmation in CLI mode:
### Delete User
# @confirmation
DELETE https://api.example.com/users/{{userId}}When executed in CLI:
restcli delete-user.http -p prod
# Prompts: Request 'Delete User' requires confirmation.
# Method: DELETE
# URL: https://api.example.com/users/123
#
# Proceed? [y/N]:Prevents accidental execution of critical endpoints.
Generate completions for your shell:
# Generate completion script
restcli completion bash > /etc/bash_completion.d/restcli
# Or add to ~/.bashrc
source <(restcli completion bash)# Create completions directory
mkdir -p ~/.zsh/completions
# Add to ~/.zshrc (if not already present)
if type restcli &>/dev/null; then
echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
fi
# Generate completions
restcli completion zsh > ~/.zsh/completions/_restcli
# Reload shell
source ~/.zshrcCompletion provides:
- Profile names for
--profileflag (from.profiles.json) - Request files for file argument (from profile's workdir or current directory)
- Flag names and options
Example:
restcli run <TAB> # Shows .http files
restcli -p <TAB> # Shows profile names
restcli run api -p <TAB> # Shows profilesNote: File completion is profile-aware. With --profile dev, it scans the dev profile's workdir for valid files.