Plasma

API Reference

Methods and options for Plasma HTTP client

createHttpClient(config)

Creates a typed HTTP client.

OptionTypeDescription
serverUrlstring | undefinedBase URL for your API
routesServerRoutesRoute definitions object
adapter(data: any) => any(Optional) Transform the response body
interceptorsInterceptors(Optional) Request/response interceptors

client.GET(alias[, options])

  • options is omittable when the route has no params schema
  • options is required (and must include params) when the route defines a params: z.object(...) schema
// Route defines `params: z.object(...)` — options is required
const [, ] = await .('get-users', {
  : { : 1, : 'admin' }, // required
  : true,                          // optional, default: true
})

// Route has no `params` schema — second argument can be omitted entirely
const [, ] = await .('get-profile')

// Or pass options to override auth when no params are needed
const [, ] = await .('get-profile', { : false })
PropertyRequiredTypeDefaultDescription
paramsWhen route defines a params schemaz.infer<Route["params"]>Query parameters, validated and coerced by the route's Zod schema
authNobooleantrueWhether to enforce the Authorization header

client.POST(alias, body[, options])

If the route defines an apiPayload schema, the body is validated and coerced before being sent. Invalid data returns [ZodError, null] without making a network request.

Options (all optional):

PropertyRequiredTypeDefaultDescription
paramsNoobjectQuery parameters appended to the URL
bodyTypeNo'json' | 'form-data''json'Serialization format
authNobooleantrueWhether to enforce the Authorization header

client.PATCH(alias, body[, options])

Identical signature to client.POST. Use for partial update requests.

On this page