api-caller

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 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/dataGriff/api-caller/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

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; 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 import openapi.yaml scaffolds files from a spec.

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

Install

# Go 1.25+
go install github.com/dataGriff/api-caller/cmd/apic@latest

# Linux / macOS: downloads the release binary and verifies its checksum
curl -fsSL https://raw.githubusercontent.com/dataGriff/api-caller/main/install.sh | sh

# Windows and everything else: download from GitHub Releases

APIC_VERSION=v1.2.3 pins a version and APIC_INSTALL_DIR=~/bin chooses where the binary lands.

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.
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 curl <id> Equivalent curl command with variables resolved.
apic init [dir] Scaffold a project: config, env files, a first request and a feature.
apic import <openapi.yaml> One .http per tag, one named request per operation, example bodies from schemas.
apic validate Parse every file and report problems; non-zero exit on errors. Use it in CI.
apic mcp Serve the project to AI agents over MCP (stdio).
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. 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.

Documentation

Published at datagriff.github.io/api-caller.

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, basic, bearer, exec
Testing with Gherkin .feature files, the step vocabulary, reports
Agents Shell and MCP integration, JSON contract
FAQ Missing variables, 403s, secrets in logs, Windows
Taskfile Keep task as the front door
Comparison apic against Bruno, Hurl, Postman, curl

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. See docs/agents.md for the JSON contract and a snippet to paste into your project's AGENTS.md.

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.

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 of the form `<selector> <op> <value>` or `<selector> exists` / `<selector> not exists`.
Package assert parses and evaluates `# @assert` expressions of the form `<selector> <op> <value>` or `<selector> exists` / `<selector> not exists`.
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.
curlexport
Package curlexport renders a resolved request as a curl command, so a request can still be run where apic is not installed.
Package curlexport renders a resolved request as a curl command, so a request can still be run where apic is not installed.
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:
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.
mcp
Package mcp exposes a project's requests to AI agents over the Model Context Protocol (stdio), 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), 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.
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.
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.
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
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.

Jump to

Keyboard shortcuts

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