apic

module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2026 License: MIT

README


apic

apic is epic: run API requests from plain .http files, in the terminal, in CI, or from an AI agent, on any platform, with one static binary.

CI Docs Latest release MIT licence

apic ui --demo                      # a fake API and a UI to poke it with, no setup
apic run login                      # POST, capture the token
apic run get-user --env staging     # reuse the token, check assertions
apic run smoke.http --json | jq     # whole file as a flow, one JSON line per request
apic test                           # run Gherkin features against the same requests
claude mcp add api -- apic mcp      # let an agent call the same requests as tools

Try it in 30 seconds

No account or API key needed, and nothing to clone. apic ui --demo serves a small fake API in-process and opens the terminal UI on an example project that targets it:

go install github.com/hungovercoders/apic/cmd/apic@latest
apic ui --demo

Press enter to send the request under the cursor, f to run a whole file as a flow, e to switch environment and ? for every key. Prefer the plain CLI? apic demo writes the same project to a directory and serves the API, so you can run it by hand:

apic demo                                  # terminal 1: writes ./apic-demo, serves the API
apic run login whoami -C apic-demo         # terminal 2
apic ui -C apic-demo --env local           # or the UI, same directory

Every command resolves .http files relative to -C (default: the current directory), so apic ui on its own in that second terminal won't see the project apic demo just wrote — point it at the directory explicitly.

Why it's epic

Postman and Bruno are apps. VS Code and JetBrains .http files are great until you leave the editor. Taskfile + curl runs anywhere but has no environments, no chaining, no assertions and no output a program can read.

apic takes the .http format editors already understand and adds what the terminal and agents need:

  • Environments from http-client.env.json (the JetBrains / kulala / httpyac convention) plus .env, shell and --var.
  • Captured variables that persist. # @capture token = body.$.access_token in login means the next apic run get-user, in a new shell or a new agent call, has {{token}}.
  • Assertions with # @assert status == 200, and files that run as ordered flows with a pass/fail summary and exit code.
  • Auth that is otherwise impossible in a text file. # @auth aws signs with SigV4 from your normal AWS credentials (environment, profiles, SSO via the AWS CLI) with no SDK in the binary; # @auth oauth2 fetches, caches and refreshes tokens; digest answers the server's challenge; apikey, basic, bearer and exec (any CLI that prints a token) round it out.
  • Gherkin without Cucumber. apic test runs .feature files with a built-in step vocabulary; # @step a user named {name} exists on a request makes features read as behaviour.
  • A terminal UI. apic ui browses the project, runs requests and flows, shows each row's status and round trip as it lands, and switches environment without leaving the keyboard.
  • Safe to log. Sensitive headers are masked in output, on the request and the response; --redact masks both bodies, all header values, query values, captures and assertion values for stored CI logs, keeping status, timing and pass/fail.
  • Agent-first output. --json gives a stable object per request; list and describe make requests discoverable; errors say what to do next.
  • MCP server. apic mcp exposes every request as a tool for Claude Code, Cursor and friends.
  • Escape hatches. apic curl <id> prints the equivalent curl, apic snippet the same in five other languages; apic import scaffolds files from an OpenAPI spec or a Postman collection.

The same file is clickable in VS Code, JetBrains and Neovim, because apic's additions are comments.

Install

# macOS / Linux with Homebrew: binary, man pages and completions
brew install hungovercoders/tap/apic

# Go 1.25+
go install github.com/hungovercoders/apic/cmd/apic@latest

# Linux / macOS without Homebrew: downloads the release binary and verifies its checksum
curl -fsSL https://raw.githubusercontent.com/hungovercoders/apic/main/install.sh | sh

# Debian/Ubuntu, Fedora/RHEL, Alpine: .deb, .rpm and .apk on every release
sudo dpkg -i apic_<version>_linux_amd64.deb

# Docker: the binary on scratch, amd64 and arm64
docker run --rm -v "$PWD:/work" ghcr.io/hungovercoders/apic version

# Windows (PowerShell): verifies the checksum, adds apic to your user PATH
irm https://raw.githubusercontent.com/hungovercoders/apic/main/install.ps1 | iex

# Everything else: download from GitHub Releases
# GitHub Actions, any runner OS: verified, cached, on PATH
- uses: hungovercoders/apic/setup-apic@v0

APIC_VERSION=v1.2.3 pins a version and APIC_INSTALL_DIR=~/bin chooses where the binary lands (both installers read them). The installers verify the archive against the published checksums.txt and refuse to install on a mismatch; the action does the same and takes with: version: v1.2.3.

