TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/sieblyio/kraken-api/llms.txt
Use this file to discover all available pages before exploring further.
@siebly/kraken-api SDK ships with a built-in default logger that writes info and error messages to the console and silently discards trace-level output. For most development work this is fine, but in production you will almost certainly want SDK logs flowing into the same structured logging pipeline as the rest of your application — whether that is pino, winston, a cloud logging service, or something else entirely. The SDK makes this straightforward: pass any object that satisfies the DefaultLogger interface as the second argument to WebsocketClient, and the SDK will route all internal log calls through it.
The DefaultLogger interface
The SDK exports both the default implementation and its type. The interface is intentionally minimal — three methods, each accepting a variadic argument list:
trace— verbose connection lifecycle events (subscribe/unsubscribe dispatches, heartbeat ticks, raw frame details). Useful for debugging; noisy in production.info— routine operational messages (connection opened, authentication succeeded, subscription confirmed).error— unexpected conditions that warrant attention (failed authentication, unhandled message types, connection errors).
Custom logger example
The simplest approach is to define an object literal that matches theDefaultLogger type and pass it directly to the WebsocketClient constructor. This pattern is taken directly from the SDK’s own examples:
The logger is the second argument to the
WebsocketClient constructor. The first argument is the options object (which holds your API credentials, proxy settings, etc.). If you only need a logger and have no credentials, pass an empty object as the first argument: new WebsocketClient({}, customLogger).Suppressing trace logs
In production environments,trace logging produces a high volume of output that is rarely useful outside of active debugging sessions. The default logger already suppresses trace, but if you are building a custom logger that forwards info and error to an external sink, make sure you also include a silent trace to avoid accidentally flooding your logging infrastructure:
Integrating with popular loggers
Using with pino
pino is a fast, low-overhead JSON logger popular in Node.js services. Map each SDK log level to its pino equivalent:
level: 'trace' on the pino logger if you want full trace output, or keep it at 'info' to suppress trace in production.
Using with winston
winston is a versatile logger that supports multiple transports (files, HTTP, external services). The adapter is the same shape:
pino and winston both use debug rather than trace as their lowest named level. Mapping SDK trace → debug is the conventional approach.
Using with console (default behaviour)
If you want to replicate the default behaviour explicitly — for example, to add a prefix to every message without changing the output format — override only the methods you care about:
REST client logging
REST clients (SpotClient, DerivativesClient) do not accept a custom logger argument — they use axios internally and surface errors through promise rejections rather than log calls. If you need HTTP-level visibility into REST requests and responses, set the KRAKENTRACE environment variable before starting your process:
KRAKENTRACE is set, the SDK registers axios interceptors that log every outgoing request (URL, method, params) and every incoming response (status, headers, body) to console.log. This is intended for development-time debugging only — disable it in production.