The fluent builder
Build a stitch step by step with .get/.post/.returns/.auth/.retry/.throttle/.timeout.
Start from stitch.use(...) and chain methods to assemble a stitch piece by
piece, then call the result like a function — handy when you build the request
incrementally or add behavior conditionally rather than declaring it all at once.
Example
import { , , } from 'stitchapi';
const =
.({ : 'https://api.example.com' })
.('/users/{id}')
.((('API_TOKEN')))
.({ : 3 });
const = await ({ : { : 1 } });Each method returns the same builder, so the chain reads top to bottom; the
final value is callable, so getUser(...) runs the request.
Options
The builder is just another facade over the same engine — every chain resolves
to one canonical config, exactly as if you had passed that object to
stitch(). Reach for it when the shape is not
known up front: build the base, then add .auth(...) or .retry(...) only when
a flag says so. When the whole config is static, the object form reads just as
well.
The chainable methods, each returning the builder:
.use(...fragments)merges config fragments into the accumulator..get(path)/.post(path)/.put(path)/.delete(path)set both the method and the path..returns(schema)sets the output schema;.unwrap(key)pulls a nested key out of the response..auth(strategy)attaches an auth strategy such asbearer(env(...))..retry(opts)/.throttle(opts)/.timeout(opts)add resilience options.
The result also carries .stream(input) for the event stream and
.with(partial) for partial application.
The builder is callable: the value at the end of the chain is the stitch, so you invoke it directly — there is no separate build step.