TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/coinbase-api/llms.txt
Use this file to discover all available pages before exploring further.
coinbase-api SDK ships with a built-in DefaultLogger that writes to the console at three severity levels: trace, info, and error. You can override any or all of these levels to filter noisy output, integrate with a structured logging library, or silence the SDK entirely in test environments.
The DefaultLogger
The built-in logger is exported from the package asDefaultLogger. Its default behaviour is:
trace— silent by default (commented out). Used for verbose internal events like ping/pong frames and upstream WebSocket messages.info— writes toconsole.info. Used for connection lifecycle events (open, reconnect, close).error— writes toconsole.error. Used for unexpected failures and parsing errors.
Passing a Custom Logger
Pass a custom logger as the second argument toWebsocketClient (or any REST client constructor). The logger must implement trace, info, and error methods.
The logger is the second argument to
WebsocketClient. REST clients (CBAdvancedTradeClient, CBExchangeClient, etc.) do not currently accept a custom logger — logging customisation is primarily relevant for the WebSocket client, which generates high-frequency trace events.Filtering Noisy Ping/Pong Messages
When you enable trace-level logging, you will see frequent messages from the SDK’s internal heartbeat mechanism. Use a spread ofDefaultLogger and override only the trace function to selectively filter these out:
Redirecting to a Custom Logging Library
Create a thin adapter that maps the SDK’strace/info/error interface onto your preferred logging library.
- pino
- winston
- Silent (test environments)
HTTP Request Tracing
For REST clients, the SDK also supports low-level HTTP tracing via theCBTRACE environment variable. When set, every outgoing request and its response are logged to console.log:
BaseRestClient using Axios interceptors and is independent of the logger interface — it always writes to console.log and cannot be redirected.
CBTRACE is intended for debugging only. It logs full request URLs, method names, parameters, and response bodies, which may include sensitive data. Do not enable it in production.Logger Interface Reference
Your custom logger object must implement these three methods:| Method | Typical use in SDK | Default behaviour |
|---|---|---|
trace(...params) | Ping/pong frames, WS message sends, subscription batches | Silent |
info(...params) | Connection open/close/reconnect lifecycle | console.info |
error(...params) | Parse failures, unexpected WS errors | console.error |
...params argument. The first element is typically a string message; subsequent elements may be objects with additional context.