LinuxCommandLibrary

curlie

Send HTTP requests from the command line

TLDR

Send a GET request

$ curlie [httpbin.org/get]
copy

Send a POST request
$ curlie post [httpbin.org/post] [name=john] [age:=25]
copy

Send a GET request with query parameters (e.g. first_param=5&second_param=true)
$ curlie get [httpbin.org/get] [first_param==5] [second_param==true]
copy

Send a GET request with a custom header
$ curlie get [httpbin.org/get] [header-name:header-value]
copy

SYNOPSIS

curlie [OPTIONS] URL [REQUEST_ITEMS...]

curlie's syntax is highly flexible:
* URL: The target URL for the HTTP request.
* OPTIONS: Various command-line flags to control behavior (e.g., headers, authentication, timeouts).
* REQUEST_ITEMS: Key-value pairs or file uploads for the request body or headers:
    - key=value: Data field (inferred as form data or JSON).
    - key:=value: Raw JSON field (e.g., 'user:="admin"').
    - key==value: URL-encoded form data field (e.g., 'user==admin').
    - key@file: File upload (e.g., 'image@picture.png').
    - key:=@file: Raw JSON data from file (e.g., 'data:=@payload.json').
    - -X METHOD or METHOD before URL: Specify HTTP method (e.g., POST).
    - Header:Value: Custom HTTP header (e.g., 'Accept:application/json').

PARAMETERS

--help
    Displays the help message and exits.

--version
    Prints the curlie version information and exits.

--json, -j
    Forces the request body to be treated and sent as JSON, even if not auto-detected.

--form, -f
    Forces the request body to be treated and sent as URL-encoded form data.

--headers, -h
    Displays the response HTTP headers in the output.

--verbose, -v
    Displays detailed information about the request and response, including headers and body.

--pretty={all,colors,format,none}
    Controls the pretty-printing of the output: all (default, colors and format), colors (colors only), format (formatting only), none (no pretty-printing).

--raw
    Disables all pretty-printing, outputting the raw response body.

--ignore-stdin
    Prevents curlie from attempting to read data from standard input.

--download
    Downloads the response body to a file named after the URL's last segment, or from Content-Disposition.

--output
    Writes the response body to the specified file instead of standard output.

--proxy
    Uses the specified HTTP or HTTPS proxy for the request.

--user
    Provides user and password for server authentication.

--header
    Adds a custom HTTP header to the request (e.g., 'Authorization: Bearer token').

--cookie
    Sends an HTTP cookie with the request (e.g., 'session=123').

--timeout
    Sets a maximum time in seconds that the request is allowed to take.

DESCRIPTION

curlie is a powerful command-line HTTP client designed to provide a more intuitive and visually appealing experience than traditional tools like curl, while maintaining a high degree of compatibility with its syntax. It draws inspiration from httpie for its output formatting, offering features like automatic JSON pretty-printing and syntax highlighting, making API debugging and interaction significantly easier.

Written in Go, curlie intelligently infers common request types, such as setting the Content-Type to application/json when a request body looks like JSON, or application/x-www-form-urlencoded for form data. It aims to reduce verbosity for common use cases, allowing users to make complex HTTP requests with fewer explicit options, yet provides full control for intricate scenarios.

CAVEATS

While curlie aims for curl compatibility, it is not a 100% drop-in replacement. Some esoteric curl options may not be supported, or might behave differently. Its primary focus is on HTTP/HTTPS, and it adds processing overhead for features like pretty-printing and syntax highlighting, which might make it less suitable for extreme high-volume, low-latency scripting where raw curl might be preferred. It also requires the Go runtime environment for execution.

KEY FEATURES

curlie offers several features that enhance the command-line HTTP experience:
* Automatic Content-Type Inference: It intelligently determines the Content-Type header based on the request body's structure (e.g., JSON if key-value pairs use :=, or form data if using =).
* Syntax Highlighting: Responses (especially JSON) are automatically color-coded for better readability.
* Pretty Printing: JSON and other structured data are automatically formatted with proper indentation.
* Sensible Defaults: For instance, POST and PUT requests automatically default to JSON if data is provided, reducing the need for explicit -H 'Content-Type: application/json'.
* Simplified Request Items: Easily construct complex request bodies, headers, and form data using intuitive key-value syntax.

HISTORY

curlie was developed by Zack HSIEH, with the intention of blending the robust functionality and widespread adoption of curl with the modern, user-friendly output and ease-of-use championed by httpie. Written entirely in the Go programming language, it was designed to be a single, self-contained binary, making it easy to deploy and use across various Linux distributions and operating systems. Its development reflects a growing demand for developer tools that are both powerful and pleasant to use, particularly for interacting with RESTful APIs.

SEE ALSO

curl(1), httpie(1), wget(1)

Copied to clipboard