Skip to main content

Command Palette

Search for a command to run...

hoppscotch-cli

Published
•3 min read•View as Markdown

You have probably heard of the open source web based HTTP client Hoppscotch but today we'll look at it cousin, the command line based version. While the web version is the most popular among the two because of its minimalist design and open source philosophy, I believe that for making requests, this works just fine. I know what you might be asking... What about cURL? It comes pre-installed on almost all major distributions of Linux and has been working just fine for over twenty years now, but according to my opinion, it's overloaded with features that might not be useful to most developer who just want to make simple get and post requests while testing their api's. The other issues which might be trivial is that I am on a Debian derivative. Most users will know that it takes ages for the maintainers to approve changes made to programs and libraries like cURL and upstream the changes. Right now the current version of cURL on Debian doesn't support http3,mainly because it has to be thoroughly tested before the changes can be approved and its security on Debian guaranteed.

Currently hoppscotch-cli is only found in the AUR but not in any Debian sources. The easiest way to install it would be by downloading the pre-built binaries from the releases page on the GitHub repo. After the download unzip the gzip file we use tar which will look like sotar -xvf hopp-cli_0.0.7_Linux_x86_64.tar.gz. The flags; x decompresses the data, v means that tar will talk alot and tell you the files being extracted and f which tell tar the name and path of the files. The order is very important. We finally have a look at our hoppescotch cli command. You can copy it to any of the $PATH and have it installed globally.

I will run it locally from the Downloads folder and make requests from there . You can use it for the basic HTTP requests, GET POST PUT DELETE . Using the mock json data from json placeholder we can make a simple get request like so ./hopp-cli get https://jsonplaceholder.typicode.com/users which will return a json list of ten users as seen below.

get-data.png

It does not stop there. You can also make a POST request. Using the example on the README we can do so like this ./hopp-cli post https://jsonplaceholder.typicode.com/posts -c js -b '{"title": "noe a fake title", "body": "totally real body", "userId": 2}' which will output

Status:         201 Created                                                 
StatusCode:     201                                                   
{
  "title": "noe a fake title",
  "body": "totally real body",
  "userId": 2,
  "id": 101
}

The flags c indicates the content type and in my case this is json while the flag -b indicates the value of the body. It is worth noting that the content types are expressed by short codes so js - application/json, html - text/html, xml - application/xml and finally plain - text/plain

There is also the -t flag which is used to include a token and is very usefull expecially when working with jsonwebtokens.

173 views