0.1.11 • Published 10 months ago
httl-cli v0.1.11
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.
Installation
To install HTTL via npm, run:
npm install -g httl-cliUsage
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
.httlconfig file). - headers: Headers in
key:valueformat, 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/usersGET 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:privateRequests 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.binPOST request with payload from an input stream
httl post https://httpbin.org/anything < ./payload.jsonRunning HTTL Files
HTTL can also execute .httl files, allowing you to define reusable HTTP requests.
Running a .httl file
httl ./file.httlRunning a .httl file from an input stream
httl < ./file.httlDefining a request inline
httl <<EOF
@base: https://httl.dev/api
@auth-basic: admin admin
post /auth
EOFMore Information
For more details, visit the HTTL documentation.