Every release is signed with cosign and ships an SPDX SBOM per archive (the image is signed too, with an SBOM attestation); see docs/verifying.md to check a download before trusting it.

60-second tour

# api/auth.http
### Log in and keep the token
# @name login
# @assert status == 200
# @capture token = body.$.access_token
POST {{baseUrl}}/auth/login
Content-Type: application/json

{"user": "{{user}}", "password": "{{password}}"}

### Who am I
# @name whoami
# @assert status == 200
# @assert body.$.email endsWith @example.com
GET {{baseUrl}}/me
Authorization: Bearer {{token}}
// api/http-client.env.json
{ "dev": { "baseUrl": "https://dev.example.com", "user": "alice" } }
// api/http-client.private.env.json  (gitignored)
{ "dev": { "password": "s3cret" } }

Start one with apic init api --base-url https://dev.example.com, or let apic import openapi.yaml write the first draft from a spec.

$ cd api
$ apic list
ID      METHOD  URL                       FILE          DESCRIPTION
login   POST    {{baseUrl}}/auth/login    auth.http:6   Log in and keep the token
whoami  GET     {{baseUrl}}/me            auth.http:14  Who am I

$ apic run whoami --env dev
error: auth.http:14: missing variable
  {{token}}: it is captured by request "login"; run `apic run login` first, or pass --var token=...

$ apic run login --env dev
POST https://dev.example.com/auth/login
200 OK · 87 ms · 412 B
{ "access_token": "eyJ..." }
✓ status == 200
↳ token = eyJ...

$ apic run whoami --env dev
GET https://dev.example.com/me
200 OK · 41 ms · 96 B
{ "email": "alice@example.com" }
✓ status == 200
✓ body.$.email endsWith @example.com

Set env: dev in api/apic.yaml to drop the --env flag.

Commands

Command What it does
apic run <id | file.http | file.http#id>... Send a request, or a file in order as a flow. --json, --body-only, -v headers, --var k=v, --env, --keep-going, --no-session, --redact; --assert and --capture try a check or a selector for one run, --dry-run shows the request without sending it, --body-limit 4k bounds the body in the output.
apic ui Terminal UI: browse, run, inspect, switch environment. --demo needs no project.
apic test [paths...] Run Gherkin features with the built-in vocabulary and # @step phrases. --format pretty|progress|junit|cucumber, --tags, --steps.
apic list [pattern] Every request: id, method, URL template, file:line, description.
apic describe <id> Variables the request needs and where each comes from, captures, asserts, and whether it is ready.
apic env Environments found and the variables in effect (secrets masked).
apic session [clear] Captured values stored in .apic/session.json.
apic history <request> The responses a request returned before, and apic history diff for what changed. Needs history: N in apic.yaml (apic init sets 10).
apic select <id> <selector> A value from the last recorded response, body.$.items[0].id or header.etag, without sending the request again.
apic curl <id> Equivalent curl command with variables resolved.
apic snippet <id> --lang python The same request as HTTPie, PowerShell, Python, JavaScript or Go code.
apic init [dir] Scaffold a project: config, env files, a first request, a feature and the Agent Skill.
apic skill [install] Print the briefing an AI agent reads before using apic, or write it into the project's .claude/skills and .agents/skills.
apic import <openapi.yaml> One .http per tag, one named request per operation, example bodies from schemas.
apic import <collection.postman.json> Folders to files, requests to named requests, variables to env files, simple pm.test checks to assertions.
apic import --curl '<command>' One named request from a curl command, appended to a file with --into.
apic validate Parse every file and report problems with line, column and a code; non-zero exit on errors. --format github annotates a pull request, --format sarif feeds code scanning.
apic fmt Rewrite .http files in their canonical form: directive order, header case, JSON bodies. --check for CI, - for editors, file.http#name for one request.
apic mcp Serve the project to AI agents over MCP (stdio).
apic lsp A language server for Neovim, Helix, JetBrains and any LSP editor: diagnostics as you type, completion, hover, run lenses, formatting.
apic demo Scaffold and serve a fake API (--out, --port, --force).

All commands take --json and -C <dir>, and none of them prompt. apic ui is the one exception, and it refuses to start without a terminal. apic mcp and apic lsp speak their own JSON protocol on stdout, so --json changes nothing for them. Colour is disabled when output is not a terminal or NO_COLOR is set.

Exit codes: 0 ok · 1 assertion or capture failed · 2 usage, parse error or missing variable · 3 network error. Every error also has a stable code (E101 missing variable, E301 could not connect, …), explained in the error catalogue.

Documentation

Published at hungovercoders.github.io/apic.

