# HTTPie — Modern HTTP Client for the Command Line

> Practical guide to HTTPie — HTTP requests, JSON data, sessions and authentication on the command line, with intuitive syntax and examples for every use case.

Source: https://www.jpkc.com/db/en/cheatsheets/networking/httpie/

<!-- PROSE:intro -->
HTTPie is the modern, developer-friendly alternative to curl: instead of cryptic flags, you write HTTP requests in an intuitive syntax that reads almost like natural language. JSON data travels as simple `key=value` pairs without extra headers, output is automatically colourised and pretty-printed, and sessions persist cookies and auth across requests. Whether you need a quick API test, Bearer token authentication, or repeatable debug steps – HTTPie makes HTTP noticeably more approachable.
<!-- PROSE:intro:end -->

## Basic Requests

`http <url>` — Send a GET request (default method).

```bash
http https://api.example.com/users
```

`http POST <url>` — Send a POST request.

```bash
http POST https://api.example.com/users
```

`http PUT <url>` — Send a PUT request.

```bash
http PUT https://api.example.com/users/1
```

`http DELETE <url>` — Send a DELETE request.

```bash
http DELETE https://api.example.com/users/1
```

`http PATCH <url>` — Send a PATCH request.

```bash
http PATCH https://api.example.com/users/1
```

`http HEAD <url>` — Send a HEAD request (headers only).

```bash
http HEAD https://example.com
```

## Data & JSON

`http POST <url> <key>=<value>` — Send JSON data (string values).

```bash
http POST https://api.example.com/users name=John email=john@example.com
```

`http POST <url> <key>:=<value>` — Send raw JSON values (numbers, booleans, arrays).

```bash
http POST https://api.example.com/users name=John age:=30 active:=true
```

`http POST <url> < <file>` — Send request body from a file.

```bash
http POST https://api.example.com/users < data.json
```

`http --json POST <url> <key>=<value>` — Explicitly send as JSON (default for data).

```bash
http --json POST https://api.example.com/users name=John
```

`http --form POST <url> <key>=<value>` — Send as form data (application/x-www-form-urlencoded).

```bash
http --form POST https://example.com/login user=admin password=secret
```

`http --multipart POST <url> file@<path>` — Upload a file (multipart form data).

```bash
http --multipart POST https://api.example.com/upload file@photo.jpg
```

## Headers & Auth

`http <url> <Header>:<value>` — Set a custom header.

```bash
http https://api.example.com/data Accept:application/xml X-API-Key:abc123
```

`http -a <user>:<pass> <url>` — HTTP Basic Authentication.

```bash
http -a admin:secret https://api.example.com/admin
```

`http -A bearer -a <token> <url>` — Bearer token authentication.

```bash
http -A bearer -a eyJhbG... https://api.example.com/me
```

`http <url> Authorization:'Bearer <token>'` — Set Authorization header manually.

```bash
http https://api.example.com/me Authorization:'Bearer eyJhbG...'
```

## Output Control

`http -v <url>` — Verbose: show request headers, body, response headers, and body.

```bash
http -v https://api.example.com/users
```

`http -h <url>` — Show response headers only.

```bash
http -h https://example.com
```

`http -b <url>` — Show response body only.

```bash
http -b https://api.example.com/users
```

`http -p HBhb <url>` — Select output parts: H=request headers, B=request body, h=response headers, b=response body.

```bash
http -p Hh https://api.example.com/users
```

`http -d <url>` — Download mode: save response body to file.

```bash
http -d https://example.com/file.zip
```

`http -o <file> <url>` — Save response body to a specific file.

```bash
http -o data.json https://api.example.com/export
```

## Sessions & Config

`http --session=<name> <url>` — Use a named session (persists cookies, auth, headers).

```bash
http --session=mysession -a admin:secret https://api.example.com/login
```

`http --session=<name> <url>` — Reuse a session (cookies/auth from previous request).

```bash
http --session=mysession https://api.example.com/dashboard
```

`http --follow <url>` — Follow redirects (not followed by default).

```bash
http --follow https://example.com/old-page
```

`http --verify=no <url>` — Skip SSL certificate verification.

```bash
http --verify=no https://self-signed.example.com
```

`http --timeout=<seconds> <url>` — Set request timeout.

```bash
http --timeout=30 https://slow-api.example.com
```

## Common Patterns

`http --pretty=all <url>` — Force colorized and formatted output.

```bash
http --pretty=all https://api.example.com/users
```

`http --print=b <url> | jq '<filter>'` — Pipe JSON response to jq for processing.

```bash
http --print=b https://api.example.com/users | jq '.[].name'
```

`http --offline POST <url> <data>` — Build and print request without sending (for debugging).

```bash
http --offline POST https://api.example.com/users name=John
```

`https <url>` — Shorthand for http with HTTPS scheme.

```bash
https api.example.com/users
```

<!-- PROSE:outro -->
## Conclusion

HTTPie shines wherever you want readable, expressive HTTP requests – especially during API debugging and development workflows. For scripting or environments where curl is already available, curl remains the safe default. Both tools complement each other, and knowing both means you have the right instrument for every situation.

## Further Reading

- [HTTPie – official documentation](https://httpie.io/docs/) – reference and manual
- [HTTPie – GitHub](https://github.com/httpie/cli) – source code and releases
<!-- PROSE:outro:end -->

## Related Commands

- [curl](https://www.jpkc.com/db/en/cheatsheets/networking/curl/) – HTTP requests on the command line, available on virtually every system
- [wget](https://www.jpkc.com/db/en/cheatsheets/networking/wget/) – download files and entire sites
- [ab](https://www.jpkc.com/db/en/cheatsheets/networking/ab/) – benchmark an HTTP server with concurrent requests (Apache Benchmark)

