httprompt is an interactive command-line API client.
Either fork and run manually, or install via npm:
npm install -g httprompt
This installs httprompt
to your bin path.
Run httprompt
to open the prompt. Common commands:
GET <url>
POST <url> <payload>
PUT <url> <payload>
DELETE <url>
- type
help
to see more
Currently only JSON payloads are supported. <payload>
can either be:
POST /register username=admin password=letmein
POST /comments message="some message with spaces"
If you need more complex data entry, you'll probably want to use the embedded JSON.
POST /register { "username": "admin", "password": "letmein" }
JSON payloads must be well-conformed (keys must be quoted).
By default, each command will just dump output to the screen, which may be hard to read. By running the open
command, httprompt open the last response in your external. viewer. Alternatively, open <command>
to always open a command externally.
You can manage config in the app with config set <key> <value>
, or you can run config edit
to open the config file in your $EDITOR
.
Options:
default.profile
sets the default profile to useexternal
sets the default external viewer. defaults toless
external.json
sets the default external json viewer. defaults toless
. jsonfui is recommended as a better alternativevim
sets vim keys (hjkl to move around, modes, etc)
Edit the profiles
config option to add new profiles.
The profile specified by default.profile
is loaded by default, or optionally specify another with httprompt -p <profileName>
baseUrl
: sets the base URL (prepend to all URLs). Example:http://yoursite.com
orhttp://localhost:8888
vars
: set arbitrary variables here that you can use in commands. For example, if you setusername
andpassword
, you could use$(profile.username)
and$(profile.password)
in commands and they would be expanded.startupTasks
: defines an array of tasks to run when opening a profile for the first timeactions
: defines custom commands made up of existing commands. For example, you could define login:
"baseUrl": "http://localhost:8888",
"actions": {
"login <username> <password>": [
"POST /login username=$(input.username) password=$(input.password)"
]
}
then you could open the app and run login admin letmein
and it would post to that URL.