callfetch
v1.0.2
Published
Simple CLI to call APIs using fetch
Readme
callfetch
Simple CLI to call APIs using fetch — interactively choose method, headers and body or pass a URL directly.
Author: Ankit K Kashyap
What is this all about?
callfetch is a small Node.js command-line tool for quickly calling HTTP APIs. It's useful for testing endpoints, debugging webhooks, or making one-off requests without writing code. It supports interactive prompts for method, content-type and body, and accepts a URL argument for quick requests.
Installation
Using npx (no install required):
npx callfetch https://example.com/apiInstall globally with npm:
npm i -g callfetch
# then run
callfetch https://example.com/apiOr add to your project:
npm i callfetch
# require/import and use if needed (the package is a CLI entrypoint)How to host / use / run
- Quick call by passing URL as first argument:
npx callfetch https://httpbin.org/get- Interactive mode (no URL provided):
#npx callapi
npx callfetch
# You'll be prompted for URL, method, content-type and body (for POST/PUT/PATCH)- Run directly with Node (for development):
node cli.js https://example.comWhat prompts look like
- URL (if not provided)
- HTTP method: GET, POST, PUT, DELETE, PATCH
- Content-Type: text/plain, application/json, application/x-www-form-urlencoded
- For POST/PUT/PATCH — you'll be asked for raw body text. If using
application/x-www-form-urlencoded, the tool will parse key=value pairs and send a proper urlencoded body.
Examples
GET request:
npx callfetch https://httpbin.org/getPOST JSON (interactive):
npx callapi
# choose POST, application/json, then paste JSON bodyPOST form urlencoded (interactive):
Enter body like:
name=Ankit&msg=helloThe CLI will convert that into application/x-www-form-urlencoded format.
For development
- Clone the repo
- Install dependencies
npm i- Run locally
npm start
# or
node cli.jsFiles included in the package
Only cli.js is included in the published package (see package.json files field).
Notes & edge cases
node-fetchis used and the package is ESM (type: "module").- If you provide malformed JSON for a JSON content-type, the server may reject it — the CLI does not validate JSON before sending.
application/x-www-form-urlencodedinput is expected askey=value&key2=value2or similar; the CLI will parse it using URLSearchParams and re-encode usingqs.
License
MIT
Donations / Support
If you like this project and want to support maintenance and development, you can:
Buy me a Dosha :

