httprompt v1.1.3
HTTPrompt
httprompt is an interactive command-line API client.
Installation
Either fork and run manually, or install via npm:
npm install -g httpromptThis installs httprompt to your bin path.
Usage
Run httprompt to open the prompt. Common commands:
GET <url>POST <url> <payload>PUT <url> <payload>DELETE <url>- type
helpto see more
Currently only JSON payloads are supported. <payload> can either be:
Key/Value Pairs
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.
Embedded JSON
POST /register { "username": "admin", "password": "letmein" }
JSON payloads must be well-conformed (keys must be quoted).
External Viewers
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.
Configuration
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.profilesets the default profile to useexternalsets the default external viewer. defaults tolessexternal.jsonsets the default external json viewer. defaults toless. jsonfui is recommended as a better alternativevimsets vim keys (hjkl to move around, modes, etc)
Profiles
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.comorhttp://localhost:8888vars: set arbitrary variables here that you can use in commands. For example, if you setusernameandpassword, 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.