---
name: api-testing
description: "Use when testing HTTP endpoints, probing URLs for status and headers, or running declarative API test suites from plain text files"
allowed-tools: [ Bash(hurl*), Bash(httpx*), Read, Write, Glob ]
version: 1.0.0
author: ykotik
license: MIT
title: api-testing
canonical_url: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/api-testing
last_updated: 2026-10-04T03:21:13.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install jeremylongshore/tons-of-skills-marketplace/api-testing`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/api-testing`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/jeremylongshore/tons-of-skills-marketplace/api-testing) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/api-testing`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/api-testing --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/api-testing --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# API Testing

## When to Use
- Testing REST API endpoints for correct responses
- Writing declarative, repeatable HTTP test suites
- Chaining HTTP requests (authenticate → create → verify)
- Probing multiple URLs for availability, status codes, or headers
- Validating response bodies, headers, and status codes with assertions

## Tools

| Tool | Purpose | Structured output |
|------|---------|-------------------|
| **Hurl** | Declarative HTTP testing from plain text `.hurl` files | `--json` for JSON report |
| **httpx** | Fast HTTP probing toolkit (ProjectDiscovery) | `-json` for JSON output |

## Patterns

### Hurl: Simple GET with status assertion
Create a `.hurl` file:
```hurl
GET http://localhost:3000/api/health
HTTP 200
[Asserts]
jsonpath "$.status" == "ok"
```
Run it:
```bash
hurl health.hurl
```

### Hurl: POST with JSON body and response validation
```hurl
POST http://localhost:3000/api/users
Content-Type: application/json
{
  "name": "Alice",
  "email": "alice@example.com"
}
HTTP 201
[Asserts]
jsonpath "$.id" isInteger
jsonpath "$.name" == "Alice"
```

### Hurl: Chained requests (auth → create → verify)
```hurl
# Step 1: Login
POST http://localhost:3000/api/auth/login
Content-Type: application/json
{
  "email": "admin@example.com",
  "password": "secret"
}
HTTP 200
[Captures]
token: jsonpath "$.token"

# Step 2: Create resource with token
POST http://localhost:3000/api/items
Authorization: Bearer {{token}}
Content-Type: application/json
{
  "title": "New Item"
}
HTTP 201
[Captures]
item_id: jsonpath "$.id"

# Step 3: Verify resource exists
GET http://localhost:3000/api/items/{{item_id}}
Authorization: Bearer {{token}}
HTTP 200
[Asserts]
jsonpath "$.title" == "New Item"
```

### Hurl: Run test suite with JSON report
```bash
hurl --test --report-json report/ tests/*.hurl
```

### Hurl: Use variables from command line
```bash
hurl --variable host=https://staging.example.com --variable token=abc123 tests/api.hurl
```

### httpx: Probe a list of URLs for status codes
```bash
echo -e "https://example.com\nhttps://httpbin.org\nhttps://nonexistent.invalid" | httpx -silent -status-code
```

### httpx: Probe with full JSON output (status, title, tech)
```bash
echo "https://example.com" | httpx -json -title -tech-detect -status-code
```

### httpx: Check specific ports across hosts
```bash
echo -e "192.168.1.1\n192.168.1.2" | httpx -ports 80,443,8080 -status-code
```

### httpx: Follow redirects and show final URL
```bash
echo "http://github.com" | httpx -follow-redirects -location -status-code
```

## Pipelines

### Hurl test suite → summarize failures
```bash
hurl --test --report-json report/ tests/*.hurl 2>&1; jq '[.[] | select(.success == false) | {file: .filename, errors: [.entries[] | select(.errors | length > 0) | .errors]}]' report/*.json
```
Each stage: Hurl runs all tests and writes JSON reports, jq filters to failures and extracts error details.

### Discover endpoints with Katana → probe with httpx
```bash
katana -u https://example.com -silent -d 2 | httpx -silent -status-code -json
```
Each stage: Katana crawls and discovers URLs, httpx probes each for status and metadata.

## Prefer Over
- Prefer **Hurl** over curl scripts for multi-step API testing — declarative syntax with built-in assertions, no bash scripting needed
- Prefer **Hurl** over Postman/Bruno for CI-friendly test suites — plain text files, no GUI dependency
- Prefer **httpx** over curl loops for probing many URLs — concurrent, structured output, built for scale

## Do NOT Use When
- Need full browser rendering or JavaScript execution — use web-crawling skill (Playwright)
- Building a long-running API client or SDK — write code instead
- Testing WebSocket or gRPC endpoints — use specialized tools (wscat, grpcurl)
- Single ad-hoc curl request — just use `curl` directly
