Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Jul 14, 2022. It is now read-only.
/hopp-cliPublic archive

🤖 HTTP CLI client forhttps://hoppscotch.io

License

NotificationsYou must be signed in to change notification settings

hoppscotch/hopp-cli

Repository files navigation

⚠️⚠️⚠️⚠️⚠️⚠️

This project is now archived. If you want to use Hoppscotch as a CLI client for CI/CD purposes, please use the newHoppscotch CLI.

⚠️⚠️⚠️⚠️⚠️⚠️

Hoppscotch CLIhoppscotchGo Report Card

Send HTTP requests from terminal and Generate API Docs. An alternative to cURL, httpie ⚡️

Installation

From Script

$ sh -c"$(curl -sL https://git.io/getpwcli)"

From Source

  • Clone the repo
$ git clone https://github.com/hoppscotch/hopp-cli.git
  • Build and install
$ make$ sudo make install

From Binary

  • You can download prebuilt binaries from theReleases page.
  • Supported platforms:
    • Linux (x64, x86)
    • Mac (x64)
    • Windows (x64, x86)

IMPORTANT: Not tested on Windows, please leave your feedback/bugs in the Issues section

Arch GNU/Linux

  • You can install fromAUR
  • There are three different packages available
NameLinkDescription
hopp-cli-binhttps://aur.archlinux.org/packages/hopp-cli-bin/Pre-built binary
hopp-clihttps://aur.archlinux.org/packages/hopp-cli/Compiled from latest release
hopp-cli-githttps://aur.archlinux.org/packages/hopp-cli-git/Compiled from latest commit

Homebrew

Install by

brew install athul/tap/hopp-cli

Windows

You can download pre-built binaries from theReleases page.

Alternatively, you can installhopp-cli viaScoop:

scoop install hopp-cli

Usages

Putting Simply:Just pass the URL to the request method

Basic Commands

  • GET :$ hopp-cli get <url>
  • POST:$ hopp-cli post <url>
  • PATCH:$ hopp-cli patch <url>
  • PUT :$ hopp-cli put <url>
  • DELETE:$ hopp-cli delete <url>

Example for a POST request:

$ hopp-cli post https://reqres.in/api/users/2 -c js -b'{"name": "morp","job": "zion resident"}'

Extra Commands

  • send for testing multiple endpoints
  • gen for generating API docs from Collection

SEND

This can be used to test multiple endpoints from thehoppscotch-collection.json file.

The output will only be thestatuscode

Example:

$ hopp-cli send<PATH to hoppscotch-collection.json>

Sample output:

send-output

GEN

Thegen command generates the API documentation fromhoppscotch-collection.json file and serves it as a static page on port1341.

Example:

$ hopp-cli gen<PATH to hoppscotch-collection.json>

Sample Hosted site:https://hopp-docsify.surge.sh/

Powered byDoscify

Flags:

  • browser orb to toggle whether the browser should open automatically [Boolean]
  • port orp for specifying the port where the server should listen to [Integer]

There are 3 Authentication Flags

(optional)

  • -t or--token for a Bearer Token for Authentication
  • -u for theUsername in Basic Auth
  • -p for thepassword in Basic Auth

There are 2 flags especially for the data management requests like POST, PUT, PATCH and DELETE

  • -c or--ctype for theContent Type
  • -b or--body for the Data Body, this can be of json, html or plain text based on the request.

Enclose the body in Single Quotes(')

Content Types can be of

Short CodeContent Type
jsapplication/json
htmltext/html
xmlapplication/xml
plaintext/plain

Include Arbitrary Headers

  • -H or--header may be specified multiple times to include headers with the request.

Example:

$ hopp-cli get -H'X-Api-Key: foobar' -H'X-Api-Secret: super_secret' https://example.com/api/v1/accounts

Providing a Request Body via stdin

In addition to-b/--body, you may provide a request body via stdin.
If you combine this method with the-b flag, the body provided with-b will be ignored.

Example with Pipes

$echo'{"foo":"bar"}'| hopp-cli post -c js http://example.com

Example with Redirection

$ cat myrequest.json{"foo":"bar"}$ hopp-cli post -c js http://example.com<myrequest.json

Providing a Request Body via text-editor

In addition to providing request body via-b / --body flag and stdin,you can also use-e / --editor flag which opens default text-editor in your system.

Example:

$ hopp-cli post https://reqres.in/api/users/2 -c js -e

It will preferrably open editor based on$EDITOR environment variable.

For example:If the environment variable is$EDITOR=code it will open VSCode for request-body input. Else, it will use default editor value based on the OS.

OSDefault Editor
Linuxnano
macOSnano
Windowsnotepad

[8]ページ先頭

©2009-2025 Movatter.jp