bpkg-http
bpkg-http
A thin, ergonomic wrapper around curl for making HTTP requests from bash scripts. Supports JSON bodies, custom headers, timeouts and response parsing.
Installation
bpkg install jakwings/bpkg-http
Usage
source bpkg_modules/bpkg-http/http.sh
# Simple GET
body=$(http_get "https://api.example.com/status")
# POST with JSON
http_post "https://api.example.com/users" \
--header "Authorization: Bearer $TOKEN" \
--json '{"name":"alice","role":"admin"}'
# Check status code
if http_ok "https://api.example.com/health"; then
echo "Service is up"
fi
Functions
| Function | Description |
|---|---|
http_get |
Perform a GET request |
http_post |
Perform a POST request |
http_put |
Perform a PUT request |
http_delete |
Perform a DELETE request |
http_ok |
Returns 0 if status is 2xx |
http_status |
Print the HTTP status code |