Skip to main content
The III SDK provides types for handling HTTP API requests and responses, including support for streaming data.

ApiRequest

Represents an incoming HTTP request with parsed parameters and body.

Fields

object
required
Path parameters extracted from the URL pattern (e.g., /users/:id{ id: "123" }).
object
required
Query string parameters. Values can be strings or arrays for repeated parameters.
TBody
required
The parsed request body. Type can be specified via generic parameter.
object
required
HTTP headers. Values can be strings or arrays for repeated headers.
string
required
HTTP method (GET, POST, PUT, PATCH, DELETE, etc.).

ApiResponse

Represents an HTTP response to be sent back to the client.

Fields

number
required
HTTP status code (200, 404, 500, etc.).
object
Response headers to include.
TBody
Response body. Can be a string, Buffer, or object (automatically JSON serialized).

HttpRequest

For streaming HTTP handlers, includes access to the request body stream.

Additional Fields

ChannelReader
required
Stream reader for accessing the raw request body as chunks.

HttpResponse

Streaming response writer for HTTP handlers.

Methods

function
required
Set the HTTP status code for the response.
function
required
Set response headers.
WritableStream
required
Writable stream for sending response body chunks.
function
required
Close the response stream and complete the HTTP response.

Usage Examples

Simple API Handler

Streaming Response