DEV Community

Cover image for Best lightweight CLI tools for API testing
Hassann
Hassann

Posted on • Originally published at apidog.com

Best lightweight CLI tools for API testing

Most API testing tools start with a GUI: open a workspace, sign in, and click through a request. That works for exploration, but it is inefficient when you are already in a terminal. Lightweight CLI tools keep the interaction simple: run one command, inspect the response, and continue.

Try Apidog today

For this article, “lightweight” means a small install, fast startup, minimal setup, terminal-friendly output, and useful exit codes for scripts or CI. This is not a ranking by feature count or open-source status. For GUI and hosted options too, see the best free API testing tools roundup.

Below are eight CLI tools for REST and HTTP API testing. They range from manual request clients to tools that run repeatable test suites in CI.

What makes an API CLI tool lightweight?

A terminal tool is lightweight when it meets most of these criteria:

  • Small footprint: a single binary, one pip or npm install, or an npx command.
  • Fast startup: it launches and sends requests without a lengthy runtime warm-up.
  • Minimal configuration: you can make a first request without creating a project, logging in, or starting a daemon.
  • Terminal-native output: results are readable, pipeable, and paired with meaningful exit codes.

The first tools in this list optimize for fast manual requests. The later tools add assertions, workflows, and CI support. For more manual-client options, see curl alternatives for REST API testing.

curl: the baseline that is probably already installed

curl ships with macOS, most Linux distributions, and modern Windows. If you cannot install extra tooling, it is usually your best starting point.

# Check the installed version
curl --version

# POST JSON and print only the HTTP status code
curl -s -o /dev/null -w "%{http_code}\n" \
  -X POST https://httpbin.org/post \
  -H "Content-Type: application/json" \
  -d '{"user":"acme","plan":"pro"}'
Enter fullscreen mode Exit fullscreen mode

Best for: one-off requests, shell scripts, and restricted environments.

Limit: headers and payloads are verbose, JSON output is not formatted by default, and assertions are DIY. You typically pipe output to jq and handle failure logic yourself.

HTTPie: curl with friendlier syntax

HTTPie provides a more readable command format for manual API exploration. It formats output by default and uses simple key=value syntax for request fields.

python -m pip install httpie   # Or: brew install httpie

# age:=24 sends a number; name=acme sends a string
http POST httpbin.org/post name=acme age:=24 plan=pro
Enter fullscreen mode Exit fullscreen mode

Best for: manually exploring APIs when readable output matters.

Limit: HTTPie uses Python, so startup is slower than a compiled binary and a clean environment may need Python installed first. Like curl, it is an HTTP client rather than a test runner.

xh: HTTPie-style requests in a single binary

xh implements HTTPie-like syntax in Rust. It provides fast startup, colored output, HTTP/2 support, and a --curl option that prints an equivalent curl command.

brew install xh   # Or: cargo install xh --locked

# HTTPie-compatible syntax with faster startup
xh POST httpbin.org/post name=acme age:=24 plan=pro
Enter fullscreen mode Exit fullscreen mode

Best for: developers who want HTTPie ergonomics without a Python runtime.

Limit: it does not implement every HTTPie feature and has a smaller ecosystem. It is still a request client, not an assertion engine.

Hurl: plain-text HTTP tests for CI

Hurl moves from sending requests to testing responses. You define requests and assertions in .hurl files, commit them to version control, and run them locally or in CI.

brew install hurl   # Or: cargo install --locked hurl

cat > login.hurl <<'EOF'
POST https://httpbin.org/post
{ "user": "acme", "plan": "pro" }

HTTP 200
[Asserts]
jsonpath "$.json.user" == "acme"
EOF

# Returns a non-zero exit code when an assertion fails
hurl --test login.hurl
Enter fullscreen mode Exit fullscreen mode

Best for: readable smoke tests and contract-style HTTP checks stored alongside application code.

Limit: Hurl is HTTP-focused. It does not drive gRPC or generate real load, and complex flows are expressed through additional .hurl files rather than a general-purpose scripting language.

Step CI: multi-step API flows in YAML

Step CI runs API workflows defined in YAML. It supports REST, GraphQL, gRPC, tRPC, and SOAP, and can validate APIs against an OpenAPI schema.

npm install -g stepci

# workflow.yml defines steps, captures, and checks
stepci run workflow.yml
Enter fullscreen mode Exit fullscreen mode

A typical workflow can:

  1. Authenticate a user.
  2. Capture the returned token.
  3. Send the token with a follow-up request.
  4. Assert on the final response.

Best for: teams that want declarative, multi-step API flows that run the same way locally and in CI.

Limit: Step CI is a Node package, so it has a runtime dependency and is heavier than a standalone Rust or Go binary. Its release cadence has slowed, so check recent repository activity before standardizing on it. For broader planning guidance, see API testing strategies.

k6: lightweight load testing from the terminal

k6 answers a performance question rather than just a functional one: can the API handle traffic under a defined load? It is written in Go, distributed as a static binary, and uses JavaScript for test scripts.

