httl-cli

0.1.11 • Public • Published

HTTL CLI

HTTL CLI is a powerful and flexible HTTP client designed for the command line. It leverages the HTTL engine to provide a simple yet robust way to make HTTP requests from the terminal.

Learn more at httl.dev

Installation

To install HTTL via npm, run:

npm install -g httl-cli

Usage

HTTL provides an intuitive syntax for making HTTP requests. The basic usage is:

httl <method> <url> [headers] [body_format] [body]

Parameters:

  • method: One of the following HTTP methods:
    • get, post, put, delete, patch, head, options, connect, trace, lock, unlock, propfind, proppatch, copy, move, mkcol, mkcalendar, acl, search
  • url: The URL for the request (absolute or relative when using a .httl config file).
  • headers: Headers in key:value format, separated by spaces (e.g., Authorization:Bearer token).
  • body_format: The format of the request body, one of:
    • --json (default)
    • --formdata
    • --urlencoded
    • --raw
    • --bin
  • body: The request body (e.g., '{ "name": "John" }').

Examples

Basic Requests

Simple GET request

httl get https://httl.dev/api/users

GET request with a default .httl configuration file

httl get users

(Requires a .httl file with @base: https://httl.dev/api)

GET request with headers

httl get https://httl.dev/api/users Authorization:"Bearer token" Cache-Control:private

Requests with Body

POST request with JSON body

httl post https://httpbin.org/anything '{ "name": "John" }'

PUT request with form data

httl put https://httpbin.org/anything --formdata '{ "name": "John" }'

POST request with URL-encoded body

httl post https://httpbin.org/anything --urlencoded '{ "name": "John" }'

POST request with raw body

httl post https://httpbin.org/anything 'name=John&age=30'

POST request with binary file

httl post https://httpbin.org/anything --bin ./file.bin

POST request with payload from an input stream

httl post https://httpbin.org/anything < ./payload.json

Running HTTL Files

HTTL can also execute .httl files, allowing you to define reusable HTTP requests.

Running a .httl file

httl ./file.httl

Running a .httl file from an input stream

httl < ./file.httl

Defining a request inline

httl <<EOF
@base: https://httl.dev/api
@auth-basic: admin admin
post /auth
EOF

More Information

For more details, visit the HTTL documentation.

Package Sidebar

Install

npm i httl-cli

Homepage

httl.dev

Weekly Downloads

7

Version

0.1.11

License

HTTL License

Unpacked Size

635 kB

Total Files

5

Last publish

Collaborators

  • lojell