An open API service indexing awesome lists of open source software.

https://github.com/bbonnin/h

Simple CLI to query HTTP endpoints
https://github.com/bbonnin/h

cli curl hacktoberfest http wget

Last synced: 4 months ago
JSON representation

Simple CLI to query HTTP endpoints

Awesome Lists containing this project

README

          

# H

> Simple CLI to query HTTP endpoints.

## Install

```bash
npm i -g http-request-cli
```

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

## Usage

```bash
Usage: h [options] [command]

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

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

## Examples

* Simple GET request

```bash
h get https://jsonplaceholder.typicode.com/todos/1
```

![simple query](docs/simple-get.png)

* GET request with response formatted as YAML

```bash
h get https://jsonplaceholder.typicode.com/todos/1 -y
```

![simple query yaml](docs/simple-get-yaml.png)

* POST request with data provided as JSON

```bash
h post https://jsonplaceholder.typicode.com/posts -d '{"name":"bob"}'
```

![post json](docs/post-json.png)

* POST request with data provided as properties and converted into JSON

```bash
h post https://jsonplaceholder.typicode.com/posts -d name=alice
```

![post props](docs/post-props.png)

## TODO

* Automatic save of binary files (images, pdf, ...)
* Proxy support [first version: to be largely tested]
* Other types of authentication
* Progress bar