Getting started Install, first project, login flow, CI, agents
Terminal UI What apic ui shows and every key it takes
Cheat sheet Directives, selectors, operators and commands on one page
Cookbook Recipes: login once, CI smoke tests, AWS, OAuth2, polling, uploads
CLI reference Every command, flag, JSON shape and exit code
The .http format Directives, variables, selectors, assertions
Authentication AWS SigV4, OAuth2, digest, API keys, basic, bearer, exec
Testing with Gherkin .feature files, the step vocabulary, reports
Agents Shell and MCP integration, JSON contract
Editors VS Code (REST Client plus the apic extension), JetBrains, Neovim
Architecture The request lifecycle, the packages, the three contracts, how to add a directive
Errors Every error code, its exit status and what to do about it
FAQ Missing variables, 403s, secrets in logs, Windows
Taskfile Keep task as the front door
Comparison apic against Bruno, Hurl, Postman, httpyac, ijhttp, Kulala.nvim, curl
Migration guides From Postman, Bruno, Hurl, httpyac, curl and Taskfile

For agents

Shell: apic list --json, apic describe <id> --json, apic run <id> --json. MCP: claude mcp add api -- apic mcp --dir ./api --env dev. Skill: apic skill install writes the briefing into the project (apic init does too); apic skill prints it, and npx skills add hungovercoders/apic fetches the same skills/apic. See docs/agents.md for the JSON contract and a snippet to paste into your project's AGENTS.md. The contract only grows: a body that is not text now comes as base64 with body_encoding beside it, saved_to names the file a >> file line wrote, a # @disabled request a flow skipped prints "skipped": "disabled" with no response, response.proto says whether it came over HTTP/1.1 or HTTP/2, under run --data each object carries its iteration, warnings lists what went wrong without failing the request (a history that could not be written), and an error comes with its catalogue code: as error beside errors on a result, and as one {"error": {"code", "title", "message", "hint", "exit", "url"}} object on stderr (stdout is unchanged).

The format

See docs/format.md for the full spec: structure, directives, variable precedence, built-ins, selectors and assertion operators. Short version: standard .http, plus

# @name id
# @description one line
# @capture name = selector
# @assert selector op value
# @auth aws|oauth2|basic|...
# @step a user named {name} exists
# @no-redirect
# @no-session
# @timeout 10s

Keeping a Taskfile

If your team already runs task api:..., keep it and delegate:

tasks:
  api:
    desc: Run an API request, e.g. task api -- get-user --env staging
    cmds: [apic run {{.CLI_ARGS}}]

Development

task build
task example:demo   # run the built-in demo project end to end
task test
task lint

Tests run against local httptest servers; no network is needed. The examples/httpbin project targets httpbin.org for a live demo instead. Two more real-world examples live under examples/: github (bearer auth, task example:github) and spotify (oauth2 client-credentials, task example:spotify). Each needs your own credentials dropped into its http-client.private.env.json first; see examples/README.md.

See CONTRIBUTING.md before opening a pull request, and AGENTS.md if you are an AI agent working in this repository.

Security

apic handles credentials, so if you find a way one escapes — output that is not masked, a file mode that is wrong, a header that follows a redirect it should not — please report it privately rather than in an issue. The policy, the scope and what apic already promises are in SECURITY.md.

Licence

apic is released under the MIT Licence.

The binary links a handful of open source modules, each under its own permissive licence (MIT, BSD, Apache-2.0 and MPL-2.0). Every release archive ships a THIRD_PARTY_NOTICES.md reproducing them in full; regenerate it at any time with task notices.

Directories

