0.2.0 • Published 5 years ago

http-request-cli v0.2.0

Weekly downloads
39
License
MIT
Repository
github
Last release
5 years ago

H

Simple CLI to query HTTP endpoints.

Install

npm i -g http-request-cli

Now you have h as a command to query http endpoint in your terminal.

Usage

Usage: h [options] [command]

Options:
  -V, --version               output the version number
  -v, --verbose               Verbose mode
  --no-color                  Monochrome display
  -o, --output <file name>    Save response to a file
  -y, --yaml                  Render JSON data in a coloured YAML-style
  -H, --header <name=value>   Set a header (default: {})
  -d, --data [data]           Content of request
  -D, --datafile <file name>  
  -t, --type <content type>   Content type
  -c, --cookie <cookie file>  Cookie file
  -h, --help                  output usage information

Commands:
  get <url> [options]         Send a GET request
  post <url> [options]        Send a POST request
  put <url> [options]         Send a PUT request
  delete <url> [options]      Send a DELETE request
  patch <url> [options]       Send a PATCH request
  head <url> [options]        Send a HEAD request

Examples

  • Simple GET request
h get https://jsonplaceholder.typicode.com/todos/1

simple query

  • GET request with response formatted as YAML
h get https://jsonplaceholder.typicode.com/todos/1 -y

simple query yaml

  • POST request with data provided as JSON
h post https://jsonplaceholder.typicode.com/posts -d '{"name":"bob"}'

post json

  • POST request with data provided as properties and converted into JSON
h post https://jsonplaceholder.typicode.com/posts -d name=alice

post props

TODO

  • Automatic save of binary files (images, pdf, ...)
  • Headers provided in a file
  • Proxy support first version: to be largely tested
  • Type of authentication (basic, ...) + Username/password
  • POST by default when data is provided
  • Progress bar