← All use cases

Add an API endpoint

Point Pier at your service and describe the endpoint. It finds the routing, the handlers, and the tests, then writes the change to match.

Pier - api

Add a GET /v1/usage endpoint that returns the caller's monthly credit spend

I'll wire the route into the billing router and reuse the credits ledger query.

Edited src/routes/usage.rs (+4 -1)

18 let user = ctx.require_user().await?;
19- Ok(Json(json!({ "ok": true })))
19+ let spend = credits::month_to_date(&ctx.db, user.id).await?;
20+ Ok(Json(UsageResponse {
21+ micro_usd: spend.micro_usd,
22+ calls: spend.call_count,
23+ }))

Ran cargo test usage::

test usage::month_to_date_sums_calls ... ok

test result: ok. 1 passed

Endpoint live and the ledger sum is covered by a test. Ready to commit?

Ask Pier anything… (/ for commands)

sarvam/sarvam-105B (shift+tab to cycle) · / for commands13.6k tokens88%
  1. 01Describe the endpoint in plain language.
  2. 02The agent maps your routing layer, models, and existing handlers.
  3. 03It plans the change across the files it needs to touch and shows you the diff.
  4. 04You approve, it writes, and it runs your tests to confirm the route works.

Adding an endpoint is rarely one file. There is a route to register, a handler to write, a model or query to wire up, validation and error handling to match your existing patterns, and a test to keep the suite green. Pier reads your project first so it follows your conventions instead of inventing its own: it picks up how you name routes, where your handlers live, which error type you return, and how the neighbouring endpoints are tested.

That up-front reading is what separates a useful agent from autocomplete. Instead of pasting a generic handler that you then spend twenty minutes reshaping, you get a change that already looks like the rest of the file. The agent traces the request from the router down to the data layer, reuses the query helpers you already have, and wires the response type into your existing serialization.

Because every change is diffed and gated before it lands, you stay the operator: you see exactly what the agent intends to do, approve it, and let it run the verification loop. The result is a working endpoint that looks like the rest of your codebase wrote it. To see the same care on a much bigger job, the codebase-wide migration walkthrough shows it across dozens of files.

An endpoint is a small job, so it is a cheap one. The cost per task page puts a number on it.

Related

Begin here

A gateway between people and intelligence. Join the early-access list and be first to ship with Pier.

$curl -fsSL https://dl.piercode.com/stable/install.sh | sh

1.45k devs and engineers ship with Pier daily