LinuxCommandLibrary

http-prompt

Interactive command-line HTTP client

TLDR

Launch a session targeting the default URL of or the previous session

$ http-prompt
copy

Launch a session with a given URL
$ http-prompt [http://example.com]
copy

Launch a session with some initial options
$ http-prompt [localhost:8000/api] --auth [username:password]
copy

SYNOPSIS

http-prompt [] []
Starts an powerful interactive HTTP prompt, optionally pre-configured with a URL or session.

PARAMETERS

--auth USER:PASS
    Specifies HTTP basic or digest authentication credentials.

--auth-type TYPE
    Sets the authentication type (basic or digest).

--proxy PROTOCOL:HOST
    Configures an HTTP proxy for requests.

--verify VALUE
    Controls SSL certificate verification (yes, no, or a path to a CA bundle).

--ignore-netrc
    Prevents the use of credentials stored in .netrc.

--session PATH
    Loads or saves the session state to a specified file.

--body FILE_PATH
    Sets the request body content from a file.

--timeout SECONDS
    Sets a timeout duration for network requests.

--version
    Displays the current version of http-prompt and exits.

--help
    Shows the command's help message and exits.

DESCRIPTION

http-prompt is an interactive command-line HTTP client designed for effortless API testing and development. It provides a rich interactive prompt with features like auto-completion for headers, methods, and URLs, syntax highlighting, and persistent sessions. Built upon the powerful Requests library and inspired by HTTPie, it simplifies complex HTTP interactions by maintaining context across requests. Users can intuitively build, send, and inspect HTTP requests, making it an excellent tool for exploring RESTful APIs. It maintains a state, allowing you to modify previous requests, set default headers, and manage authentication credentials easily.

CAVEATS

Requires Python and its dependencies (requests, httpie, prompt_toolkit). While powerful for interactive use, it is not designed for scripting automated tasks in the same way curl or HTTPie are. Its primary strength lies in its interactive exploration and debugging capabilities.

<I>INTERACTIVE MODE</I>

Once started, http-prompt enters an interactive shell where users can type HTTP methods, URLs, headers, and data. It supports various commands for managing the session, viewing history, and sending requests. The prompt provides real-time auto-completion and syntax highlighting, greatly speeding up API exploration.

<I>SESSION MANAGEMENT</I>

A key feature is its ability to manage sessions. You can load or save your current request context (headers, authentication, base URL) to a file, allowing you to resume work or share configurations with others. This persistence is invaluable for continuous API development and testing.

HISTORY

http-prompt was created by @eliang, drawing inspiration from the user-friendly syntax of HTTPie and the powerful request capabilities of the Requests library. It was initially released around 2016, aiming to bridge the gap between simple command-line HTTP clients and more complex graphical tools by providing an interactive, stateful environment for API interaction and testing. Its development has focused on enhancing user experience through features like smart auto-completion and session management.

SEE ALSO

curl(1), http(1), wget(1)

Copied to clipboard