No Description

gwillz 73803d71c8 Version bump 1.4.4. 1 month ago
src 55a2ed4ee5 Added HTTP/1.1 token to test file, looser token matching. 1 month ago
tests b9e7a2533c Export main/express app, ready for integrated testing. 1 month ago
.gitignore 2ea6955264 Initial parser. 5 months ago 6fd5564924 Added readme, license. 5 months ago a5c393c02f Rename binary to 'restcli'. 5 months ago
_config.yml c7817212b5 Set theme jekyll-theme-tactile 3 months ago
package-lock.json 73803d71c8 Version bump 1.4.4. 1 month ago
package.json 73803d71c8 Version bump 1.4.4. 1 month ago
tsconfig.json dc6c171db0 Fix tests missing types. 1 month ago

Rest CLI

A request runner inspired by REST Client.

This tool is intended to be compliant with Hauchao's VSCode plugin so that requests can be sequenced via command line tools.


npm install -g rest-cli

# A single file, simple output.
# Shows stats, request method, and URL.
restcli myrequest.http

# A sequence of files.
restcli requests/*.http

# All .http files in the current directory.
restcli .

# Modify retry count (default: 3).
restcli --retry 5 myrequest.http

# A named request within a file.
restcli --pick myname myrequest.http

# Hide the stats (1: [2]).
restcli --no-stats myrequest.http

# Show the request.
restcli --request slug|headers|body myrequest.http

# Show the response.
restcli --response slug|headers|body myrequest.http

# Show everything.
restcli --full myrequest.http

# Disable colour.
restcli --no-color myrequest.http


This package exports a file parser and utilities for automating your requests.

Typescript defs are also exported.


import { RestParser } from 'rest-cli';

(async () => {
    const parser = new RestParser();
    await parser.readFile("./myrequest.http");
    const request = await parser.get(0);
    const { response } = await request.request();

Node v8

This uses async iterators and therefore only supports Node v10. Note, as of January 2020, Node v8 is end-of-life and unsupported. If you really need Node v8, you can hack a solution with the --harmony_async_iterator flag.

Something like:

echo "#!/usr/bin/node --harmony_async_iterator" > restcli
echo "require('rest-cli').main()" >> restcli
chmod +x restcli

HTTP Language

This follows the standard RFC 2616, with templating as defined by vscode-restclient.

Example file

@baseUrl =

# @name login
POST {{baseUrl}}/api/login HTTP/1.1
Content-Type: application/x-www-form-urlencoded



@authToken = {{login.response.headers.X-AuthToken}}

# @name createComment
POST {{baseUrl}}/comments HTTP/1.1
Authorization: {{authToken}}
Content-Type: application/json

    "content": "fake content"


@commentId = {{createComment.response.body.$.id}}

# @name getCreatedComment
GET {{baseUrl}}/comments/{{commentId}} HTTP/1.1
Authorization: {{authToken}}


# @name getReplies
GET {{baseUrl}}/comments/{{commentId}}/replies HTTP/1.1
Accept: application/xml


# @name getFirstReply
GET {{baseUrl}}/comments/{{commentId}}/replies/{{getReplies.response.body.//reply[1]/@id}}

Not supported

  • $aadToken
  • extension (%varname) environment variables


  • variables should be recursively interpolated in when used instead of statically
  • shared variables, environment files
  • GraphQL support
  • multipart file loading support
  • cookies??
  • tests for:
    • functions
    • request (fill, slug, body)
    • restfile
    • utils (basicAuth, bodyAsString, ServerError)
    • parser (out-of-order, iterator, get)
  • cli options for:
    • timeout
    • environment file
    • config file
  • config file:
    • timeout
    • followRedirects
    • defaultHeaders?
    • proxy?
    • show/hide stats
    • show/hide request [slug, headers, body]
    • show/hide response [slug, headers, body]