Under heavy development
StitchAPI
Reference

Helpers

fetchAdapter, createTrace, multiplex, the OTLP exporters, memoryStore, and toValidator.

The exported helper functions you wire into a stitch: the default transport, the trace sinks (including OTLP export), the default store, and the schema adapter. Each signature is below; the guides cover usage in depth and are linked under See also.

Transport

fetchAdapter

The default fetch-based transport. Returns an Adapter backed by the global fetch; it never throws on a non-2xx response — only network and abort errors propagate, leaving the engine to decide what a status means.

import {  } from 'stitchapi';

const  = ();

Tracing & OTLP

createTrace

Build a zero-infra trace sink: a compact one-line-per-event summary on the console and/or an appended JSONL record per event. console defaults to true; file defaults to a path under $HOME, or false to disable the JSONL stream.

import {  } from 'stitchapi';

const  = ({ : true, : false });

multiplex

Fan one event stream out to several sinks — for example console/JSONL alongside OTLP — flushing each in turn.

import { , ,  } from 'stitchapi';

const  = ((), ());

otlpTrace

An opt-in OpenTelemetry sink: it maps each stitch call's events to a single OTel CLIENT span and hands finished spans to a SpanExporter. With no exporter supplied it uses otlpHttpExporter. Configured by OtlpOptions (below).

import {  } from 'stitchapi';

const  = ({ : 'https://api.example.com:4318' });

otlpHttpExporter

The default exporter: POST spans as OTLP/JSON to ${endpoint}/v1/traces. The endpoint defaults to OTEL_EXPORTER_OTLP_ENDPOINT or http://localhost:4318. Fire-and-forget — a missing collector never breaks a stitch call.

import {  } from 'stitchapi';

const  = ({
    : 'https://api.example.com:4318',
    : { : 'Bearer token' },
});

toOtlpJson

Serialize finished spans to the OTLP/JSON ResourceSpans shape a collector accepts on /v1/traces — useful for a custom SpanExporter.

import {  } from 'stitchapi';

const  = ([]);

OtlpOptions

Prop

Type

Store

memoryStore

The default in-memory StitchStore: single-process, with TTL and atomic increment. Swap it for a Redis/Postgres-backed store to make throttling distributed and sessions shared across workers, with no change to the call site.

import {  } from 'stitchapi';

const  = ();

Validation

toValidator

Coerce a Zod schema, any Standard Schema, an existing Validator, or a predicate into a Validator — returning undefined when passed null or undefined. This is how Zod-first projects keep Zod while Valibot/ArkType also work.

import {  } from 'stitchapi';

const  = ((: unknown) => typeof  === 'string');

See also

On this page