Catalog / HTTPie Command-Line HTTP Client Cheatsheet
HTTPie Command-Line HTTP Client Cheatsheet
A comprehensive guide to using HTTPie, a command-line HTTP client, for making API requests, testing endpoints, and inspecting HTTP traffic with examples and usage scenarios.
Basic Usage and Parameters
Making Basic Requests
Example: |
Specifying HTTP Method: Examples: |
Including Headers: Example: |
Passing Request Data
|
String parameters in the request body or query string. Example: |
|
URL parameters. Example: |
|
Non-string parameters. Useful for JSON payloads. Example: |
|
JSON Data. Sends a JSON array. Example: |
|
Attach files. Example: |
|
Read field value from a file (text). Example: |
|
Read field value from a file (JSON). Example: |
Working with Forms and Raw JSON
Submitting Forms
Example: |
Ensure correct Content-Type: Example: |
Sending Raw JSON Data
Piping Raw JSON: Example: |
Specifying Content-Type for JSON: Example: |
Handling Different Content Types
HTTPie supports various content types, and you can specify them using the Example: |
Options for Output and Authentication
Printing Options
|
Verbose mode, same as Example: |
|
Print only headers, same as Example: |
|
Print only body, same as Example: |
|
Print intermediate requests. Example: |
|
Specify which parts of the request/response to print. Example: |
|
Style for output formatting (none, all, colors, format). Example: |
|
Response is serialized as a JSON object. Example: |
Authentication Options
|
Provide HTTP Basic authentication credentials. Example: |
|
Specify the authentication type (basic, digest). Example: |
Session Management and Downloading
Session Handling
|
Create or use a session to store authentication and cookies. Example: |
|
Use a read-only session. Example: |
Session Use Cases |
Sessions are useful for maintaining authentication and cookies across multiple requests. They help simulate a user’s interaction with a website. Example: |
Downloading Content
|
Download the response body like wget. Example: |
|
Continue an interrupted download. Example: |
|
Specify the output file for the downloaded content. Example: |
Advanced Options
Redirection and Timeouts
|
Follow HTTP redirects. Example: |
|
Set the maximum number of redirects to follow. Example: |
|
Set a timeout for the request. Example: |
SSL Verification and Proxies
|
Skip SSL verification. Example: |
|
Specify a proxy to use for the request. Example: |
Request Headers Examples
|
Sets the media type of the body of the request. Example: |
|
Provides credentials to authenticate with a server. Example: |
|
Identifies the client making the request. Example: |