Path Synopsis
cmd
apic command
Command apic runs .http request files for humans and AI agents.
Command apic runs .http request files for humans and AI agents.
internal
assert
Package assert parses and evaluates `# @assert` expressions: `<selector> <op> <value>`, `<selector> exists` / `not exists`, a predicate such as `<selector> isInteger` or `not isEmpty`, `<selector> length <op> <n>` and `<selector> matchesSchema <file>`.
Package assert parses and evaluates `# @assert` expressions: `<selector> <op> <value>`, `<selector> exists` / `not exists`, a predicate such as `<selector> isInteger` or `not isEmpty`, `<selector> length <op> <n>` and `<selector> matchesSchema <file>`.
auth
Package auth applies authentication to outgoing requests, driven by the `# @auth <type> [args]` directive or the `auth.default` setting in apic.yaml.
Package auth applies authentication to outgoing requests, driven by the `# @auth <type> [args]` directive or the `auth.default` setting in apic.yaml.
bdd
Package bdd runs Gherkin feature files against a project's .http requests with a fixed step vocabulary, using godog embedded in the binary.
Package bdd runs Gherkin feature files against a project's .http requests with a fixed step vocabulary, using godog embedded in the binary.
cli
Package cli wires the apic commands together.
Package cli wires the apic commands together.
curlimport
Package curlimport turns a curl command line into a `.http` request block, the reverse of `apic curl`: the common flags map onto the request line, headers, body and auth; the rest is reported, never fatal.
Package curlimport turns a curl command line into a `.http` request block, the reverse of `apic curl`: the common flags map onto the request line, headers, body and auth; the rest is reported, never fatal.
datafile
Package datafile reads the rows of a data-driven run, `apic run --data`: a CSV file whose header row names the columns, or a JSON array of objects.
Package datafile reads the rows of a data-driven run, `apic run --data`: a CSV file whose header row names the columns, or a JSON array of objects.
demoapi
Package demoapi backs `apic demo`: a tiny, fully in-memory HTTP API and its matching example .http project (embedded from project/), so apic can be tried with no network access and no git clone.
Package demoapi backs `apic demo`: a tiny, fully in-memory HTTP API and its matching example .http project (embedded from project/), so apic can be tried with no network access and no git clone.
env
Package env loads environment variable files:
Package env loads environment variable files:
history
Package history keeps the last few responses of each named request, per environment, so "what did this return yesterday?" has an answer.
Package history keeps the last few responses of each named request, per environment, so "what did this return yesterday?" has an answer.
httpfile
Package httpfile parses the common subset of the `.http` request file format used by VS Code REST Client, JetBrains HTTP Client, kulala.nvim and httpyac, plus apic's own `# @capture` / `# @assert` comment directives.
Package httpfile parses the common subset of the `.http` request file format used by VS Code REST Client, JetBrains HTTP Client, kulala.nvim and httpyac, plus apic's own `# @capture` / `# @assert` comment directives.
lsp
Package lsp is apic's language server: `apic lsp` speaks the Language Server Protocol over stdio, so any editor with an LSP client gets the diagnostics, completion, hover, code lenses and formatting the VS Code extension has, from the same code the CLI runs.
Package lsp is apic's language server: `apic lsp` speaks the Language Server Protocol over stdio, so any editor with an LSP client gets the diagnostics, completion, hover, code lenses and formatting the VS Code extension has, from the same code the CLI runs.
mcp
Package mcp exposes a project's requests to AI agents over the Model Context Protocol (stdio, or streamable HTTP behind a token), so an agent can discover and call an API without shelling out.
Package mcp exposes a project's requests to AI agents over the Model Context Protocol (stdio, or streamable HTTP behind a token), so an agent can discover and call an API without shelling out.
openapi
Package openapi scaffolds .http files from an OpenAPI 3 document: one file per tag, one named request per operation, path parameters as {{vars}} and an example body derived from the schema.
Package openapi scaffolds .http files from an OpenAPI 3 document: one file per tag, one named request per operation, path parameters as {{vars}} and an example body derived from the schema.
output
Package output renders run results for humans (coloured, readable) and for machines (one JSON object per result).
Package output renders run results for humans (coloured, readable) and for machines (one JSON object per result).
phrase
Package phrase turns `# @step` phrases such as `a user named {name} exists` into anchored regular expressions whose capture groups map to variables.
Package phrase turns `# @step` phrases such as `a user named {name} exists` into anchored regular expressions whose capture groups map to variables.
postman
Package postman turns a Postman collection (v2.1, or v2.0 where the shapes coincide) and its environments into .http files and env files: folders become files, requests become named requests, variables become http-client.env.json, and the trivial forms of pm.test scripts become `# @assert` and `# @capture` lines.
Package postman turns a Postman collection (v2.1, or v2.0 where the shapes coincide) and its environments into .http files and env files: folders become files, requests become named requests, variables become http-client.env.json, and the trivial forms of pm.test scripts become `# @assert` and `# @capture` lines.
project
Package project discovers .http files under a directory and indexes their requests by name.
Package project discovers .http files under a directory and indexes their requests by name.
report
Package report renders a self-contained HTML report of an `apic run` or an `apic test`: one file, inline CSS, no JavaScript needed to read it, light and dark through prefers-color-scheme.
Package report renders a self-contained HTML report of an `apic run` or an `apic test`: one file, inline CSS, no JavaScript needed to read it, light and dark through prefers-color-scheme.
runner
Package runner executes parsed requests: it resolves variables, sends the request, evaluates captures and assertions, and persists captured values to the session.
Package runner executes parsed requests: it resolves variables, sends the request, evaluates captures and assertions, and persists captured values to the session.
selector
Package selector extracts values from an HTTP response using the small selector language shared by `# @capture` and `# @assert`:
Package selector extracts values from an HTTP response using the small selector language shared by `# @capture` and `# @assert`:
session
Package session persists values captured from responses between apic invocations, so `apic run login` followed by `apic run get-user` works the way it does in a GUI client.
Package session persists values captured from responses between apic invocations, so `apic run login` followed by `apic run get-user` works the way it does in a GUI client.
snippet
Package snippet renders a resolved request as code that sends the same thing without apic: a curl command, an HTTPie command, PowerShell's Invoke-RestMethod, Python requests, JavaScript fetch or Go net/http.
Package snippet renders a resolved request as code that sends the same thing without apic: a curl command, an HTTPie command, PowerShell's Invoke-RestMethod, Python requests, JavaScript fetch or Go net/http.
template
Package template substitutes `{{expr}}` placeholders.
Package template substitutes `{{expr}}` placeholders.
ui
Package ui is the interactive terminal UI behind `apic ui`: a request list on the left, a tabbed detail pane on the right, and a status bar.
Package ui is the interactive terminal UI behind `apic ui`: a request list on the left, a tabbed detail pane on the right, and a status bar.
scripts
agenteval command
Command agenteval runs the skill's evals (skills/apic/evals/evals.json) through the Claude Code CLI against fresh `apic demo` projects, once with the skill installed and once without, and scores what the agent did rather than only what it answered: whether the task's outcome holds in the API or the files, which files it changed, whether it opened a secret file, how many requests it sent and how many selector or directive errors it hit on the way.
Command agenteval runs the skill's evals (skills/apic/evals/evals.json) through the Claude Code CLI against fresh `apic demo` projects, once with the skill installed and once without, and scores what the agent did rather than only what it answered: whether the task's outcome holds in the API or the files, which files it changed, whether it opened a secret file, how many requests it sent and how many selector or directive errors it hit on the way.
clidocs command
Command clidocs generates the "Commands and flags" section at the end of docs/cli.md and the man pages, from apic's own command tree, so the reference cannot drift from what the binary accepts.
Command clidocs generates the "Commands and flags" section at the end of docs/cli.md and the man pages, from apic's own command tree, so the reference cannot drift from what the binary accepts.
errdocs command
Command errdocs writes docs/errors.md from runner.Catalogue and httpfile.Codes, so an error's code, exit status, hint and documentation live in one table in the code and cannot drift from the page.
Command errdocs writes docs/errors.md from runner.Catalogue and httpfile.Codes, so an error's code, exit status, hint and documentation live in one table in the code and cannot drift from the page.
learncheck command
Command learncheck runs the commands in the course pages so a lesson cannot rot: it builds apic, starts `apic demo` in a scratch directory, then extracts every fenced block in docs/learn/*.md and docs/migrate/*.md that is preceded by an `<!-- learn -->` comment and runs it there with `sh -e`, in page order (the course first, then the migration guides).
Command learncheck runs the commands in the course pages so a lesson cannot rot: it builds apic, starts `apic demo` in a scratch directory, then extracts every fenced block in docs/learn/*.md and docs/migrate/*.md that is preceded by an `<!-- learn -->` comment and runs it there with `sh -e`, in page order (the course first, then the migration guides).
schemas command
Command schemas generates the JSON schemas for the files apic reads and writes: apic.yaml, http-client.env.json (and the private file, same shape) and .apic/session.json.
Command schemas generates the JSON schemas for the files apic reads and writes: apic.yaml, http-client.env.json (and the private file, same shape) and .apic/session.json.
shot command
Command shot regenerates the terminal screenshots in docs/assets from real apic output: it serves the demo API in-process, runs the requests the docs talk about, and renders the frames the CLI and the UI produce as SVG.
Command shot regenerates the terminal screenshots in docs/assets from real apic output: it serves the demo API in-process, runs the requests the docs talk about, and renders the frames the CLI and the UI produce as SVG.
skilldocs command
Command skilldocs writes skills/apic/references/cheatsheet.md from docs/cheatsheet.md, the one page an agent needs when it writes a request.
Command skilldocs writes skills/apic/references/cheatsheet.md from docs/cheatsheet.md, the one page an agent needs when it writes a request.
Package skills carries the Agent Skill that `apic skill` prints and installs: skills/apic in this repository, compiled into the binary so a project gets it from `apic init` or `apic skill install` without the repository or a network.
Package skills carries the Agent Skill that `apic skill` prints and installs: skills/apic in this repository, compiled into the binary so a project gets it from `apic init` or `apic skill install` without the repository or a network.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL