Lesson 1: Install apic and send your first request
Goal. Install apic, run a request from a .http file against the demo
API, and read the file that described it.
You will need
Section titled “You will need”- A terminal. Nothing else: this lesson installs apic and the demo API ships inside it.
1. Install apic
Section titled “1. Install apic”One static binary, no runtime. Pick your platform:
Homebrew (macOS and Linux)
Section titled “Homebrew (macOS and Linux)”brew install hungovercoders/tap/apicThe cask installs the binary, the man pages and shell completions, and
brew upgrade follows new releases.
Linux / macOS without Homebrew
Section titled “Linux / macOS without Homebrew”curl -fsSL https://raw.githubusercontent.com/hungovercoders/apic/main/install.sh | shThe installer puts apic in ~/.local/bin (or /usr/local/bin when
that is writable), verifies the release checksum, and prints where it
landed. If the directory is not on your PATH, it says so.
Windows
Section titled “Windows”In PowerShell:
irm https://raw.githubusercontent.com/hungovercoders/apic/main/install.ps1 | iexThe installer puts apic.exe in %LOCALAPPDATA%\Programs\apic,
verifies the release checksum, and adds the directory to your user
PATH (open a new terminal for other windows to see it).
go install github.com/hungovercoders/apic/cmd/apic@latest # Go 1.26.11 or newerThis builds from source into $(go env GOPATH)/bin.
In GitHub Actions, the setup-apic action installs
it in one step; lesson 8 uses it.
Check it answers:
apic versionapic v0.2.0 · 1a2b3c4 · go1.26.11 linux/amd64apic is epic · https://apic.sh/Your version and platform will differ; the shape is what matters.
2. Thirty seconds in the UI
Section titled “2. Thirty seconds in the UI”Before any files, see the tool move. apic ui --demo serves a fake API
inside the process and opens the terminal UI on an example project that
targets it:
apic ui --demoFour keys are enough for now:
| Key | What it does |
|---|---|
| enter | Send the request under the cursor |
| f | Run the whole file the cursor is in, as a flow |
| ? | Every key |
| q | Quit |
Press enter on login. The right pane shows the status, the
body and a green check. Press j to move down to whoami and
enter again: it uses the token login just captured. Press
q. Lesson 5 is the full tour; the rest of this course works from
the command line, where every step is a command you can copy.
3. Start the demo API and look at the project
Section titled “3. Start the demo API and look at the project”apic demo writes the same example project to a directory and serves the
API it targets. Leave it running in one terminal:
apic demo --out apic-demowrote apic-demo/apic.yamlwrote apic-demo/auth.httpwrote apic-demo/explore.httpwrote apic-demo/features/todos.featurewrote apic-demo/http-client.private.env.jsonwrote apic-demo/jobs.httpwrote apic-demo/todos.httpwrote apic-demo/http-client.env.jsondemo api listening on http://localhost:8089try: apic run login whoami -C apic-demo --env localIn a second terminal, list what the project contains. -C tells every apic
command which directory the project is in:
apic list -C apic-demoID METHOD URL LINE DESCRIPTION PHRASESauth.httplogin POST {{baseUrl}}/auth/login :9 Log in and keep the token I am logged inwhoami GET {{baseUrl}}/me :20 Who am I, using the token captured by login (which runs first if needed) I ask who I ambasic-auth GET {{baseUrl}}/basic-auth/{{user}}/{{password}} :28 Basic auth, encoded for you…todos.httplist-todos GET {{baseUrl}}/todos :8 List todos I list the todoslist-open-todos GET {{baseUrl}}/todos?done=false&page=1&limit=5 :18 Filter and paginate; the total comes back in a header I list the open todos…
24 requests in 4 files · apic describe <id> · apic run <id> · apic uiFour files, twenty-four requests, each with an id you can type. The
PHRASES column is for lesson 7.
4. Describe a request before sending it
Section titled “4. Describe a request before sending it”describe shows everything apic knows about a request without sending it:
the method and URL, every variable it needs and where each one comes from,
and whether it is ready.
apic describe login -C apic-demoPOST {{baseUrl}}/auth/loginLog in and keep the tokenfile: auth.http:9
headers Content-Type: application/json
body {"user": "{{user}}", "password": "{{password}}"}
variables ✓ baseUrl http://localhost:8089 http-client.env.json [local] ✓ user alice auth.http:1 @user ✓ password *** http-client.private.env.json [local]
steps I am logged in
captures ↳ token = body.$.access_token
asserts status == 200
╭──────────────────────────────╮│ ready {{baseUrl}}/auth/login │╰──────────────────────────────╯Three variables, three different sources, and a password shown as ***
because it came from the private file. Lesson 2 is about that column.
5. Send it
Section titled “5. Send it”apic run login -C apic-demoPOST http://localhost:8089/auth/login200 OK · 1 ms · 30 B
{ "access_token": "mock-token"}
✓ status == 200↳ token = mock-tokenStatus, timing, size, the body, the assertion that passed, and the value
that was captured. That last line is the one to remember: token is now
stored, and every later request that says {{token}} will find it.
6. Read the file
Section titled “6. Read the file”Open apic-demo/auth.http in any editor. The first request is:
@user = alice@clientId = demo-client
### Log in and keep the token# @name login# @step I am logged in# @assert status == 200# @capture token = body.$.access_tokenPOST {{baseUrl}}/auth/loginContent-Type: application/json
{"user": "{{user}}", "password": "{{password}}"}Line by line:
| Line | What it is |
|---|---|
@user = alice | A file variable, available to every request in the file as {{user}}. |
### Log in and keep the token | The separator that starts a request, and its title. |
# @name login | The id. Without it the request would be auth.http#1. |
# @step I am logged in | A Gherkin phrase for lesson 7. Ignore it for now. |
# @assert status == 200 | A check on the response. Lesson 4. |
# @capture token = body.$.access_token | Keep a value from the response. Lesson 3. |
POST {{baseUrl}}/auth/login | The request line: method and URL, with a variable. |
Content-Type: application/json | Headers, until the first blank line. |
{"user": …} | The body, until the next ###. |
Every line starting with # is a comment to any other tool that reads
.http files, so this file still works in VS Code and JetBrains. The
# @ lines are apic’s directives, and the
cheatsheet lists every one.
7. Exit codes
Section titled “7. Exit codes”Scripts and CI read the exit code before anything else. 0 means every
assertion passed:
apic run login -C apic-demo > /dev/null; echo "exit $?"exit 0The demo project has one request that fails its assertion on purpose:
apic run not-found -C apic-demo || echo "exit $?"GET http://localhost:8089/status/404404 Not Found · 1 ms · 15 B
{ "status": 404}
✗ status == 200 (actual: 404)exit 11 is an assertion that failed. 2 is a mistake before anything was sent
(a missing variable, a request id that does not exist) and 3 is the
network. The exit codes table is the contract.
Checkpoint
Section titled “Checkpoint”--json prints one JSON object per request. If this prints "ok":true,
apic is installed, the demo is up, and you have sent a request through
both:
apic run login -C apic-demo --json | grep -o '"ok":true'"ok":true(With jq installed, apic run login -C apic-demo --json | jq .ok prints
true.)
Exercise
Section titled “Exercise”The demo API has a GET /health endpoint that needs no token. Add a
request for it, named ping, to apic-demo/auth.http (or to a new file
in the same directory), and run it with apic run ping -C apic-demo.
Solution
Appending a request to a new file keeps the shipped one clean:
cat >> apic-demo/mine.http <<'EOF'### Is the API up?# @name ping# @assert status == 200GET {{baseUrl}}/healthEOFapic run ping -C apic-demoGET http://localhost:8089/health200 OK · 1 ms · 73 B
{ "service": "apic-demo", "status": "ok", "uptime_seconds": 12, "version": "v0.2.0"}
✓ status == 200{{baseUrl}} resolves in any file in the project because it comes from
http-client.env.json, not from the file. The ### line, # @name
and the request line are the whole request; headers and a body are
only there when the request needs them.
Going further
Section titled “Going further”- Getting started, the same steps for a real project
- The terminal UI, every key
apic runand the exit codes
Episode script
Length. 8 to 10 minutes.
Cold open (after the title card). An empty terminal. “In ten minutes you will have sent a request from a text file, and understood every line of the file.”
Talking points.
- Install: thirty seconds per platform, cut short.
apic versionproves it. apic ui --demo: enter on login, j, enter on whoami. “That second request used the token the first one captured. Hold that thought for lesson 3.”apic demoin terminal one;list,describe login,run loginin terminal two. Point at the three variable sources and the***.- The file, line by line, with the table on screen.
- Exit codes: 0, then the deliberate 404 and its
✗line, then the1. - The checkpoint, and the
--jsonline it comes from.
Shot list. Per-OS install as three short picture-in-picture clips;
then one terminal, 100x30, font size 16. docs/learn/tapes/01.tape
reproduces the terminal parts. Zoom on ↳ token = mock-token after
step 5 and on exit 1 in step 7.
Chapters. 0:00 Why · 0:30 Install · 1:40 The UI in thirty seconds · 3:00 list, describe, run · 5:20 The file, line by line
· 7:10 Exit codes · 8:10 Checkpoint · 8:40 Exercise and lesson 2.
Description. From the episode template.
Hosted on Cloudflare, which keeps aggregate traffic statistics. No cookies, no tracking scripts, no per-request logs. Privacy