carapace-sh/carapace-bin / skills/httpie
httpie
UnverifiedUse when working with HTTPie (http/https CLI) — the command-line HTTP client for the API era. Covers request items syntax (headers, params, data fields, file uploads), authentication (basic, digest, bearer, plugins), session management, output formatting and printing, SSL/TLS configuration, download mode, configuration files, environment variables, plugin system, exit codes, scripting, and URL syntax. Triggers on: "httpie", "http command", "https command", "http --json", "http --form", "http --download", "http --session", "http --auth", "http --auth-type", "http --print", "http --verbose", "http --follow", "http --offline", "http --check-status", "http --proxy", "http --ssl", "http --cert", "http --verify", "http --format-options", "http --pretty", "http --style", "http --stream", "http --boundary", "http --multipart", "http --raw", "httpie config", "HTTPIE_CONFIG_DIR", "httpie cli plugins", "request items", "data fields", "URL parameters", "HTTP headers", "raw JSON fields", "file upload fields", "named session", "anonymous session", "read-only session", "Content-Disposition", "httpie-unixsocket", "httpie plugins", "AuthPlugin", "TransportPlugin", "ConverterPlugin", "FormatterPlugin".
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.2 KB |
| references/auth.md | markdown | 3.3 KB |
| references/cli.md | markdown | 6.6 KB |
| references/config.md | markdown | 4.0 KB |
| references/downloads.md | markdown | 3.7 KB |
| references/output.md | markdown | 6.1 KB |
| references/plugins.md | markdown | 5.6 KB |
| references/request-items.md | markdown | 4.9 KB |
| references/scripting.md | markdown | 3.7 KB |
| references/sessions.md | markdown | 5.0 KB |
| references/ssl.md | markdown | 2.8 KB |
| references/url-syntax.md | markdown | 3.5 KB |
references/scripting.md
View on GitHub# Scripting and Exit Codes
Using HTTPie in shell scripts, automation, and pipelines — exit codes, `--check-status`, stdin handling, and best practices.
## Exit Codes
Without `--check-status`, HTTPie exits with `0` unless a network or fatal error occurs. With `--check-status`, HTTP status codes map to exit codes:
| Exit Code | Meaning |
|-----------|---------|
| `0` | Success (no errors, no bad status codes) |
| `1` | General error (e.g., download body not fully downloaded) |
| `2` | Request timed out |
| `3` | HTTP 3xx Redirection (when `--follow` is not set) |
| `4` | HTTP 4xx Client Error |
| `5` | HTTP 5xx Server Error |
| `6` | Exceeded `--max-redirects=N` redirects |
## Shell Script Example
```bash
#!/bin/bash
if http --check-status --ignore-stdin --timeout=2.5 HEAD pie.dev/get &> /dev/null; then
echo 'OK!'
else
case $? in
2) echo 'Request timed out!' ;;
3) echo 'Unexpected HTTP 3xx Redirection!' ;;
4) echo 'HTTP 4xx Client Error!' ;;
5) echo 'HTTP 5xx Server Error!' ;;
6) echo 'Exceeded --max-redirects=<n> redirects!' ;;
*) echo 'Other Error!' ;;
esac
fi
```
## Best Practices for Automation
### Use `--ignore-stdin`
In non-interactive contexts (cron jobs, scripts), stdin is not connected to a terminal. HTTPie assumes piped input contains a request body and will **hang** waiting for data. Always use `--ignore-stdin` in scripts, unless you are intentionally piping data:
```bash
# Correct — prevents hanging
$ http --ignore-stdin pie.dev/get
# Correct — piping data intentionally
$ echo '{"name": "John"}' | http pie.dev/post
```
### Use `--timeout`
Prevent unresponsive scripts by setting a connection timeout:
```bash
$ http --timeout=2.5 pie.dev/get
```
### Recommended Flags for Scripts
```bash
http --check-status --ignore-stdin --timeout=<seconds> <METHOD> <URL>
```
### Suppress All Output
Use `-qq` (quiet twice) with `--check-status` for completely silent operation:
```bash
$ http -qq --check-status pie.dev/post enjoy='the silence'
```
## Piping Data Into HTTPie
### From a File
```bash
$ http PUT pie.dev/put X-API-Token:123 < files/data.json
```
### From Another Command
```bash
$ grep '401 Unauthorized' /var/log/httpd/error_log | http POST pie.dev/post
```
### Bash Here String
```bash
$ http pie.dev/post <<<'{"name": "John"}'
```
### Chaining HTTP Requests
```bash
$ http GET https://api.github.com/repos/httpie/cli | http POST pie.dev/post
```
### Interactive Paste
```bash
$ cat | http POST pie.dev/post
<paste data>
^D
```
Data from stdin **cannot** be combined with data fields specified on the command line.
## `--raw` Flag
Pass raw request data without processing:
```bash
$ http --raw='{"name": "John"}' pie.dev/post
```
## Redirected Output Defaults
When output is piped or redirected, HTTPie changes defaults for convenience:
| Aspect | Terminal | Redirected |
|--------|----------|-----------|
| Formatting | Enabled (`--pretty=all`) | Disabled (`--pretty=none`) |
| Colors | Enabled | Disabled |
| Default content | Headers + body | Body only |
| Binary data | Suppressed | Not suppressed |
Override with `--pretty`:
```bash
$ http --pretty=all pie.dev/get | less -R
```
## Download Mode and Exit Codes
`--download` implies `--check-status` and `--follow`. If the body is not fully downloaded, HTTPie exits with code `1`. See [downloads.md](downloads.md).
## References
- Source of truth: <https://httpie.io/docs/cli/scripting>
- Carapace completer: `completers/common/http_completer/cmd/root.go`
## Related Skills
- [cli.md](cli.md) — full flag reference
- [downloads.md](downloads.md) — download mode and `--check-status`
- [output.md](output.md) — redirected output behavior
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |