http [METHOD] URL [item [item]]
- Basic syntax for making HTTP requests.
Example:
http GET example.com
- Sends a GET request to example.com
http POST example.com
- Sends a POST request.
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.
Example: |
Specifying HTTP Method: Examples: |
Including Headers: Example: |
|
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: |
Example: |
Ensure correct Content-Type: Example: |
Piping Raw JSON: Example: |
Specifying Content-Type for JSON: Example: |
HTTPie supports various content types, and you can specify them using the Example: |
|
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: |
|
Provide HTTP Basic authentication credentials. Example: |
|
Specify the authentication type (basic, digest). Example: |
|
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: |
|
Download the response body like wget. Example: |
|
Continue an interrupted download. Example: |
|
Specify the output file for the downloaded content. Example: |
|
Follow HTTP redirects. Example: |
|
Set the maximum number of redirects to follow. Example: |
|
Set a timeout for the request. Example: |
|
Skip SSL verification. Example: |
|
Specify a proxy to use for the request. Example: |
|
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: |