aboutsummaryrefslogtreecommitdiff

rest-run

Postman? Never heard of it! rest-run is the only REST API client you will ever need!

Dependencies

  • Ranger file manager
  • HTTPie
  • esh template engine

Instalation

If you have GNU Make installed run a

make install

Otherwise just copy the rest-run script to some directory on your $PATH

Usage

# pipe JSON body to rest-run
cat /tmp/body.json | rest-run http://localhost:8080/api/path --body stdin

# create a PUT request, the default editor will be called to compose the request body
rest-run PUT http://localhost:8080/api/resource

# replay last request according to the API path, skip editting request body
rest-run PUT http://localhost:8080/api/resource -b last -ne

# pick request response from history according to the API path and read it with a pager
rest-run PUT http://localhost:8080/api/resource -r last -p
Positional arguments

You must provide the API URL. An HTTP verb preceding it is accepted if present.

Options
  • -x|--method HTTP Method
  • -b|--body Request body source, must be one of the following options:
  • default - create a request body using the default editor
  • last - use the last request
  • history - pick from the request history
  • stdin - reads from piped input
  • -r|--response Request response handling, must be one of the following options:
  • default - store the request on cache
  • last - read last request, skip request
  • history - pick from the response history, skip request
  • -ne|--no-edit Skip request editting. Ignored when --body is set to default
  • -h|--header Header string. Ex: "Authorization: Bearer 123"
  • -p|--paginate Paginate request response

rest-run parses your request body with a simple template engine called esh. You can embed shell scripts/commands in your request file surrouning it with <% my-command %> or <%= $MY_ENV_VARIABLE %>

Example:

  echo '{
    "username": "<%= $USER %>",
    "device": "<%= $HOSTNAME %>",
    "created_at": "<% date +"%FT%T.000Z" %>",
    "password": 123
  }' | rest-run POST https://postman-echo.com/post