brew install k6   # Or: docker run grafana/k6

cat > load.js <<'EOF'
import http from 'k6/http';
import { check } from 'k6';

export const options = {
  vus: 10,
  duration: '30s',
  thresholds: {
    http_req_duration: ['p(95)<500'],
  },
};

export default function () {
  const res = http.get('https://httpbin.org/get');

  check(res, {
    'status is 200': (r) => r.status === 200,
  });
}
EOF

k6 run load.js
Enter fullscreen mode Exit fullscreen mode

When a configured threshold is breached, k6 exits with code 99, allowing CI to fail the build.

Best for: scripted load and performance checks that run from a laptop or CI pipeline.

Limit: k6 is not designed for manually inspecting one response. Meaningful scenarios require learning its JavaScript API and performance-testing concepts.

Newman: run Postman collections headlessly

Newman is Postman’s command-line collection runner. Export a Postman collection and, optionally, an environment file, then run the same tests without opening the Postman GUI.

npm install -g newman

# collection.json is exported from Postman
# staging.json is an optional Postman environment
newman run collection.json -e staging.json
Enter fullscreen mode Exit fullscreen mode

Newman returns a non-zero exit code when a test fails, making it suitable for CI gates.

Best for: teams already maintaining Postman collections and wanting to execute them in pipelines.

Limit: it depends on Node.js and runs Postman-format collections only. It is most valuable when Postman is already part of your workflow.

Apidog CLI: run visual scenarios from CI

The Apidog CLI is the terminal runner for scenarios created in Apidog. Install the apidog-cli npm package, authenticate with a token, then run a scenario headlessly.

npm install -g apidog-cli
apidog login --with-token <YOUR_TOKEN>

# Copy this command from the scenario's CI/CD tab
apidog run -t <scenario_id> -e <env_id> -r cli
Enter fullscreen mode Exit fullscreen mode

To get the exact IDs:

  1. Open a test scenario in Apidog.
  2. Go to the CI/CD tab.
  3. Copy the generated apidog run command.
  4. Add it to your local script or CI configuration.

Use -r cli for step-by-step terminal output. Use -r cli,junit when your CI system needs JUnit-compatible test results.

apidog run -t <scenario_id> -e <env_id> -r cli,junit
Enter fullscreen mode Exit fullscreen mode

apidog run exits with 0 when assertions pass and a non-zero code when they fail. Its structured JSON output includes agentHints.nextSteps, which can also help AI coding agents run and interpret results.

Best for: teams that author complex, multi-step scenarios visually but need to run them from a terminal, CI pipeline, or agent.

Limit: unlike curl or xh, it runs scenarios stored in an Apidog project. It is an integrated-platform option rather than a bare HTTP client.

For more details, see the Apidog CLI complete guide, the apidog run command reference, and this walkthrough for testing a REST API from the command line with Apidog CLI.

How to choose

Tool Best for Install Open source? Notes
curl One-off requests, scripts Preinstalled Yes (MIT/curl) Universal; assertions are DIY
HTTPie Readable manual requests pip install httpie Yes (BSD-3) Friendly syntax; Python runtime
xh HTTPie feel with faster startup brew install xh Yes (MIT) Single Rust binary
Hurl Plain-text HTTP tests brew install hurl Yes (Apache-2.0) --test gates CI
Step CI Multi-step YAML flows npm i -g stepci Yes (MPL-2.0) REST/GraphQL/gRPC; Node runtime
k6 Load and performance testing brew install k6 Yes (AGPL-3.0) JavaScript scripts; thresholds fail runs
Newman Postman collections in CI npm i -g newman Yes (Apache-2.0) Runs Postman JSON headlessly
Apidog CLI Visual scenarios run headlessly npm i -g apidog-cli No (free tier) Exit-code gate; agent-native JSON

Use this progression:

  • Choose curl when you need universal availability.
  • Choose xh or HTTPie when you need readable manual requests.
  • Choose Hurl when those requests should become version-controlled assertions.
  • Choose Step CI for declarative multi-step workflows.
  • Choose k6 when you need to validate performance under load.
  • Choose Newman when your test suite already lives in Postman.
  • Choose Apidog CLI when you want to build scenarios visually and execute them headlessly.

For a GUI-free testing workflow, see the headless API testing tool guide.

Where lightweight CLI tools pay off

CLI tools are most useful when a GUI would interrupt the workflow:

  • You are debugging from a terminal.
  • You need a repeatable smoke test in a pull request.
  • A pipeline must block deployment on failed assertions.
  • An AI agent needs a command, structured output, and an exit code.

curl and xh keep manual testing fast. Hurl and Step CI turn ad-hoc requests into repeatable checks. k6 handles load. Newman runs existing Postman collections.

The Apidog CLI connects visual scenario authoring with terminal execution. Build a scenario once in Apidog, then run it with apidog run from your terminal or pipeline. Download Apidog, create a scenario, and add its generated command to CI.

Top comments (0)